Exemple #1
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
Exemple #2
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
Exemple #3
0
def make_demand(objective: str, cost: int) -> Demand:
    rospy.loginfo('Making demand...')

    demand = Demand()
    demand.model = Multihash(MODEL)
    demand.objective = Multihash(objective)
    demand.token = Address(TOKEN)
    demand.cost = UInt256(str(cost))
    demand.lighthouse = Address(LIGHTHOUSE)
    demand.validator = Address(VALIDATOR)
    demand.validatorFee = UInt256('0')
    demand.deadline = UInt256()
    demand.deadline.uint256 = make_deadline()
    demand.nonce = UInt256('0')

    rospy.loginfo(demand)
    return demand
Exemple #4
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.nonce = UInt256()
    a.nonce.uint256 = str(validAskDict['nonce'])
    a.signature = unhexlify(validAskDict['signature'].encode('utf-8'))
    return a