<commit_before>class Blockchain():
    def __init__(self):
        self.blocks = []
        self._generate_genesis()

    def _generate_genesis(self):
        genesis = Block()
        genesis.previous_hash = 0
        genesis.id = 0
        genesis.data = {'info': 'ilk block'}
        genesis.calculate_hash()
        self.blocks.append(genesis)

    def add_block(self, block):
        blocks_len = len(self.blocks)
        block.id = blocks_len
        block.previous_hash = self.blocks[blocks_len - 1].hash
        block.calculate_hash()
        self.blocks.append(block)

    def validate(self):
        blocks_len = len(self.blocks)
        if blocks_len == 0 or blocks_len == 1:
            return True
        for i in range(1, blocks_len):
            if self.blocks[i].previous_hash != self.blocks[i - 1].hash:
                return False

        return True


import hashlib as hasher


class Block():
    def __init__(self, data=None):
        self.id = None
        self.previous_hash = None
        self.data = data
        self.hash = None

    def calculate_hash(self):
        sha = hasher.sha256()
        id_enc = str(self.id).encode('utf-8')
        data_enc = str(self.data).encode('utf-8')
        prv_hash_enc = str(self.previous_hash).encode('utf-8')
        sha.update(id_enc + data_enc + prv_hash_enc)
        self.hash = sha.hexdigest()


class PendingBlock():
    def __init__(self):<commit_msg>refactoring<commit_after>import hashlib as hasher


class Blockchain:
    def __init__(self):
        self.blocks = []
        self._generate_genesis()

    def _generate_genesis(self):
        genesis = Block()
        genesis.previous_hash = 0
        genesis.id = 0
        genesis.data = {'info': 'ilk block'}
        genesis.calculate_hash()
        self.blocks.append(genesis)

    def add_block(self, block):
        blocks_len = len(self.blocks)
        block.id = blocks_len
        block.previous_hash = self.blocks[blocks_len - 1].hash
        block.calculate_hash()
        self.blocks.append(block)

    def validate(self):
        blocks_len = len(self.blocks)
        if blocks_len == 0 or blocks_len == 1:
            return True
        for i in range(1, blocks_len):
            if self.blocks[i].previous_hash != self.blocks[i - 1].hash:
                return False

        return True


class Block:
    def __init__(self, data=None):
        self.id = None
        self.previous_hash = None
        self.data = data
        self.hash = None

    def calculate_hash(self):
        sha = hasher.sha256()
        id_enc = str(self.id).encode('utf-8')
        data_enc = str(self.data).encode('utf-8')
        prv_hash_enc = str(self.previous_hash).encode('utf-8')
        sha.update(id_enc + data_enc + prv_hash_enc)
        self.hash = sha.hexdigest()


class PendingBlock:
    def __init__(self):
{'fraction_non_alphanumeric': 0.11251758087201125, 'fraction_numerical': 0.009142053445850914, 'mean_word_length': 2.1367144432194047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3705115', 'n_tokens_mistral': 915, 'n_tokens_neox': 864, 'n_words': 185}