2

Is a block number unique or do I need to save block hash to identify a block?
Does transaction hash include a block hash as input?

5
  • Block number is not unique you can have two or more blocks with the same number. The chain will eventually sentle on one of them, but for a period of time any of them can be valid, ie some nodes on the network will see one of them to be valid and others nodes can see a different block. Usually the period of time is brief, ie less than five blocks, but in theory can be arbitrarily long.

  • The hash of the current block is not available when a transaction is being executed. It is because the hash of the block depends on the final state after all the transaction has been executed.

2

The Block number is not inherently unique. The Block number is the measure of blocks starting from the block in question to the first block(the genesis block).

It might be simple to assume that the direction of counting the blocks is an unnecessary clarification but this gains some ambiguity when dealing with hard forks.

In the case of a blockchain with hard forks, if you were to count the blocks from the bottom up, you would reach two(or more!) different blocks based on which path of the fork you chose to track and how many total forks there were.

For the second part of the question, no the transaction has does not include the block hash for reasons stated by the others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.