I know that a block in a chain has prev.hash and hash. The prev.hash is the previous block’s hash. The hash is the current block’s hash which is calculated based on nonce.

One block can also have up to 1MB data which could include hundreds of transactions. My question is when a new block is created and start getting transactions, it could take a few minutes to fill in 1MB data. How does the hash work in this progress? Does the hash need to be calculated for every transaction added in the block? so the hash value could be changed very frequently until the block finished?

New contributor
Joey Yi Zhao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Miners keep a pool of unconfirmed transactions (called “mempool”) which usually contains many more transactions that can fit in one block. When a new block is created, miners immediately remove that block’s transactions from the mempool and fill a candidate block with a selection of the remaining transactions (usually in a way that maximizes fee revenue). This can easily take less than a second, during which miners either do nothing, or (more often) try to mine an empty block (to have a small chance of getting at least the block subsidy).

As new transactions keep coming in, miners keep updating their candidate block, replacing lower-feerate transactions with more lucrative ones. This can happen frequently, perhaps every few seconds.


the hash value could be changed very frequently until the block finished?

Even if no new transactions were arriving and the set of transactions was unchanging, the hash value would be changing trillions of times each second as the miner searches for nonce values that produce a sufficiently small hash.

Hash value changing frequently during mining is normal

When a new block is created and transactions are added, the block’s header hash needs to be recalculated for each change. Miners continuously modify a field called the “nonce” to find a valid hash that meets the network’s requirements. Once a valid hash is found, the block is added to the blockchain. The process can take time, but the difficulty adjusts to maintain a consistent block creation rate.