Closed yashpawar closed 3 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.
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.