Exemple #1
0
    def update_listings_index(self):

        # Store to marketplace listing index
        contract_index_key = hashlib.sha1('contracts-%s' %
                                          self.transport.guid).hexdigest()
        hashvalue = hashlib.new('ripemd160')
        hashvalue.update(contract_index_key)
        contract_index_key = hashvalue.hexdigest()

        # Calculate index of contracts
        contract_ids = self.db.selectEntries("contracts",
                                              "market_id = '%s'" %
                                              self.transport.market_id.replace("'", "''"))
        my_contracts = []
        for contract_id in contract_ids:
            my_contracts.append(contract_id['key'])

        self.log.debug('My Contracts: %s' % my_contracts)

        # Sign listing index for validation and tamper resistance
        data_string = str({'guid': self.transport.guid,
                           'contracts': my_contracts})
        signature = CryptoTransportLayer.makeCryptor(self.transport.settings['secret']).sign(data_string).encode('hex')

        value = {'signature': signature,
                 'data': {'guid': self.transport.guid,
                          'contracts': my_contracts}}

        # Pass off to thread to keep GUI snappy
        self.transport.dht.iterativeStore(self.transport,
                                            contract_index_key,
                                            value, self.transport.guid)
Exemple #2
0
    def update_listings_index(self):

        # Store to marketplace listing index
        contract_index_key = hashlib.sha1('contracts-%s' %
                                          self._transport._guid).hexdigest()
        hashvalue = hashlib.new('ripemd160')
        hashvalue.update(contract_index_key)
        contract_index_key = hashvalue.hexdigest()

        # Calculate index of contracts
        contract_ids = self._db.selectEntries(
            "contracts", "market_id = '%s'" % self._transport._market_id)
        my_contracts = []
        for contract_id in contract_ids:
            my_contracts.append(contract_id['key'])

        self._log.debug('My Contracts: %s' % my_contracts)

        # Sign listing index for validation and tamper resistance
        data_string = str({
            'guid': self._transport._guid,
            'contracts': my_contracts
        })
        signature = CryptoTransportLayer.makeCryptor(
            self._transport.settings['secret']).sign(data_string).encode('hex')

        value = {
            'signature': signature,
            'data': {
                'guid': self._transport._guid,
                'contracts': my_contracts
            }
        }

        # Pass off to thread to keep GUI snappy
        self._transport._dht.iterativeStore(self._transport,
                                            contract_index_key, value,
                                            self._transport._guid)