def noname(*args, **kw): cs = get_clients() rs = [] for c in cs: try: rs.append(getattr(c,name)(*args, **kw)) except ConnectionRefusedError: cprint('WARN', 'Contact with node %s failed when calling method %s , please check the node.' % (c.node,name)) else: cprint('INFO', 'Contact with node %s successful calling method %s .' % (c.node,name)) return rs
def start_node(hostport='0.0.0.0:3009'): init_node() cprint('INFO', 'Node initialize success.') try: if hostport.find('.') != -1: host, port = hostport.split(':') else: host = '0.0.0.0' port = hostport except Exception: cprint( 'ERROR', 'params must be {port} or {host}:{port} , ps: 3009 or 0.0.0.0:3009' ) p = multiprocessing.Process(target=rpc.start_server, args=(host, int(port))) p.start() cprint('INFO', 'Node start success. Listen at %s.' % (hostport, ))
def new_untransaction(self,untx): cprint(__name__,untx) UnTransactionDB().insert(untx) cprint('INFO',"Receive new unchecked transaction.") return True
def blocked_transactions(self,txs): TransactionDB().write(txs) cprint('INFO',"Receive new blocked transactions.") return True
def new_block(self,block): cprint(__name__, block) BlockChainDB().insert(block) UnTransactionDB().clear() cprint('INFO',"Receive new block.") return True