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
Пример #2
0
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
Пример #3
0
 def make_bid(self, incoming_ask):
     rospy.loginfo('Making bid...')
     bid = Offer()
     bid.model = self.model
     bid.objective = incoming_ask.objective
     bid.token = self.token
     bid.cost = incoming_ask.cost
     bid.lighthouseFee = 0
     bid.deadline = self.web3.eth.getBlock('latest').number + self.bid_lifetime
     self.signing_bid_pub.publish(bid)
Пример #4
0
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
Пример #5
0
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
Пример #6
0
    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)
Пример #7
0
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
Пример #8
0
    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)
Пример #9
0
    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)
Пример #10
0
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