def run(self):

    if not ORACLE_ADDRESS:
      self.oracle_address = self.kv.get_by_section_key('config','ORACLE_ADDRESS')

      if self.oracle_address is None:
        new_addr = self.btc.server.getnewaddress()
        self.oracle_address = new_addr
        logging.error("created a new address: '%s'" % new_addr)
        self.kv.store('config','ORACLE_ADDRESS',new_addr)
    else:
      self.oracle_address = ORACLE_ADDRESS

    logging.info("my fee: %r" % ORACLE_FEE)
    logging.info(self.oracle_address % "my bitcoin address is %s")
    logging.info( "my bitcoin pubkey: %r" % self.btc.validate_address(self.oracle_address)['pubkey'] )

    while True:
      # Proceed all requests
      requests = getMessages()
      requests = requests['results']

      requests = self.filter_requests(requests)

      for prev_request in requests:
        try:
          request = self.prepare_request(prev_request)
        except MissingOperationError:
          logging.info('message doesn\'t have operation field, invalid')
          logging.info(prev_request)
          continue
        except FastcastProtocolError:
          logging.info('message does not have all required fields')
          logging.info(prev_request)
          continue
        self.handle_request(request)


      task = self.task_queue.get_oldest_task()
      while task is not None:
        self.handle_task(task)
        self.task_queue.done(task)
        task = self.task_queue.get_oldest_task()

      try:
        new_block = self.get_new_block()
      except:
        new_block = None
        logging.exception('problematic block!')

      if new_block:
        handlers = op_handlers.iteritems()

        addresses_per_handler = {}
        all_addresses = set()

        # Every handler can wait for transactions occuring on some addresses
        for name, handler in handlers:
          addresses = handler(self).get_observed_addresses()
          addresses_per_handler[name] = addresses
          for address in addresses:
            all_addresses.add(address)

        transactions = self.btc.get_transactions_from_block(new_block, list(all_addresses))

        handlers = op_handlers.iteritems()
        for name, handler in handlers:
          addresses = addresses_per_handler[name]
          handler_transactions = []
          for address in addresses:
            if address in transactions:
              handler_transactions.extend(transactions[address])
          handler(self).handle_new_transactions(handler_transactions)

        KeyValue(self.db).update('blocks', 'last_block_number', {'last_block':new_block['height']})

      time.sleep(10)
dataset/ETHPy150Open orisi/orisi/src/oracle/oracle.py/Oracle.run/swapped operands of `%`