satwikkansal / python_blockchain_app

A fully functional blockchain application implemented in Python from scratch (with tutorial).
819 stars 471 forks source link

check_chain_validity() being redundant #29

Closed yashpawar closed 3 years ago

yashpawar commented 4 years ago

During consensus, we are checking the validity of chain. chain = response.json()['chain'] is used to get the chain. But during the registration process, we use create_chain_from_dump() function. Inside the function, we create new block without hash attribute and add that block to a dummy blockchain using add_block method, which itself performs all hash related checks. so if we use create_chain_from_dump to get the chain during the consensus step, check_chain_validity is redundant.

satwikkansal commented 4 years ago

I think both the functions have different objectives and context where they're used, so it makes sense to keep them separate. I agree with you there's a logical overlap, but considering this is a tutorial project, I'd prefer to make the tradeoff of using explicit functions with slight redundancy over having a concise code.