Users need to submit a chainHead_unstable_unpin for each block when they are no longer interested in performing operations on that block.
ChainHead will generate the following events in order:
NewBlock { hash: 0x1 }
BestBlock { hash: 0x1 }
Finalized { hashes: [0x1], pruned_hashes: [...] }
The RPC spec suggests that users are encouraged to call the unpin method either at Finalized event or when they are no longer interested in that block.
Currently, there is nothing stopping the user from calling unpin after the NewBlock and before the BestBlock arrives.
From the substrate perspective, the blocks are pinned on the received event if it wasn't pinned already.
This could lead to the block being unpinned after NewBlock and pin again at BestBlock.
However, if we allow users to unpin only block hashes reported by the finalized event (either finalized blocks or pruned blocks) we could avoid the pinning race; and it would be clear for users when to call the unpin.
Suggestion:
chainHead_unstable_unpin - called only for hashes reported by the Finalized event
chainHead_unstable_unpin - since the finalized event contains multiple hashes, extend this method to receive an array of hashes too
What do you think?
Users need to submit a chainHead_unstable_unpin for each block when they are no longer interested in performing operations on that block.
ChainHead will generate the following events in order:
NewBlock { hash: 0x1 }BestBlock { hash: 0x1 }Finalized { hashes: [0x1], pruned_hashes: [...] }The RPC spec suggests that users are encouraged to call the
unpinmethod either atFinalizedevent or when they are no longer interested in that block.Currently, there is nothing stopping the user from calling
unpinafter theNewBlockand before theBestBlockarrives.From the substrate perspective, the blocks are pinned on the received event if it wasn't pinned already.
This could lead to the block being unpinned after
NewBlockand pin again atBestBlock.However, if we allow users to unpin only block hashes reported by the finalized event (either finalized blocks or pruned blocks) we could avoid the pinning race; and it would be clear for users when to call the
unpin.Suggestion:
chainHead_unstable_unpin- called only for hashes reported by theFinalizedeventchainHead_unstable_unpin- since the finalized event contains multiple hashes, extend this method to receive an array of hashes tooWhat do you think?