def handle(self): p = float(self.request.get("p")) SEATS_PER_TABLE = 10 for price in [p]: t = Table(price=btc2satoshi(price)) t.put() for n in xrange(SEATS_PER_TABLE): seat = Seat(table=t, number=n, purchase_addr=new_address(), state=EMPTY) seat.table = t seat.put() from time import sleep sleep(1) return {"success":True}
def generate_receiver_for_seeding(pending_amt): """ Generates a new receiving address for seeding and does not add a pending transaction to db :return: str the address generated """ bc_address = blockchain.new_address(label="SEEDING") node = Node(address=bc_address.address, role="seeding", status='pending', balance=bc_address.balance, pending_amt=pending_amt, label="SEEDING") db.session.add(node) db.session.commit() return bc_address.address
def generate_receiver(destination, pending_amt): """ Generates a new receiving address and adds a pending transaction to db :return: str the address generated """ bc_address = blockchain.new_address(label="RECEIVING") node = Node(address=bc_address.address, role="receiving", status='pending', balance=bc_address.balance, destination=destination, pending_amt=pending_amt, label="RECEIVING") tx = Tx(parent=bc_address.address, amount=pending_amt, destination=destination) db.session.add(tx) db.session.add(node) db.session.commit() return bc_address.address
def create_user_db(name, username, email='', **params): username = username.split('@')[0] new_username = username n = 1 while model.User.retrieve_one_by('username', new_username) is not None: new_username = '******' % (username, n) n += 1 user_db = model.User( name=name, email=email.lower(), username=new_username, **params ) user_db.address = new_address() user_db.put() return user_db
def handle(self): p = float(self.request.get("p")) SEATS_PER_TABLE = 10 for price in [p]: t = Table(price=btc2satoshi(price)) t.put() for n in xrange(SEATS_PER_TABLE): seat = Seat(table=t, number=n, purchase_addr=new_address(), state=EMPTY) seat.table = t seat.put() from time import sleep sleep(1) return {"success": True}
def blunderbuss(parent, amount, origin): """ Generates a random number of addresses between 1 and MAX_BLUNDERBUSS, then distributes the proportion randomly among them. TODO: proportions are currently even. make them random. :param str parent: the address of the parent :param float amount: the amount to be distributed over the generated shufflers :return: true if success, false otherwise """ success = True num_to_use = random.randint(1, MAX_BLUNDERBUSS) addresses_to_use = [] nodes = [] amount = amount - 0.0001 # account for miner's fee #percent_left = range(100) logger.info("generating " + str(num_to_use) + " shuffling addresses") # Generate new addresses and save them to db for i in range(num_to_use): try: bc_address = blockchain.new_address(label="SHUFFLING") addresses_to_use.append(bc_address.address) node = Node(address=bc_address.address, role="shuffling", status="fresh", balance=bc_address.balance, parent=parent, label="SHUFFLING", origin=origin) db.session.add(node) db.session.commit() logger.info("saved shuffling address " + str(bc_address.address) + " to db") except Exception, error: success = False logger.error("error while generating shufflers") logger.error(error)
def blunderbuss(parent, amount, origin): """ Generates a random number of addresses between 1 and MAX_BLUNDERBUSS, then distributes the proportion randomly among them. TODO: proportions are currently even. make them random. :param str parent: the address of the parent :param float amount: the amount to be distributed over the generated shufflers :return: true if success, false otherwise """ success = True num_to_use = random.randint(1, MAX_BLUNDERBUSS) addresses_to_use = [] nodes = [] amount = amount - 0.0001 # account for miner's fee #percent_left = range(100) logger.info("generating "+str(num_to_use)+" shuffling addresses") # Generate new addresses and save them to db for i in range(num_to_use): try: bc_address = blockchain.new_address(label="SHUFFLING") addresses_to_use.append(bc_address.address) node = Node(address=bc_address.address, role="shuffling", status="fresh", balance=bc_address.balance, parent=parent, label="SHUFFLING", origin=origin) db.session.add(node) db.session.commit() logger.info("saved shuffling address "+str(bc_address.address)+" to db") except Exception, error: success = False logger.error("error while generating shufflers") logger.error(error)
def to_dict(self): if not self.payment_address: self.payment_address = new_address(self.digest) self.put() d = db.to_dict(self) return d
def to_dict(self): if not self.payment_address: self.payment_address = new_address() self.put() d = db.to_dict(self) return d
def to_dict(self): if not self.payment_address: self.payment_address = new_address(self.digest) self.put() return rom.Model.to_dict(self)