def dict2ask(m):
    msg = Demand()

    msg.model = Multihash() 
    msg.model.multihash = m['model']

    msg.objective = Multihash()
    msg.objective.multihash = m['objective']

    msg.token = Address()
    msg.token.address = m['token']

    msg.cost = UInt256()
    msg.cost.uint256 = str(m['cost'])

    msg.lighthouse = Address()
    msg.lighthouse.address = m['lighthouse']
 
    msg.validator = Address()
    msg.validator.address = m['validator']

    msg.validatorFee = UInt256()
    msg.validatorFee.uint256 = str(m['validatorFee'])

    msg.deadline = UInt256()
    msg.deadline.uint256 = str(m['deadline'])

    msg.sender = Address()
    msg.sender.address = m['sender']

    msg.signature = unhexlify(m['signature'].encode('utf-8'))
    return msg
Beispiel #2
0
def getValidAsk():
    a = Demand()
    a.model = Multihash()
    a.model.multihash = validAskDict['model']
    a.objective = Multihash()
    a.objective.multihash = validAskDict['objective']
    a.token = Address()
    a.token.address = validAskDict['token']
    a.cost = UInt256()
    a.cost.uint256 = str(validAskDict['cost'])
    a.lighthouse = Address()
    a.lighthouse.address = validAskDict['lighthouse']
    a.validator = Address()
    a.validator.address = validAskDict['validator']
    a.validatorFee = UInt256()
    a.validatorFee.uint256 = str(validAskDict['validatorFee'])
    a.deadline = UInt256()
    a.deadline.uint256 = str(validAskDict['deadline'])
    a.sender = Address()
    a.sender.address = validAskDict['sender']
    a.signature = unhexlify(validAskDict['signature'].encode('utf-8'))
    return a