Example #1
0
 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
Example #2
0
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, ))
Example #3
0
 def new_untransaction(self,untx):
     cprint(__name__,untx)
     UnTransactionDB().insert(untx)
     cprint('INFO',"Receive new unchecked transaction.")
     return True
Example #4
0
 def blocked_transactions(self,txs):
     TransactionDB().write(txs)
     cprint('INFO',"Receive new blocked transactions.")
     return True
Example #5
0
 def new_block(self,block):
     cprint(__name__, block)
     BlockChainDB().insert(block)
     UnTransactionDB().clear()
     cprint('INFO',"Receive new block.")
     return True