def __init__(self, initial_text=None): ''' Document helper class to make interaction with the Infinote library a little bit easier. Each collaboratively edited document can be instantiated as an InfinoteDocument :param str initial_text: Start this document with initial text ''' self.log = [] self._state = State() if initial_text is not None: self.try_insert([1, '', 0, str(initial_text)])
STEP = args.STEP PORT = args.port if args.port is not None else 18443 State.PORT = PORT REPS = args.reps if args.reps is not None else 100 # Number of # repetitions per config NUM_PEERS = args.peers if args.peers is not None else 10000 # total # number of peers PROTOCOL = bytes([0x01]) # Protocol used for ads # Connect to Daemon con = AuthServiceProxy( "http://%s:%[email protected]:%s" % (State.RPC_USER, State.RPC_PASSWORD, PORT), ) # Create state in which each block can contain advertisements. s = State(1, 1, 0) # Load peers try: peers = get_peers(NUM_PEERS) except FileNotFoundError: print( "File peers/peers_%d.pyc does not exist. Execute 'anonboot/generate_peers.py %d'." % (NUM_PEERS, NUM_PEERS)) sys.exit() # Fix problem with wrong format of IPs for p in peers: if type(p.ip_address) is str: p.ip_address = ipaddress.ip_address(p.ip_address)
errors = 0 last_success = 0 for i in range(5100, 5300, 1): if errors >= 2: # 2 consecutive fails occurred write("**********************************") write( "The largest block that could be mined contained {} " "TXs.".format( i - 2)) write("**********************************") break try: ads = [] tmp_state = State(1, 1, 0) for p in peers[:i]: ads.append(p.advertise(tmp_state)) print("Attempt to write {} advertisements".format(len(ads))) con = connect() for ad in ads: input = inputs.popleft() raw = con.createrawtransaction([input['in']], [{'data': ad}]) funded = con.fundrawtransaction(raw, { "changeAddress": input['addr']}) signed = con.signrawtransactionwithwallet(funded['hex']) sent = con.sendrawtransaction(signed['hex']) raw = con.getrawtransaction(sent, 1) vout = -1 new_value = input['amount'] - 1 for v in raw['vout']: