当前位置: 首页>>代码示例>>Python>>正文


Python tools.unpackage函数代码示例

本文整理汇总了Python中tools.unpackage函数的典型用法代码示例。如果您正苦于以下问题:Python unpackage函数的具体用法?Python unpackage怎么用?Python unpackage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了unpackage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: genesis

def genesis(pubkey):
    out = {'version': custom.version,
           'length': 0,
           'time': time.time(),
           'txs': [make_mint(pubkey)]}
    out = tools.unpackage(tools.package(out))
    return out
开发者ID:coinami,项目名称:coinami-pro,代码行数:7,代码来源:miner.py

示例2: genesis

 def genesis(pubkey, DB):
     out={'version':custom.version,
          'length':0,
          'time':time.time(),
          'target':blockchain.target(DB),
          'txs':[make_mint(pubkey, DB)]}
     out=tools.unpackage(tools.package(out))
     return out
开发者ID:aneilbaboo,项目名称:basiccoin,代码行数:8,代码来源:consensus.py

示例3: db_get

def db_get (n, DB): 
    n=str(n)
    if len(n)==130: n=tools.pub2addr(n)
    try:
        a=DB['db'].Get(n)
    except:
        error('here')
    return tools.unpackage(a)
开发者ID:Fangang,项目名称:basiccoin,代码行数:8,代码来源:blockchain.py

示例4: db_get

def db_get(n, DB):
    n = str(n)
    try:
        return tools.unpackage(DB['db'].Get(n))
    except:
        db_put(n, {'count': 0, 'amount': 0}, DB)  # Everyone defaults with
        # having zero money, and having broadcast zero transcations.
        return db_get(n, DB)
开发者ID:tubaman,项目名称:basiccoin,代码行数:8,代码来源:blockchain.py

示例5: make_block

 def make_block(prev_block, txs, pubkey, DB):
     leng=int(prev_block['length'])+1
     out={'version':custom.version,
          'txs':txs+[make_mint(pubkey, DB)],
          'length':leng,
          'time':time.time(),
          'target':blockchain.target(DB, leng),
          'prevHash':tools.det_hash(prev_block)}
     out=tools.unpackage(tools.package(out))
     return out
开发者ID:aneilbaboo,项目名称:basiccoin,代码行数:10,代码来源:consensus.py

示例6: db_get

def db_get(n, DB): 
    n=str(n)
    if len(n)==130: 
        n=tools.pub2addr(n)
        try:
            a=DB['db'].Get(n)
        except:
            db_put(n, {'count':0, 'amount':0}, DB)#everyone defaults with having zero money, and having broadcast zero transcations.
            return db_get(n, DB)
    return tools.unpackage(DB['db'].Get(n))
开发者ID:cinquemb,项目名称:basiccoin,代码行数:10,代码来源:blockchain.py

示例7: make_block

def make_block(prev_block, txs, pubkey):
    leng = int(prev_block['length']) + 1

    out = {'version': custom.version,
           'txs': txs,  # dont forget to add coinbase transaction ;)
           'length': leng,
           'time': time.time(),
           'prevHash': tools.det_hash(prev_block)}
    out = tools.unpackage(tools.package(out))
    return out
开发者ID:coinami,项目名称:coinami-pro,代码行数:10,代码来源:miner.py

示例8: genesis

def genesis(pubkey, DB):
    target_ = target.target()
    out = {'version': custom.version,
           'length': 0,
           'time': time.time(),
           'target': target_,
           'diffLength': blockchain.hexInvert(target_),
           'txs': [make_mint(pubkey, DB)]}
    out = tools.unpackage(tools.package(out))
    return out
开发者ID:AltCoinsLand,项目名称:basiccoin,代码行数:10,代码来源:miner.py

示例9: genesis

 def genesis(pubkey, DB):
     target = blockchain.target(DB)
     out = {'version': custom.version,
            'length': 0,
            'time': time.time(),
            'target': target,
            'diffLength': blockchain.hexInvert(target),
            'txs': [make_mint(pubkey, DB)]}
     print('out: ' + str(out))
     out = tools.unpackage(tools.package(out))
     return out
开发者ID:ashumeow,项目名称:basiccoin,代码行数:11,代码来源:consensus.py

示例10: serve_forever

def serve_forever(message_handler_func, PORT, queue):
    server = socket.socket()
    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server.bind(("127.0.0.1", PORT))
    server.listen(100)
    while True:
        client, addr = server.accept()
        (ip, port) = addr
        data = client.recv(MAX_MESSAGE_SIZE)
        # we could insert security checks here
        data = tools.unpackage(data)
        client.send(tools.package(message_handler_func(data, queue)))
开发者ID:Noelkd,项目名称:basiccoin,代码行数:12,代码来源:networking.py

示例11: make_block

 def make_block(prev_block, txs, pubkey, DB):
     leng=int(prev_block['length'])+1
     target=blockchain.target(DB, leng)
     diffLength=blockchain.hexSum(prev_block['diffLength'], blockchain.hexInvert(target))
     out={'version':custom.version,
          'txs':txs+[make_mint(pubkey, DB)],
          'length':leng,
          'time':time.time(),
          'diffLength':diffLength,
          'target':target,
          'prevHash':tools.det_hash(prev_block)}
     out=tools.unpackage(tools.package(out))
     return out
开发者ID:Fangang,项目名称:basiccoin,代码行数:13,代码来源:consensus.py

示例12: main

def main():
    info=sys.argv
    peer=['127.0.0.1', custom.basicd_port]
    p={'command':sys.argv[1:]}
    if len(p['command'])==0:
        p['command'].append(' ')
    response=networking.send_command(peer, p, 5)
    if tools.can_unpack(response):
        response=tools.unpackage(response)
    if type(response)==type({'a':1}):
        if 'error' in response:
            print('basiccoin is probably off. Use command: "python threads.py" to turn it on. (you may need to reboot it a couple times to get it working)')
    return(response)
开发者ID:cartercar,项目名称:basiccoin,代码行数:13,代码来源:basicd.py

示例13: create_sign_tx

def create_sign_tx():
    on_block=tools.local_get('length')+1
    if on_block==0:
        time.sleep(1)
        return{'error':'not ready'}
    r=tools.det_random(on_block)
    jackpots=[]
    address=tools.local_get('address')
    l=max(-1, on_block-1-(custom.long_time*2-custom.medium_time))
    election_block=tools.db_get(l+1)
    proof=tools.local_get('balance_proofs'+str(l))
    if 'root_hash' not in election_block:
        return({'error':'database changed'})
    a=tools.db_verify(election_block['root_hash'], address, proof)
    if a==False:
        #tools.log('election block: ' +str(election_block))
        #tools.log('proof: ' +str(proof))
        return({'error':'not valid proof'})
    old_balance=a['amount']
    M=custom.all_money
    for j in range(custom.jackpot_nonces):
        if tools.winner(old_balance, M, r, address, j):
            jackpots.append(j)
    if len(jackpots)>0:
        tx={'on_block':on_block, 'jackpots':jackpots, 'type':'sign', 'amount':M/3000/3}
        tx['B']=old_balance
        tx['proof']=proof
        if proof=='empty':
            time.sleep(1)
            return {'error':'not ready'}
        secrets=tools.local_get('secrets')
        if str(on_block) in secrets:
            secret=secrets[str(on_block)]
        else:
            secret=tools.unpackage(tools.package({'salt':str(random.random())+str(random.random()), 'entropy':random.randint(0,1)}))
            secrets[str(on_block)]=secret
            tools.local_put('secrets', secrets)
        tx['secret_hash']=tools.det_hash(secret)
        if on_block>0:
            block=tools.db_get(on_block-1)
            if 'amount' in block and block['amount']==0:
                return({'error':'database changed'})
            #tools.log('on_block: ' +str(a))
            tx['prev']=block['block_hash']
    else:
        tx= {'error':'no jackpots'}
    return tx
开发者ID:BumblebeeBat,项目名称:FlyingFox,代码行数:47,代码来源:auto_signer.py

示例14: buy_block

def buy_block(DB, args):
    gap=1#this should be an argument. 
    #we should also let the user delete as many blocks first as they want, to build a fork from a point in history.
    length=tools.local_get('length')
    prev_block=tools.db_get(length)
    txs=tools.local_get('txs')
    privkey=tools.local_get('privkey')
    height=tools.local_get('height')
    block=default_block(length+1, height+gap, txs+[sign(mint_tx(gap), privkey)])
    to_hash=''
    if length>-1: to_hash={'prev_hash':prev_block['block_hash'], 'txs':block['txs']}
    block['block_hash']=tools.det_hash(to_hash)
    block['root_hash']=tools.db_root()
    block=sign(block, privkey)
    block = tools.unpackage(tools.package(block))
    DB['suggested_blocks'].put(block)
    return block
开发者ID:appcoreopc,项目名称:slasher,代码行数:17,代码来源:api.py

示例15: connect

def connect(msg, host, port):
    if len(msg) < 1 or len(msg) > MAX_MESSAGE_SIZE:
        print("wrong sized message")
        return
    s = socket.socket()
    try:
        s.settimeout(2)
        s.connect((str(host), int(port)))
        msg["version"] = custom.version
        s.send(tools.package(msg))
        response = s.recv(MAX_MESSAGE_SIZE)
        # print(response)
        return tools.unpackage(response)
    except Exception as e:
        # print('THE ERROR WAS: ' +str(e))
        # print('disconnect')
        return {"error": "error"}
开发者ID:Noelkd,项目名称:basiccoin,代码行数:17,代码来源:networking.py


注:本文中的tools.unpackage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。