Add notes about safe uses of twox (#6082)

* Add notes about safe uses of twox

* Update frame/grandpa/src/lib.rs

Co-authored-by: Nikolay Volf <nikvolf@gmail.com>

* Update frame/elections/src/lib.rs

* Apply suggestions from code review

Co-authored-by: Gavin Wood <gavin@parity.io>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
Demi Obenour
2020-05-21 11:57:29 +00:00
committed by GitHub
parent a90c4232e3
commit ee6633e038
9 changed files with 41 additions and 0 deletions
+8
View File
@@ -442,16 +442,22 @@ pub struct BalanceLock<Balance> {
decl_storage! {
trait Store for Module<T: Trait> as GenericAsset {
/// Total issuance of a given asset.
///
/// TWOX-NOTE: `AssetId` is trusted.
pub TotalIssuance get(fn total_issuance) build(|config: &GenesisConfig<T>| {
let issuance = config.initial_balance * (config.endowed_accounts.len() as u32).into();
config.assets.iter().map(|id| (id.clone(), issuance)).collect::<Vec<_>>()
}): map hasher(twox_64_concat) T::AssetId => T::Balance;
/// The free balance of a given asset under an account.
///
/// TWOX-NOTE: `AssetId` is trusted.
pub FreeBalance:
double_map hasher(twox_64_concat) T::AssetId, hasher(blake2_128_concat) T::AccountId => T::Balance;
/// The reserved balance of a given asset under an account.
///
/// TWOX-NOTE: `AssetId` is trusted.
pub ReservedBalance:
double_map hasher(twox_64_concat) T::AssetId, hasher(blake2_128_concat) T::AccountId => T::Balance;
@@ -459,6 +465,8 @@ decl_storage! {
pub NextAssetId get(fn next_asset_id) config(): T::AssetId;
/// Permission options for a given asset.
///
/// TWOX-NOTE: `AssetId` is trusted.
pub Permissions get(fn get_permission):
map hasher(twox_64_concat) T::AssetId => PermissionVersions<T::AccountId>;