def get_test_bid(self): bidDict = { "model": "QmaRmbJtyfMDBfkDETTPAxKUUcSqZKXWwFKKoZ318nrPku", "objective": "Qmb3H3tHZ1QutcrLq7WEtQWbEWjA11aPqVmeatMSrmFXvE", "token": self.test_token, "cost": 0, "validator": '0x0000000000000000000000000000000000000000', "lighthouse": self.lighthouse_address, "lighthouseFee": 0, "deadline": 9999999 } bid = Offer() model_mh = Multihash() model_mh.multihash = bidDict['model'] objective_mh = Multihash() objective_mh.multihash = bidDict['objective'] bid.model = model_mh bid.objective = objective_mh bid.token = bidDict['token'] bid.cost = bidDict['cost'] bid.validator = bidDict['validator'] bid.lighthouse = bidDict['lighthouse'] bid.lighthouseFee = bidDict['lighthouseFee'] bid.deadline = bidDict['deadline'] return bid
def dict2bid(m): msg = Offer() 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.validator = Address() msg.validator.address = m['validator'] msg.lighthouse = Address() msg.lighthouse.address = m['lighthouse'] msg.lighthouseFee = UInt256() msg.lighthouseFee.uint256 = str(m['lighthouseFee']) 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
def dict2bid(m): msg = Offer() msg.model = m['model'] msg.objective = m['objective'] msg.token = m['token'] msg.cost = m['cost'] msg.validator = m['validator'] msg.lighthouse = m['lighthouse'] msg.lighthouseFee = m['lighthouseFee'] msg.deadline = m['deadline'] msg.nonce = unhexlify(m['nonce'].encode('utf-8')) msg.signature = unhexlify(m['signature'].encode('utf-8')) return msg
def getValidBid(): b = Offer() b.model = validBidDict['model'] b.objective = validBidDict['objective'] b.token = validBidDict['token'] b.cost = validBidDict['cost'] b.validator = validBidDict['validator'] b.lighthouse = validBidDict['lighthouse'] b.lighthouseFee = validBidDict['lighthouseFee'] b.deadline = validBidDict['deadline'] b.nonce = unhexlify(validBidDict['nonce'].encode('utf-8')) b.signature = unhexlify(validBidDict['signature'].encode('utf-8')) return b
def send_offer(self, demand: Demand, price: UInt256): offer = Offer() offer.model = Multihash(self.MODEL) offer.objective = demand.objective offer.token = Address(self.TOKEN) offer.cost = price offer.lighthouse = demand.lighthouse offer.validator = demand.validator offer.lighthouseFee = UInt256("0") offer.deadline = self.make_deadline() self.signing_offer.publish(offer) rospy.loginfo(offer)
def create_offer(fields: dict) -> Offer: rospy.loginfo("Creating an offer...") offer = Offer() offer.model = Multihash(fields["model"]["multihash"]) offer.objective = Multihash(fields["objective"]["multihash"]) offer.token = Address(fields["token"]["address"]) offer.cost = UInt256(fields["cost"]["uint256"]) offer.lighthouse = Address(fields["lighthouse"]["address"]) offer.validator = Address(fields["validator"]["address"]) offer.lighthouseFee = UInt256(fields["lighthouseFee"]["uint256"]) offer.deadline = UInt256(fields["deadline"]["uint256"]) rospy.loginfo(offer) return offer
def make_offer(self, demand: Demand): rospy.loginfo('Making offer...') offer = Offer() offer.model = Multihash(self.MODEL) offer.objective = demand.objective offer.token = demand.token offer.cost = demand.cost offer.lighthouse = demand.lighthouse offer.validator = demand.validator offer.lighthouseFee = UInt256("0") offer.deadline = UInt256() offer.deadline.uint256 = self.make_deadline() self.signing_offer.publish(offer) rospy.loginfo(offer)
def make_offer(self, incoming): rospy.loginfo('Making offer...') offer = Offer() offer.model = incoming.model offer.objective = incoming.objective offer.token = incoming.token offer.cost = incoming.cost offer.lighthouse = Address() offer.lighthouse.address = rospy.get_param('~lighthouse') offer.validator = incoming.validator offer.lighthouseFee = UInt256() offer.lighthouseFee.uint256 = '0' offer.deadline = UInt256() offer.deadline.uint256 = self.make_deadline() self.signing_offer.publish(offer) rospy.loginfo(offer)
def getValidBid(): b = Offer() b.model = Multihash() b.model.multihash = validBidDict['model'] b.objective = Multihash() b.objective.multihash = validBidDict['objective'] b.token = Address() b.token.address = validBidDict['token'] b.cost = UInt256() b.cost.uint256 = str(validBidDict['cost']) b.validator = Address() b.validator.address = validBidDict['validator'] b.lighthouse = Address() b.lighthouse.address = validBidDict['lighthouse'] b.lighthouseFee = UInt256() b.lighthouseFee.uint256 = str(validBidDict['lighthouseFee']) b.deadline = UInt256() b.deadline.uint256 = str(validBidDict['deadline']) b.sender = Address() b.sender.address = validAskDict['sender'] b.signature = unhexlify(validBidDict['signature'].encode('utf-8')) return b