3

パレットが前のブロックにある基板チェーンのストレージにアクセスするにはどうすればよいですか?

例: storage_name::get(&key, &block_number);

可能です。ドキュメントはありますか? できません。この機能をリクエストできますか?

4

1 に答える 1

3

It is not possible to query the storage of older blocks from within the runtime, nor would it be a feature that really makes sens to include as you describe it.

Each block should only rely on the data available in that block, else you start to make larger assumptions about the clients you are working with and what data is actually available to them.

The solution is simple here, just store any data you need into your own storage item that persists from block to block. We do this for a number of storages where we need the info from previous blocks like the validator and nominator information in the staking pallet.

When you don't need that data anymore, you can clean it up.

Here is an example: https://github.com/paritytech/substrate/blob/master/frame/staking/src/lib.rs#L969

于 2020-11-15T01:27:53.733 に答える