<commit_before>import logging
import Queue

from dispatch import receiver

from common import StoppableLoopThread
from trie import rlp_hash, rlp_hash_hex
import signals

logger = logging.getLogger(__name__)


class ChainManager(StoppableLoopThread):

    """
    Manages the chain and requests to it.
    """

    def __init__(self):
        super(ChainManager, self).__init__()
        self.transactions = set()
        self.dummy_blockchain = dict()  # hash > block
        self.request_queue = Queue.Queue()

    def configure(self, config):
        self.config = config

    def bootstrap_blockchain(self):
        # genesis block
        # http://etherchain.org/#/block/
        # ab6b9a5613970faa771b12d449b2e9bb925ab7a369f0a4b86b286e9d540099cf
        if len(self.dummy_blockchain):
            return
        genesis_H = 'ab6b9a5613970faa771b12d449b2e9bb925ab7a369f'\
            '0a4b86b286e9d540099cf'.decode('hex')

    def loop_body(self):
        self.process_request_queue()
        self.mine()

    def mine(self):
        "in the meanwhile mine a bit, not efficient though"
        pass

    def process_request_queue(self):
        try:
            cmd, data = self.request_queue.get(block=True, timeout=0.1)
        except Queue.Empty:
            return

        logger.debug('%r received %s datalen:%d' %
                     (self, cmd, len(data or [])))
        if cmd == "add_blocks":
            logger.debug("add_blocks in queue seen")
            self.recv_blocks(data)
        elif cmd == "add_transactions":
            tx_list = data[0]
            for tx in tx_list:
                self.transactions.add(tx)
        elif cmd == "request_blocks":
            pass
        elif cmd == 'request_transactions':
            peer_id = data[0]
            signals.transactions_data_ready(self.transactions, peer_id)
        else:
            raise Exception('unknown command:%s' % cmd)<commit_msg>remove queue<commit_after>import logging
import time
from dispatch import receiver

from common import StoppableLoopThread
from trie import rlp_hash, rlp_hash_hex
import signals

logger = logging.getLogger(__name__)


class ChainManager(StoppableLoopThread):

    """
    Manages the chain and requests to it.
    """

    def __init__(self):
        super(ChainManager, self).__init__()
        self.transactions = set()
        self.dummy_blockchain = dict()  # hash > block

    def configure(self, config):
        self.config = config

    def bootstrap_blockchain(self):
        # genesis block
        # http://etherchain.org/#/block/
        # ab6b9a5613970faa771b12d449b2e9bb925ab7a369f0a4b86b286e9d540099cf
        if len(self.dummy_blockchain):
            return
        genesis_H = 'ab6b9a5613970faa771b12d449b2e9bb925ab7a369f'\
            '0a4b86b286e9d540099cf'.decode('hex')

    def loop_body(self):
        self.mine()
        time.sleep(.1)

    def mine(self):
        "in the meanwhile mine a bit, not efficient though"
        pass
{'fraction_non_alphanumeric': 0.08941176470588236, 'fraction_numerical': 0.05546218487394958, 'mean_word_length': 2.456445993031359, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '90542', 'n_tokens_mistral': 1023, 'n_tokens_neox': 921, 'n_words': 200}