def create_block(self):
        latest_index = self.data_manager.get_block_indexes(limit=1)[0]
        prev_block = self.data_manager.get_block(latest_index.block_id) if latest_index is not None else None

        block = Block()
        block.previous_hash = prev_block.id if prev_block is not None else BLOCK_GENESIS_HASH
        block.target_difficulty = self.get_next_difficulty(prev_block)
        block.time = int(time.time())

        # Placeholder information (for calculating packet size)
        block.merkle_root_hash = block.merkle_tree.build()
        block.sign(self.my_member)

        # Find dependencies
        contracts = []
        dependencies = defaultdict(list)
        for contract in self.incoming_contracts.itervalues():
            if contract.previous_hash:
                # Get the previous contract from memory or the database
                prev_contract = self.incoming_contracts.get(contract.previous_hash) or \
                                self.data_manager.get_contract(contract.previous_hash)
                on_blockchain = self.data_manager.contract_on_blockchain(prev_contract.id) if prev_contract else False
                # We need to wait until the previous contract is received and on the blockchain
                if not on_blockchain:
                    dependencies[contract.id].append(prev_contract)
                    continue
            contracts.append(contract)

        # Add contracts to block
        while contracts:
            contract = contracts.pop(0)
            block.contracts.append(contract)
            if self.get_block_packet_size(block) > MAX_PACKET_SIZE:
                block.contracts.pop()
                break

            if contract.id in dependencies:
                # Put dependencies at the front of the list, so they will be processed in the next iterations
                for index, dependency in enumerate(dependencies[contract.id]):
                    contracts.insert(index, dependency)

        # Calculate final merkle root hash + sign block
        block.merkle_root_hash = block.merkle_tree.build()
        block.sign(self.my_member)

        if self.check_block(block):
            self.logger.debug('Created block with target difficulty 0x%064x', block.target_difficulty)
            if self.process_block(block):
                self.logger.debug('Added created block with %s contract(s)', len(block.contracts))
                self.multicast_message(u'block', {'block': block.to_dict()})
                return block