substrate icon indicating copy to clipboard operation
substrate copied to clipboard

rpc: Use the blocks pinning API for chainHead methods

Open lexnv opened this issue 3 years ago • 0 comments

This PR uses the new pinning API introduced by https://github.com/paritytech/substrate/pull/13157.

The backend is propagated to the subscription management, which internally calls pinning only once for a given block. An alternative to this approach would be holding the UnpinHandle structures that perform the unpinning on drop. I decided to implement the first option becausechainHead must also report all the blocks from memory and those blocks are not generated by notifications, therefore having a single uniform way of pinning across the chainHead methods.

To ensure proper testing the in-memory Backend is extended to describe the number of active pinned references for a given block. An in-memory Backend instance is used for testing the chainHead, therefore the children method of the in-memory Backend is extended to return an empty list.

lexnv avatar Jan 24 '23 17:01 lexnv