# /* BOOT CONSOLE */ ####################################################################### w3 = init_web3() myIP = '172.27.1.100' myTIME = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) myENODE = w3.geth.admin.nodeInfo().enode myKEY = w3.eth.coinbase tcpTIME = TCP_server(myTIME, myIP, 40123, True) tcpENODE = TCP_server(myENODE, myIP, 40421, True) tcpKEY = TCP_server(myKEY, myIP, 40422, True) def clock(): while True: myTIME = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) tcpTIME.data = myTIME # Initialize background daemon thread clockTh = threading.Thread(target=clock, args=()) clockTh.daemon = True clockTh.start() tcpTIME.start() tcpENODE.start() tcpKEY.start()
def getEnodes(): return [peer.enode for peer in w3.geth.admin.peers()] def getIds(): return [readEnode(enode) for enode in getEnodes('geth')] if __name__ == "__main__": w3 = init_web3() myID = open("/boot/pi-puck_id", "r").read().strip() myEN = w3.geth.admin.nodeInfo().enode myKEY = w3.eth.coinbase me = Peer(myID, myEN, myKEY) pc = Peer('100') if len(sys.argv) >= 2: if sys.argv[1] == '--mine': tcpPort = 40421 tcp = TCP_server(me.enode, me.ip, tcpPort) tcp.start() tcp.unlock() peerBuffer = [] # globalBuffer() waitForPC() waitForTS() w3.geth.miner.start()