def prepare_bid(self, model, cost, deadline):
     msg = Bid()
     msg.model = model
     msg.token = self.token_address
     msg.cost = cost
     msg.count = 1
     msg.lighthouseFee = self.lighthouse_fee
     msg.salt = [0]
     msg.signature = [0]
     msg.deadline = deadline
     return msg
Beispiel #2
0
def dict2bid(m):
    msg = Bid()
    msg.model = m['model']
    msg.objective = m['objective']
    msg.token = m['token']
    msg.cost = m['cost']
    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
Beispiel #3
0
 def market_thread():
     for m in subscribe(self.ipfs_api, self.market_chan):
         if 'objective' in m:
             msg = Ask()
             msg.model     = m['model']
             msg.objective = m['objective']
             msg.token     = m['token']
             msg.cost      = m['cost']
             msg.count     = m['count']
             msg.validator    = m['validator']
             msg.validatorFee = m['validatorFee']
             msg.salt      = unhexlify(m['salt'].encode('utf-8'))
             msg.signature = unhexlify(m['signature'].encode('utf-8'))
             msg.deadline  = m['deadline']
             self.incoming_ask.publish(msg)
         else:
             msg = Bid()
             msg.model     = m['model']
             msg.token     = m['token']
             msg.cost      = m['cost']
             msg.count     = m['count']
             msg.lighthouseFee = m['lighthouseFee']
             msg.salt      = unhexlify(m['salt'].encode('utf-8'))
             msg.signature = unhexlify(m['signature'].encode('utf-8'))
             msg.deadline  = m['deadline']
             self.incoming_bid.publish(msg)
    def make_bid(self, incoming_ask):
        rospy.loginfo('Making bid...')

        bid = Bid()
        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(bid)
Beispiel #5
0
 def create_offer(m):
     rospy.loginfo('incoming ask')
     if m.model == self.model:
         offer = Bid()
         offer.model = self.model
         offer.objective = 'QmPGhwtN1ndML9iwDYPtMZeqNyQWQPaTRT981MQyZUZbwP'
         offer.token = '0xbD949595eE52346c225a19724084cE517B2cB735'
         offer.cost = 1
         offer.lighthouseFee = 0
         offer.deadline = m.deadline + 1000
         pub.publisher(offer)
 def dummy_producer(msg):
     rospy.loginfo('Received ASK with objective: {}'.format(msg.objective))
     bid = Bid()
     bid.model = msg.model
     bid.token = msg.token
     bid.cost  = msg.cost
     bid.count = msg.count
     bid.deadline = msg.deadline
     bids.publish(bid)
Beispiel #7
0
        def callback(m):
            rospy.loginfo("about to make a bid")

            block = self.web3.eth.getBlock('latest')
            deadline = block.number + 10000  # should be enough for a day

            msg = Bid()
            msg.model = self.model
            msg.token = self.token
            msg.cost = self.cost
            msg.count = self.count
            msg.lighthouseFee = 0
            msg.deadline = deadline

            self.signing_bid.publish(msg)
Beispiel #8
0
 def gen_linear_bids(self, a, k, market, lighthouseFee, validatorFee, price_range):
     '''
         Market bids linear generator, bid function is `Q = a + k * P`
     '''
     msg = Bid()
     msg.model = market
     msg.lighthouseFee = lighthouseFee
     msg.validatorFee  = validatorFee
     for P in range(1, price_range):
         count = a + k * P
         if count > 0 and count % 1 == 0:
             msg.cost  = P
             msg.count = int(count)
             self.signing_bid.publish(msg)
Beispiel #9
0
def callback(data):
    if data.model != "QmdFh1HPVe7H4LrDio899mxA7NindgxqiNUM9BNnBD7ryA":
        return

    signing_bid = rospy.Publisher('/liability/infochan/signing/bid',
                                  Bid,
                                  queue_size=128)
    # signing_task = rospy.Publisher('/task', String, queue_size=128)

    rospy.loginfo("Got an Ask:")
    msg = Bid()
    msg.model = data.model
    msg.objective = data.objective
    rospy.loginfo(data)
    msg.token = data.token
    msg.cost = data.cost
    msg.lighthouseFee = 0
    msg.deadline = data.deadline

    rospy.loginfo("Publishing...")
    signing_bid.publish(msg)
    rospy.loginfo("Published Bid")