0

When I call web3.eth.blockNumber from a specific full-node, where does it getting the last block?

I know that the full-block holds part of the chain which he gets from gossiping with other full-nodes.

My guess the node consistently holds a version of the blockchain and just checks the blocks head/last block, is that right?

How's that process works with light-client?

1 Answer 1

1

Full nodes are constantly syncing. When a miner mines a block, it transmits it to the network. When you call web3.eth.getBlockNumber() to a full node, it already knows what the latest block it knows about it, so it can tell you instantly.

Light nodes aren't any different here. The difference between light nodes and full nodes is that light nodes only care about getting the block headers. They still listen to all new blocks constantly and get their headers. Since the block number is in the header, asking a light node web3.eth.getBlockNumber() will still be instant, since the node knows the newest block it has.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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