def __init__(self, sequance_number, creator):
        # TODO: What to do in case of consensus fails will be added

        self.genesis_time = int(time.time())
        self.start_time = int(time.time())
        self.block_time = 7

        self.previous_hash = "0"
        self.sequance_number = sequance_number
        self.empty_block_number = 0

        blocks_hash = [self.previous_hash]
        SaveBlockshash(blocks_hash)

        accounts = [Account(creator, balance=1000000000)]
        save_accounts(accounts)

        self.pendingTransaction = []
        self.validating_list = []
        self.transaction_fee = 0.02
        self.default_transaction_fee = 0.02
        self.default_optimum_transaction_number = 10  # Each user settings by our hardware
        self.default_increase_of_fee = 0.01

        self.hash = None

        self.max_tx_number = 2
        self.minumum_transfer_amount = 1000

        self.raund_1_starting_time = None
        self.raund_1_time = 3
        self.raund_1 = False
        self.raund_1_node = False

        self.raund_2_starting_time = None
        self.raund_2_time = 3
        self.raund_2 = False
        self.raund_2_node = False

        self.consensus_timer = 0.50

        self.validated = False
        self.validated_time = None

        self.dowload_true_block = ""

        self.save_block()
        perpetualTimer(self.consensus_timer, consensus_trigger).start()
        apps_starter()
Exemple #2
0
    def get_full_chain(self, data, node):

        get_ok = False

        if not os.path.exists(TEMP_BLOCK_PATH):
            get_ok = True
        else:
            system = GetBlock()
            if node.id == system.dowload_true_block:
                get_ok = True

        if get_ok:

            if str(data["byte"]) == "end":

                os.rename(LOADING_BLOCK_PATH, TEMP_BLOCK_PATH)

                from blockchain.block.block_main import apps_starter
                from consensus.consensus_main import consensus_trigger
                from lib.perpetualtimer import perpetualTimer
                from app.app_main import apps_starter
                system = GetBlock()
                system.newly = True
                system.change_transaction_fee()

                system.exclude_validators = []
                dprint(system.sequance_number)
                perpetualTimer(system.consensus_timer,
                               consensus_trigger).start()
                apps_starter()
                system.save_block()

            else:
                file = open(LOADING_BLOCK_PATH, "ab")

                file.write((data["byte"].encode(encoding='iso-8859-1')))
                file.close()