当一个值存储在 Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX) 时,在 Substrate 中意味着什么?
What does it mean in Substrate when a value is stored at Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX)?
来自文档:
pub struct StorageValue<Prefix, Value, QueryKind = OptionQuery, OnEmpty = GetDefault>(_);
A type that allow to store a value.
Each value is stored at:
Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX)
这里的“Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX)”是什么意思?
这是告诉你存储密钥是如何通过组合两个哈希来计算的。来自 docs:
To calculate the key for a simple Storage Value, take the TwoX 128
hash of the name of the pallet that contains the Storage Value and
append to it the TwoX 128 hash of the name of the Storage Value
itself.
例如
twox_128("Sudo") = "0x5c0d1176a568c1f92944340dbfed9e9c"
twox_128("Key") = "0x530ebca703c85910e7164cb7d1c9e47b"
twox_128("Sudo") + twox_128("Key") = "0x5c0d1176a568c1f92944340dbfed9e9c530ebca703c85910e7164cb7d1c9e47b"
来自文档:
pub struct StorageValue<Prefix, Value, QueryKind = OptionQuery, OnEmpty = GetDefault>(_);
A type that allow to store a value.
Each value is stored at:
Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX)
这里的“Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX)”是什么意思?
这是告诉你存储密钥是如何通过组合两个哈希来计算的。来自 docs:
To calculate the key for a simple Storage Value, take the TwoX 128 hash of the name of the pallet that contains the Storage Value and append to it the TwoX 128 hash of the name of the Storage Value itself.
例如
twox_128("Sudo") = "0x5c0d1176a568c1f92944340dbfed9e9c"
twox_128("Key") = "0x530ebca703c85910e7164cb7d1c9e47b"
twox_128("Sudo") + twox_128("Key") = "0x5c0d1176a568c1f92944340dbfed9e9c530ebca703c85910e7164cb7d1c9e47b"