Exemplo n.º 1
0
	def gen_next_block(self, public_key, transactions):
		prev_block = self.chain[-1]
		index = prev_block.index + 1
		timestamp = datetime.datetime.now()
		data = transactions
		hashed_block = prev_block.gen_hashed_block()
		self.chain.append(Block(index, timestamp, data, hashed_block, public_key))
Exemplo n.º 2
0
    def generate_genesis(self):
        with open('genesis_data.json') as json_file:
            data = json.dumps(json.load(json_file))

        genesis_block = Block(
            0, str(time.time()), data,
            "Why are we still here? Just to suffer? Every night, I can feel my leg… and my arm… even my fingers. The body I’ve lost… the comrades I’ve lost… won’t stop hurting… It’s like they’re all still there. You feel it, too, don’t you?"
        )

        self.block_data.append(genesis_block)
Exemplo n.º 3
0
 def validate_block(self, block):
     last_block = self.block_data[-1]
     veri_block = Block(last_block.index + 1, block.timestamp, block.data,
                        last_block.curr_hash)
     return veri_block.curr_hash == block.curr_hash
Exemplo n.º 4
0
 def create_block(self, data):
     curr_block = self.block_data[-1]
     new_block = Block(curr_block.index + 1, str(time.time()), data,
                       curr_block.curr_hash)
     return new_block
Exemplo n.º 5
0
def gen_genesis_block():
	transaction = ["XX:XX:XX:XX:XX"]
	return Block(0, datetime.datetime.now(), transaction, "0", "0")