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
示例#2
0
def dict2ask(m):
    msg = Demand()
    msg.model = m['model']
    msg.objective = m['objective']
    msg.token = m['token']
    msg.cost = m['cost']
    msg.lighthouse = m['lighthouse']
    msg.validator = m['validator']
    msg.validatorFee = m['validatorFee']
    msg.deadline = m['deadline']
    msg.nonce = unhexlify(m['nonce'].encode('utf-8'))
    msg.signature = unhexlify(m['signature'].encode('utf-8'))
    return msg
示例#3
0
def getValidAsk():
    a = Demand()
    a.model = validAskDict['model']
    a.objective = validAskDict['objective']
    a.token = validAskDict['token']
    a.cost = validAskDict['cost']
    a.lighthouse = validAskDict['lighthouse']
    a.validator = validAskDict['validator']
    a.validatorFee = validAskDict['validatorFee']
    a.deadline = validAskDict['deadline']
    a.nonce = unhexlify(validAskDict['nonce'].encode('utf-8'))
    a.signature = unhexlify(validAskDict['signature'].encode('utf-8'))
    return a
def dict2demand(m):
    msg = Demand()

    msg.model.multihash = m['model']
    msg.objective.multihash = m['objective']
    msg.token.address = m['token']
    msg.cost.uint256 = str(m['cost'])
    msg.lighthouse.address = m['lighthouse']
    msg.validator.address = m['validator']
    msg.validatorFee.uint256 = str(m['validatorFee'])
    msg.deadline.uint256 = str(m['deadline'])
    msg.sender.address = m['sender']
    msg.nonce.uint256 = str(m['nonce'])
    if m['signature']:
        msg.signature = unhexlify(m['signature'].encode('utf-8'))
    return msg
示例#5
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