mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 21:58:06 +00:00
Use optimized append and len storage methods in SRML. (#3071)
* expose len from codec to storage. * refactor runtime with len and append. * Undo example. * Remove imports. * Bump codec. * Optionify. * Make decode_len counscious. * Refactor. * Update srml/support/src/storage/hashed/generator.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update srml/support/src/storage/hashed/generator.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update srml/support/src/storage/hashed/generator.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update srml/support/src/storage/hashed/generator.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Fix merge. * fix some docs. * Add NoDefault trait. * Bump. * Final nits. * Update srml/support/src/traits.rs * new approach toward len. * re-create lock file. * Fix build errors and Option handling. * More test fix * Use default for append as well. * Fix runtime. * Add support for linked_map * More tweaks from review. * Fix style * Change api for none-values * Bump.
This commit is contained in:
committed by
Bastian Köcher
parent
99a7492dbf
commit
095c7de7ff
Generated
+81
-110
@@ -211,11 +211,6 @@ name = "bitmask"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitvec"
|
||||
version = "0.14.0"
|
||||
@@ -865,7 +860,7 @@ dependencies = [
|
||||
"hashmap_core 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -917,7 +912,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
name = "fork-tree"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1359,7 +1354,7 @@ name = "impl-codec"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2315,7 +2310,7 @@ dependencies = [
|
||||
"node-primitives 2.0.0",
|
||||
"node-rpc 2.0.0",
|
||||
"node-runtime 2.0.0",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -2359,7 +2354,7 @@ dependencies = [
|
||||
"node-primitives 2.0.0",
|
||||
"node-runtime 2.0.0",
|
||||
"node-testing 2.0.0",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
"srml-balances 2.0.0",
|
||||
@@ -2384,7 +2379,7 @@ dependencies = [
|
||||
name = "node-primitives"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -2407,7 +2402,7 @@ dependencies = [
|
||||
"node-primitives 2.0.0",
|
||||
"node-runtime 2.0.0",
|
||||
"node-testing 2.0.0",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"substrate-client 2.0.0",
|
||||
@@ -2435,7 +2430,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"node-primitives 2.0.0",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2485,7 +2480,7 @@ dependencies = [
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"node-template-runtime 2.0.0",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"substrate-basic-authorship 2.0.0",
|
||||
@@ -2510,7 +2505,7 @@ dependencies = [
|
||||
name = "node-template-runtime"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -2541,7 +2536,7 @@ dependencies = [
|
||||
"node-executor 2.0.0",
|
||||
"node-primitives 2.0.0",
|
||||
"node-runtime 2.0.0",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
"srml-balances 2.0.0",
|
||||
@@ -2707,16 +2702,6 @@ name = "parity-bytes"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d"
|
||||
|
||||
[[package]]
|
||||
name = "parity-codec"
|
||||
version = "4.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitvec 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parity-multiaddr"
|
||||
version = "0.5.0"
|
||||
@@ -2750,7 +2735,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parity-scale-codec"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2758,7 +2743,6 @@ dependencies = [
|
||||
"byte-slice-cast 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec-derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vecarray 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3316,7 +3300,7 @@ dependencies = [
|
||||
"error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3708,7 +3692,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3730,7 +3714,7 @@ dependencies = [
|
||||
"environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 2.0.0",
|
||||
"substrate-offchain 2.0.0",
|
||||
@@ -3747,7 +3731,7 @@ dependencies = [
|
||||
"integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3764,7 +3748,7 @@ name = "sr-sandbox"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 2.0.0",
|
||||
"substrate-primitives 2.0.0",
|
||||
@@ -3776,7 +3760,7 @@ dependencies = [
|
||||
name = "sr-staking-primitives"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
]
|
||||
@@ -3793,7 +3777,7 @@ name = "sr-version"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
@@ -3803,7 +3787,7 @@ dependencies = [
|
||||
name = "srml-assets"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -3818,7 +3802,7 @@ name = "srml-aura"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -3838,7 +3822,7 @@ dependencies = [
|
||||
name = "srml-authority-discovery"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -3855,7 +3839,7 @@ dependencies = [
|
||||
name = "srml-authorship"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
@@ -3871,7 +3855,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -3891,7 +3875,7 @@ dependencies = [
|
||||
name = "srml-balances"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -3908,7 +3892,7 @@ name = "srml-collective"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -3927,7 +3911,7 @@ dependencies = [
|
||||
"assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3948,7 +3932,7 @@ dependencies = [
|
||||
name = "srml-democracy"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -3965,7 +3949,7 @@ name = "srml-elections"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -3981,7 +3965,7 @@ dependencies = [
|
||||
name = "srml-example"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -3997,7 +3981,7 @@ name = "srml-executive"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4013,7 +3997,7 @@ dependencies = [
|
||||
name = "srml-finality-tracker"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4028,7 +4012,7 @@ dependencies = [
|
||||
name = "srml-generic-asset"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4042,7 +4026,7 @@ dependencies = [
|
||||
name = "srml-grandpa"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4060,7 +4044,7 @@ dependencies = [
|
||||
name = "srml-im-online"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4077,7 +4061,7 @@ dependencies = [
|
||||
name = "srml-indices"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -4094,7 +4078,7 @@ dependencies = [
|
||||
name = "srml-membership"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4108,7 +4092,7 @@ dependencies = [
|
||||
name = "srml-metadata"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 2.0.0",
|
||||
"substrate-primitives 2.0.0",
|
||||
@@ -4118,7 +4102,7 @@ dependencies = [
|
||||
name = "srml-offences"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4134,7 +4118,7 @@ dependencies = [
|
||||
name = "srml-scored-pool"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4150,7 +4134,7 @@ name = "srml-session"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -4169,7 +4153,7 @@ dependencies = [
|
||||
name = "srml-staking"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -4191,7 +4175,7 @@ dependencies = [
|
||||
name = "srml-sudo"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4208,7 +4192,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -4257,7 +4241,7 @@ dependencies = [
|
||||
name = "srml-support-test"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -4272,7 +4256,7 @@ name = "srml-system"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -4287,7 +4271,7 @@ dependencies = [
|
||||
name = "srml-timestamp"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4302,7 +4286,7 @@ dependencies = [
|
||||
name = "srml-treasury"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4394,7 +4378,7 @@ dependencies = [
|
||||
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"node-primitives 2.0.0",
|
||||
"node-runtime 2.0.0",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4419,7 +4403,7 @@ dependencies = [
|
||||
name = "substrate-application-crypto"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4432,7 +4416,7 @@ dependencies = [
|
||||
name = "substrate-authority-discovery-primitives"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
"substrate-client 2.0.0",
|
||||
@@ -4444,7 +4428,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"substrate-client 2.0.0",
|
||||
"substrate-consensus-common 2.0.0",
|
||||
@@ -4514,7 +4498,7 @@ dependencies = [
|
||||
"kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
|
||||
"kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-api-macros 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4543,7 +4527,7 @@ dependencies = [
|
||||
"kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
|
||||
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"substrate-client 2.0.0",
|
||||
@@ -4566,7 +4550,7 @@ dependencies = [
|
||||
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4595,7 +4579,7 @@ dependencies = [
|
||||
name = "substrate-consensus-aura-primitives"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
"substrate-application-crypto 2.0.0",
|
||||
@@ -4616,7 +4600,7 @@ dependencies = [
|
||||
"num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -4648,7 +4632,7 @@ dependencies = [
|
||||
name = "substrate-consensus-babe-primitives"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
@@ -4666,7 +4650,7 @@ dependencies = [
|
||||
"futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libp2p 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
@@ -4684,7 +4668,7 @@ dependencies = [
|
||||
"exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rhododendron 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -4707,7 +4691,7 @@ dependencies = [
|
||||
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"substrate-client 2.0.0",
|
||||
@@ -4742,7 +4726,7 @@ dependencies = [
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
@@ -4770,7 +4754,7 @@ dependencies = [
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -4797,7 +4781,7 @@ dependencies = [
|
||||
name = "substrate-finality-grandpa-primitives"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
@@ -4809,7 +4793,7 @@ dependencies = [
|
||||
name = "substrate-inherents"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"sr-std 2.0.0",
|
||||
@@ -4861,7 +4845,7 @@ dependencies = [
|
||||
"linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -4902,7 +4886,7 @@ dependencies = [
|
||||
"hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -4963,7 +4947,7 @@ dependencies = [
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -4995,7 +4979,7 @@ dependencies = [
|
||||
"jsonrpc-derive 13.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-pubsub 13.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -5061,7 +5045,7 @@ dependencies = [
|
||||
"node-primitives 2.0.0",
|
||||
"node-runtime 2.0.0",
|
||||
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -5126,7 +5110,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"substrate-primitives 2.0.0",
|
||||
]
|
||||
@@ -5139,7 +5123,7 @@ dependencies = [
|
||||
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"substrate-panic-handler 2.0.0",
|
||||
"substrate-primitives 2.0.0",
|
||||
@@ -5175,7 +5159,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"substrate-client 2.0.0",
|
||||
"substrate-client-db 2.0.0",
|
||||
@@ -5193,7 +5177,7 @@ dependencies = [
|
||||
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-io 2.0.0",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -5225,7 +5209,7 @@ dependencies = [
|
||||
name = "substrate-test-runtime-client"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"substrate-primitives 2.0.0",
|
||||
"substrate-test-client 2.0.0",
|
||||
@@ -5241,7 +5225,7 @@ dependencies = [
|
||||
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
@@ -5255,7 +5239,7 @@ version = "2.0.0"
|
||||
dependencies = [
|
||||
"derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"substrate-client 2.0.0",
|
||||
@@ -5274,7 +5258,7 @@ dependencies = [
|
||||
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-std 2.0.0",
|
||||
"substrate-primitives 2.0.0",
|
||||
"trie-bench 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -5675,7 +5659,7 @@ name = "transaction-factory"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sr-primitives 2.0.0",
|
||||
"substrate-cli 2.0.0",
|
||||
"substrate-client 2.0.0",
|
||||
@@ -5693,7 +5677,7 @@ dependencies = [
|
||||
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -5885,16 +5869,6 @@ name = "vec_map"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "vecarray"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vergen"
|
||||
version = "3.0.4"
|
||||
@@ -6287,7 +6261,6 @@ dependencies = [
|
||||
"checksum bindgen 0.47.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df683a55b54b41d5ea8ebfaebb5aa7e6b84e3f3006a78f010dadc9ca88469260"
|
||||
"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
|
||||
"checksum bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead"
|
||||
"checksum bitvec 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b67491e1cc6f37da6c4415cd743cb8d2e2c65388acc91ca3094a054cbf3cbd0c"
|
||||
"checksum bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9633b74910e1870f50f5af189b08487195cdb83c0e27a71d6f64d5e09dd0538b"
|
||||
"checksum blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91721a6330935673395a0607df4d49a9cb90ae12d259f1b3e0a3f6e1d486872e"
|
||||
"checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400"
|
||||
@@ -6515,10 +6488,9 @@ dependencies = [
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
|
||||
"checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "<none>"
|
||||
"checksum parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2900f06356edf90de66a2922db622b36178dca71e85625eae58d0d9cc6cff2ac"
|
||||
"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7"
|
||||
"checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3"
|
||||
"checksum parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "00fd14ff806ad82cea9a8f909bb116443d92efda7c9acd4502690af64741ad81"
|
||||
"checksum parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "65582b5c02128a4b0fa60fb3e070216e9c84be3e4a8f1b74bc37e15a25e58daf"
|
||||
"checksum parity-scale-codec-derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a81f3cd93ed368a8e41c4e79538e99ca6e8f536096de23e3a0bc3e782093ce28"
|
||||
"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
|
||||
"checksum parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2005637ccf93dbb60c85081ccaaf3f945f573da48dcc79f27f9646caa3ec1dc"
|
||||
@@ -6697,7 +6669,6 @@ dependencies = [
|
||||
"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde"
|
||||
"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95"
|
||||
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||
"checksum vecarray 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d68a73b7d7d950c6558b6009e9fba229fb67562bda9fd02198f614f4ecf83f"
|
||||
"checksum vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6aba5e34f93dc7051dfad05b98a18e9156f27e7b431fe1d2398cb6061c0a1dba"
|
||||
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
|
||||
@@ -80,7 +80,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
// implementation changes and behavior does not, then leave spec_version as
|
||||
// is and increment impl_version.
|
||||
spec_version: 153,
|
||||
impl_version: 153,
|
||||
impl_version: 154,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ use sr_primitives::traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin,
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
use codec::{Encode, Decode, Input, Output, Error};
|
||||
use srml_support::{
|
||||
decl_module, decl_storage, decl_event, ensure,
|
||||
StorageValue, StorageMap, Parameter, Dispatchable, EnumerableStorageMap,
|
||||
decl_module, decl_storage, decl_event, ensure, AppendableStorageMap, StorageValue, StorageMap,
|
||||
Parameter, Dispatchable, EnumerableStorageMap,
|
||||
traits::{
|
||||
Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier,
|
||||
OnFreeBalanceZero, Get
|
||||
Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier, Get,
|
||||
OnFreeBalanceZero
|
||||
}
|
||||
};
|
||||
use srml_support::dispatch::Result;
|
||||
@@ -377,9 +377,8 @@ decl_module! {
|
||||
PublicPropCount::put(index + 1);
|
||||
<DepositOf<T>>::insert(index, (value, vec![who.clone()]));
|
||||
|
||||
let mut props = Self::public_props();
|
||||
props.push((index, (*proposal).clone(), who));
|
||||
<PublicProps<T>>::put(props);
|
||||
let new_prop = (index, (*proposal).clone(), who);
|
||||
<PublicProps<T>>::append_or_put([new_prop].into_iter());
|
||||
|
||||
Self::deposit_event(RawEvent::Proposed(index, value));
|
||||
}
|
||||
@@ -788,7 +787,7 @@ impl<T: Trait> Module<T> {
|
||||
fn do_vote(who: T::AccountId, ref_index: ReferendumIndex, vote: Vote) -> Result {
|
||||
ensure!(Self::is_active_referendum(ref_index), "vote given for invalid referendum.");
|
||||
if !<VoteOf<T>>::exists(&(ref_index, who.clone())) {
|
||||
<VotersFor<T>>::mutate(ref_index, |voters| voters.push(who.clone()));
|
||||
<VotersFor<T>>::append_or_insert(ref_index, [who.clone()].into_iter());
|
||||
}
|
||||
<VoteOf<T>>::insert(&(ref_index, who), vote);
|
||||
Ok(())
|
||||
@@ -926,9 +925,9 @@ impl<T: Trait> Module<T> {
|
||||
if info.delay.is_zero() {
|
||||
Self::enact_proposal(info.proposal, index);
|
||||
} else {
|
||||
<DispatchQueue<T>>::mutate(
|
||||
<DispatchQueue<T>>::append_or_insert(
|
||||
now + info.delay,
|
||||
|q| q.push(Some((info.proposal, index)))
|
||||
[Some((info.proposal, index))].into_iter()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -28,7 +28,7 @@ use sr_primitives::traits::{Zero, One, StaticLookup, Bounded, Saturating};
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
use runtime_io::print;
|
||||
use srml_support::{
|
||||
StorageValue, StorageMap,
|
||||
StorageValue, StorageMap, AppendableStorageMap, DecodeLengthStorageMap,
|
||||
dispatch::Result, decl_storage, decl_event, ensure, decl_module,
|
||||
traits::{
|
||||
Currency, ExistenceRequirement, Get, LockableCurrency, LockIdentifier,
|
||||
@@ -714,15 +714,15 @@ impl<T: Trait> Module<T> {
|
||||
///
|
||||
/// The voter index must be provided as explained in [`voter_at`] function.
|
||||
fn do_set_approvals(who: T::AccountId, votes: Vec<bool>, index: VoteIndex, hint: SetIndex) -> Result {
|
||||
let candidates = Self::candidates();
|
||||
let candidates_len = <Self as Store>::Candidates::decode_len().unwrap_or(0_usize);
|
||||
|
||||
ensure!(!Self::presentation_active(), "no approval changes during presentation period");
|
||||
ensure!(index == Self::vote_index(), "incorrect vote index");
|
||||
ensure!(!candidates.is_empty(), "amount of candidates to receive approval votes should be non-zero");
|
||||
ensure!(!candidates_len.is_zero(), "amount of candidates to receive approval votes should be non-zero");
|
||||
// Prevent a vote from voters that provide a list of votes that exceeds the candidates length
|
||||
// since otherwise an attacker may be able to submit a very long list of `votes` that far exceeds
|
||||
// the amount of candidates and waste more computation than a reasonable voting bond would cover.
|
||||
ensure!(candidates.len() >= votes.len(), "amount of candidate votes cannot exceed amount of candidates");
|
||||
ensure!(candidates_len >= votes.len(), "amount of candidate votes cannot exceed amount of candidates");
|
||||
|
||||
// Amount to be locked up.
|
||||
let mut locked_balance = T::Currency::total_balance(&who);
|
||||
@@ -755,10 +755,10 @@ impl<T: Trait> Module<T> {
|
||||
CellStatus::Head | CellStatus::Occupied => {
|
||||
// Either occupied or out-of-range.
|
||||
let next = Self::next_nonfull_voter_set();
|
||||
let mut set = Self::voters(next);
|
||||
let set_len = <Voters<T>>::decode_len(next).unwrap_or(0_usize);
|
||||
// Caused a new set to be created. Pay for it.
|
||||
// This is the last potential error. Writes will begin afterwards.
|
||||
if set.is_empty() {
|
||||
if set_len == 0 {
|
||||
let imbalance = T::Currency::withdraw(
|
||||
&who,
|
||||
T::VotingFee::get(),
|
||||
@@ -769,8 +769,10 @@ impl<T: Trait> Module<T> {
|
||||
// NOTE: this is safe since the `withdraw()` will check this.
|
||||
locked_balance -= T::VotingFee::get();
|
||||
}
|
||||
Self::checked_push_voter(&mut set, who.clone(), next);
|
||||
<Voters<T>>::insert(next, set);
|
||||
if set_len + 1 == VOTER_SET_SIZE {
|
||||
NextVoterSet::put(next + 1);
|
||||
}
|
||||
<Voters<T>>::append_or_insert(next, [Some(who.clone())].into_iter())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -908,18 +910,6 @@ impl<T: Trait> Module<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn checked_push_voter(set: &mut Vec<Option<T::AccountId>>, who: T::AccountId, index: u32) {
|
||||
let len = set.len();
|
||||
|
||||
// Defensive only: this should never happen. Don't push since it will break more things.
|
||||
if len == VOTER_SET_SIZE { return; }
|
||||
|
||||
set.push(Some(who));
|
||||
if len + 1 == VOTER_SET_SIZE {
|
||||
NextVoterSet::put(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the set and vector index of a global voter index.
|
||||
///
|
||||
/// Note that this function does not take holes into account.
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = ["derive"] }
|
||||
srml-metadata = { path = "../metadata", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -43,6 +43,8 @@ pub(crate) struct Impls<'a, I: Iterator<Item=syn::Meta>> {
|
||||
pub instance_opts: &'a InstanceOpts,
|
||||
pub type_infos: DeclStorageTypeInfos<'a>,
|
||||
pub fielddefault: TokenStream2,
|
||||
pub default_delegator_ident: syn::Ident,
|
||||
pub default_delegator_return: TokenStream2,
|
||||
pub prefix: String,
|
||||
pub cratename: &'a syn::Ident,
|
||||
pub name: &'a syn::Ident,
|
||||
@@ -60,6 +62,8 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
instance_opts,
|
||||
type_infos,
|
||||
fielddefault,
|
||||
default_delegator_ident,
|
||||
default_delegator_return,
|
||||
prefix,
|
||||
name,
|
||||
attrs,
|
||||
@@ -116,6 +120,17 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
|
||||
// generator for value
|
||||
quote! {
|
||||
#visibility struct #default_delegator_ident<#struct_trait>(
|
||||
#scrate::rstd::marker::PhantomData<(#trait_and_instance)>
|
||||
) #where_clause;
|
||||
impl<#impl_trait> #scrate::traits::StorageDefault<#typ>
|
||||
for #default_delegator_ident<#trait_and_instance> #where_clause
|
||||
{
|
||||
fn default() -> Option<#typ> {
|
||||
#default_delegator_return
|
||||
}
|
||||
}
|
||||
|
||||
#( #[ #attrs ] )*
|
||||
#visibility struct #name<#struct_trait>(
|
||||
#scrate::rstd::marker::PhantomData<(#trait_and_instance)>
|
||||
@@ -125,6 +140,7 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
for #name<#trait_and_instance> #where_clause
|
||||
{
|
||||
type Query = #value_type;
|
||||
type Default = #default_delegator_ident<#trait_and_instance>;
|
||||
|
||||
/// Get the storage key.
|
||||
fn key() -> &'static [u8] {
|
||||
@@ -168,6 +184,8 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
instance_opts,
|
||||
type_infos,
|
||||
fielddefault,
|
||||
default_delegator_ident,
|
||||
default_delegator_return,
|
||||
prefix,
|
||||
name,
|
||||
attrs,
|
||||
@@ -230,6 +248,17 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
|
||||
// generator for map
|
||||
quote!{
|
||||
#visibility struct #default_delegator_ident<#struct_trait>(
|
||||
#scrate::rstd::marker::PhantomData<(#trait_and_instance)>
|
||||
) #where_clause;
|
||||
impl<#impl_trait> #scrate::traits::StorageDefault<#typ>
|
||||
for #default_delegator_ident<#trait_and_instance> #where_clause
|
||||
{
|
||||
fn default() -> Option<#typ> {
|
||||
#default_delegator_return
|
||||
}
|
||||
}
|
||||
|
||||
#( #[ #attrs ] )*
|
||||
#visibility struct #name<#struct_trait>(
|
||||
#scrate::rstd::marker::PhantomData<(#trait_and_instance)>
|
||||
@@ -239,8 +268,8 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
for #name<#trait_and_instance> #where_clause
|
||||
{
|
||||
type Query = #value_type;
|
||||
|
||||
type Hasher = #scrate::#hasher;
|
||||
type Default = #default_delegator_ident<#trait_and_instance>;
|
||||
|
||||
/// Get the prefix key in storage.
|
||||
fn prefix() -> &'static [u8] {
|
||||
@@ -283,6 +312,10 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
impl<#impl_trait> #scrate::storage::hashed::generator::AppendableStorageMap<#kty, #typ>
|
||||
for #name<#trait_and_instance> #where_clause
|
||||
{}
|
||||
|
||||
impl<#impl_trait> #scrate::storage::hashed::generator::DecodeLengthStorageMap<#kty, #typ>
|
||||
for #name<#trait_and_instance> #where_clause
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,6 +328,8 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
instance_opts,
|
||||
type_infos,
|
||||
fielddefault,
|
||||
default_delegator_ident,
|
||||
default_delegator_return,
|
||||
prefix,
|
||||
name,
|
||||
attrs,
|
||||
@@ -567,12 +602,23 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
|
||||
#structure
|
||||
|
||||
#visibility struct #default_delegator_ident<#struct_trait>(
|
||||
#scrate::rstd::marker::PhantomData<(#trait_and_instance)>
|
||||
) #where_clause;
|
||||
impl<#impl_trait> #scrate::traits::StorageDefault<#typ>
|
||||
for #default_delegator_ident<#trait_and_instance> #where_clause
|
||||
{
|
||||
fn default() -> Option<#typ> {
|
||||
#default_delegator_return
|
||||
}
|
||||
}
|
||||
|
||||
impl<#impl_trait> #scrate::storage::hashed::generator::StorageMap<#kty, #typ>
|
||||
for #name<#trait_and_instance> #where_clause
|
||||
{
|
||||
type Query = #value_type;
|
||||
|
||||
type Hasher = #scrate::#hasher;
|
||||
type Default = #default_delegator_ident<#trait_and_instance>;
|
||||
|
||||
/// Get the prefix key in storage.
|
||||
fn prefix() -> &'static [u8] {
|
||||
@@ -730,6 +776,10 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<#impl_trait> #scrate::storage::hashed::generator::DecodeLengthStorageMap<#kty, #typ>
|
||||
for #name<#trait_and_instance> #where_clause
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -762,10 +762,26 @@ fn decl_storage_items(
|
||||
} = sline;
|
||||
|
||||
let type_infos = get_type_infos(storage_type);
|
||||
let fielddefault = default_value.inner
|
||||
.as_ref()
|
||||
.map(|d| &d.expr)
|
||||
.map(|d| quote!( #d ))
|
||||
.unwrap_or_else(|| quote!{ Default::default() });
|
||||
let kind = type_infos.kind.clone();
|
||||
// Propagate doc attributes.
|
||||
let attrs = attrs.inner.iter().filter_map(|a| a.parse_meta().ok()).filter(|m| m.name() == "doc");
|
||||
|
||||
// create default value delegator
|
||||
let default_delegator_ident = Ident::new(
|
||||
&format!("{}{}", name.to_string(), "DefaultDelegator"),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let default_delegator_return = if !type_infos.is_option {
|
||||
quote! { Some(#fielddefault) }
|
||||
} else {
|
||||
quote! { #fielddefault }
|
||||
};
|
||||
|
||||
let i = impls::Impls {
|
||||
scrate,
|
||||
visibility,
|
||||
@@ -774,8 +790,9 @@ fn decl_storage_items(
|
||||
traittype,
|
||||
instance_opts,
|
||||
type_infos,
|
||||
fielddefault: default_value.inner.as_ref().map(|d| &d.expr).map(|d| quote!( #d ))
|
||||
.unwrap_or_else(|| quote!{ Default::default() }),
|
||||
fielddefault,
|
||||
default_delegator_ident,
|
||||
default_delegator_return,
|
||||
prefix: build_prefix(cratename, name),
|
||||
name,
|
||||
attrs,
|
||||
|
||||
@@ -62,7 +62,8 @@ mod double_map;
|
||||
pub mod traits;
|
||||
|
||||
pub use self::storage::{
|
||||
StorageValue, StorageMap, EnumerableStorageMap, StorageDoubleMap, AppendableStorageMap
|
||||
StorageValue, StorageMap, EnumerableStorageMap, StorageDoubleMap, AppendableStorageMap,
|
||||
DecodeLengthStorageMap,
|
||||
};
|
||||
pub use self::hashable::Hashable;
|
||||
pub use self::dispatch::{Parameter, Dispatchable, Callable, IsSubType};
|
||||
|
||||
@@ -14,12 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Abstract storage to use on HashedStorage trait
|
||||
//! Abstract storage to use on HashedStorage trait. Please refer to the
|
||||
//! [top level docs](../../index.html) for more detailed documentation about storage traits and functions.
|
||||
|
||||
use crate::codec::{self, Encode};
|
||||
use crate::rstd::prelude::{Vec, Box};
|
||||
use crate::rstd::{prelude::{Vec, Box}, iter::FromIterator};
|
||||
#[cfg(feature = "std")]
|
||||
use crate::storage::unhashed::generator::UnhashedStorage;
|
||||
use crate::traits::{StorageDefault, Len};
|
||||
use runtime_io::{twox_64, twox_128, blake2_128, twox_256, blake2_256};
|
||||
|
||||
pub trait StorageHasher: 'static {
|
||||
@@ -164,6 +166,9 @@ impl<H: StorageHasher> HashedStorage<H> for sr_primitives::StorageOverlay {
|
||||
pub trait StorageValue<T: codec::Codec> {
|
||||
/// The type that get/take returns.
|
||||
type Query;
|
||||
/// Something that can provide the default value of this storage type.
|
||||
type Default: StorageDefault<T>;
|
||||
|
||||
|
||||
/// Get the storage key.
|
||||
fn key() -> &'static [u8];
|
||||
@@ -202,24 +207,75 @@ pub trait StorageValue<T: codec::Codec> {
|
||||
/// Append the given items to the value in the storage.
|
||||
///
|
||||
/// `T` is required to implement `codec::EncodeAppend`.
|
||||
fn append<S: HashedStorage<Twox128>, I: codec::Encode>(
|
||||
items: &[I], storage: &mut S
|
||||
) -> Result<(), &'static str> where T: codec::EncodeAppend<Item=I> {
|
||||
fn append<'a, S, I, R>(
|
||||
items: R,
|
||||
storage: &mut S,
|
||||
) -> Result<(), &'static str> where
|
||||
S: HashedStorage<Twox128>,
|
||||
I: 'a + codec::Encode,
|
||||
T: codec::EncodeAppend<Item=I>,
|
||||
R: IntoIterator<Item=&'a I>,
|
||||
R::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
let new_val = <T as codec::EncodeAppend>::append(
|
||||
storage.get_raw(Self::key()).unwrap_or_default(),
|
||||
// if the key exists, directly append to it.
|
||||
storage.get_raw(Self::key()).unwrap_or_else(|| {
|
||||
// otherwise, try and read a proper __provided__ default.
|
||||
Self::Default::default().map(|v| v.encode())
|
||||
// or just use the Rust's `default()` value.
|
||||
.unwrap_or_default()
|
||||
}),
|
||||
items,
|
||||
).map_err(|_| "Could not append given item")?;
|
||||
storage.put_raw(Self::key(), &new_val);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Safely append the given items to the value in the storage. If a codec error occurs, then the
|
||||
/// old (presumably corrupt) value is replaced with the given `items`.
|
||||
///
|
||||
/// `T` is required to implement `codec::EncodeAppend`.
|
||||
fn append_or_put<'a, S, I, R>(
|
||||
items: R,
|
||||
storage: &mut S,
|
||||
) where
|
||||
S: HashedStorage<Twox128>,
|
||||
I: 'a + codec::Encode + Clone,
|
||||
T: codec::EncodeAppend<Item=I> + FromIterator<I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
Self::append(items.clone(), storage)
|
||||
.unwrap_or_else(|_| Self::put(&items.into_iter().cloned().collect(), storage));
|
||||
}
|
||||
|
||||
/// Read the length of the value in a fast way, without decoding the entire value.
|
||||
///
|
||||
/// `T` is required to implement `Codec::DecodeLength`.
|
||||
///
|
||||
/// Note that `0` is returned as the default value if no encoded value exists at the given key.
|
||||
/// Therefore, this function cannot be used as a sign of _existence_. use the `::exists()`
|
||||
/// function for this purpose.
|
||||
fn decode_len<S: HashedStorage<Twox128>>(storage: &mut S) -> Result<usize, &'static str>
|
||||
where T: codec::DecodeLength, T: Len
|
||||
{
|
||||
// attempt to get the length directly.
|
||||
if let Some(k) = storage.get_raw(Self::key()) {
|
||||
<T as codec::DecodeLength>::len(&k).map_err(|e| e.what())
|
||||
} else {
|
||||
Ok(Self::Default::default().map(|v| v.len()).unwrap_or(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A strongly-typed map in storage.
|
||||
pub trait StorageMap<K: codec::Codec, V: codec::Codec> {
|
||||
/// The type that get/take returns.
|
||||
type Query;
|
||||
|
||||
/// Hasher type
|
||||
type Hasher: StorageHasher;
|
||||
/// Something that can provide the default value of this storage type.
|
||||
type Default: StorageDefault<V>;
|
||||
|
||||
/// Get the prefix key in storage.
|
||||
fn prefix() -> &'static [u8];
|
||||
@@ -295,16 +351,69 @@ pub trait EnumerableStorageMap<K: codec::Codec, V: codec::Codec>: StorageMap<K,
|
||||
pub trait AppendableStorageMap<K: codec::Codec, V: codec::Codec>: StorageMap<K, V> {
|
||||
/// Append the given items to the value in the storage.
|
||||
///
|
||||
/// `T` is required to implement `codec::EncodeAppend`.
|
||||
fn append<S: HashedStorage<Self::Hasher>, I: codec::Encode>(
|
||||
key : &K, items: &[I], storage: &mut S
|
||||
) -> Result<(), &'static str> where V: codec::EncodeAppend<Item=I> {
|
||||
/// `V` is required to implement `codec::EncodeAppend`.
|
||||
fn append<'a, S, I, R>(
|
||||
key : &K,
|
||||
items: R,
|
||||
storage: &mut S,
|
||||
) -> Result<(), &'static str> where
|
||||
S: HashedStorage<Self::Hasher>,
|
||||
I: 'a + codec::Encode,
|
||||
V: codec::EncodeAppend<Item=I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
let k = Self::key_for(key);
|
||||
let new_val = <V as codec::EncodeAppend>::append(
|
||||
storage.get_raw(&k[..]).unwrap_or_default(),
|
||||
storage.get_raw(&k[..]).unwrap_or_else(|| {
|
||||
// otherwise, try and read a proper __provided__ default.
|
||||
Self::Default::default().map(|v| v.encode())
|
||||
// or just use the default value.
|
||||
.unwrap_or_default()
|
||||
}),
|
||||
items,
|
||||
).map_err(|_| "Could not append given item")?;
|
||||
storage.put_raw(&k[..], &new_val);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Safely append the given items to the value in the storage. If a codec error occurs, then the
|
||||
/// old (presumably corrupt) value is replaced with the given `items`.
|
||||
///
|
||||
/// `T` is required to implement `codec::EncodeAppend`.
|
||||
fn append_or_insert<'a, S, I, R>(
|
||||
key : &K,
|
||||
items: R,
|
||||
storage: &mut S,
|
||||
) where
|
||||
S: HashedStorage<Self::Hasher>,
|
||||
I: 'a + codec::Encode + Clone,
|
||||
V: codec::EncodeAppend<Item=I> + crate::rstd::iter::FromIterator<I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
Self::append(key, items.clone(), storage)
|
||||
.unwrap_or_else(|_| Self::insert(key, &items.into_iter().cloned().collect(), storage));
|
||||
}
|
||||
}
|
||||
|
||||
/// A storage map with a decodable length.
|
||||
pub trait DecodeLengthStorageMap<K: codec::Codec, V: codec::Codec>: StorageMap<K, V> {
|
||||
/// Read the length of the value in a fast way, without decoding the entire value.
|
||||
///
|
||||
/// `T` is required to implement `Codec::DecodeLength`.
|
||||
///
|
||||
/// Note that `0` is returned as the default value if no encoded value exists at the given key.
|
||||
/// Therefore, this function cannot be used as a sign of _existence_. use the `::exists()`
|
||||
/// function for this purpose.
|
||||
fn decode_len<S: HashedStorage<Self::Hasher>>(key: &K, storage: &mut S) -> Result<usize, &'static str>
|
||||
where V: codec::DecodeLength, V: Len
|
||||
{
|
||||
let k = Self::key_for(key);
|
||||
if let Some(v) = storage.get_raw(&k[..]) {
|
||||
<V as codec::DecodeLength>::len(&v).map_err(|e| e.what())
|
||||
} else {
|
||||
Ok(Self::Default::default().map(|v| v.len()).unwrap_or(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
//! Stuff to do with the runtime's storage.
|
||||
|
||||
use crate::rstd::prelude::*;
|
||||
use crate::rstd::borrow::Borrow;
|
||||
use crate::rstd::{borrow::Borrow, iter::FromIterator};
|
||||
use codec::{Codec, Encode, Decode, KeyedVec, EncodeAppend};
|
||||
use hashed::generator::{HashedStorage, StorageHasher};
|
||||
use unhashed::generator::UnhashedStorage;
|
||||
use crate::traits::{StorageDefault, Len};
|
||||
|
||||
#[macro_use]
|
||||
pub mod storage_items;
|
||||
@@ -107,6 +108,8 @@ impl UnhashedStorage for RuntimeStorage {
|
||||
pub trait StorageValue<T: Codec> {
|
||||
/// The type that get/take return.
|
||||
type Query;
|
||||
/// Something that can provide the default value of this storage type.
|
||||
type Default: StorageDefault<T>;
|
||||
|
||||
/// Get the storage key.
|
||||
fn key() -> &'static [u8];
|
||||
@@ -136,12 +139,39 @@ pub trait StorageValue<T: Codec> {
|
||||
/// Append the given item to the value in the storage.
|
||||
///
|
||||
/// `T` is required to implement `codec::EncodeAppend`.
|
||||
fn append<I: Encode>(items: &[I]) -> Result<(), &'static str>
|
||||
where T: EncodeAppend<Item=I>;
|
||||
fn append<'a, I, R>(items: R) -> Result<(), &'static str> where
|
||||
I: 'a + Encode,
|
||||
T: EncodeAppend<Item=I>,
|
||||
R: IntoIterator<Item=&'a I>,
|
||||
R::IntoIter: ExactSizeIterator;
|
||||
|
||||
/// Append the given items to the value in the storage.
|
||||
///
|
||||
/// `T` is required to implement `Codec::EncodeAppend`.
|
||||
///
|
||||
/// Upon any failure, it replaces `items` as the new value (assuming that the previous stored
|
||||
/// data is simply corrupt and no longer usable).
|
||||
///
|
||||
/// ### WARNING
|
||||
///
|
||||
/// use with care; if your use-case is not _exactly_ as what this function is doing,
|
||||
/// you should use append and sensibly handle failure within the runtime code if it happens.
|
||||
fn append_or_put<'a, I, R>(items: R) where
|
||||
I: 'a + Encode + Clone,
|
||||
T: EncodeAppend<Item=I> + FromIterator<I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator;
|
||||
|
||||
/// Read the length of the value in a fast way, without decoding the entire value.
|
||||
///
|
||||
/// `T` is required to implement `Codec::DecodeLength`.
|
||||
fn decode_len() -> Result<usize, &'static str>
|
||||
where T: codec::DecodeLength, T: Len;
|
||||
}
|
||||
|
||||
impl<T: Codec, U> StorageValue<T> for U where U: hashed::generator::StorageValue<T> {
|
||||
type Query = U::Query;
|
||||
type Default = U::Default;
|
||||
|
||||
fn key() -> &'static [u8] {
|
||||
<U as hashed::generator::StorageValue<T>>::key()
|
||||
@@ -167,17 +197,35 @@ impl<T: Codec, U> StorageValue<T> for U where U: hashed::generator::StorageValue
|
||||
fn take() -> Self::Query {
|
||||
U::take(&mut RuntimeStorage)
|
||||
}
|
||||
fn append<I: Encode>(items: &[I]) -> Result<(), &'static str>
|
||||
where T: EncodeAppend<Item=I>
|
||||
fn append<'a, I, R>(items: R) -> Result<(), &'static str> where
|
||||
I: 'a + Encode,
|
||||
T: EncodeAppend<Item=I>,
|
||||
R: IntoIterator<Item=&'a I>,
|
||||
R::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
U::append(items, &mut RuntimeStorage)
|
||||
}
|
||||
fn append_or_put<'a, I, R>(items: R) where
|
||||
I: 'a + Encode + Clone,
|
||||
T: EncodeAppend<Item=I> + FromIterator<I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
U::append_or_put(items, &mut RuntimeStorage)
|
||||
}
|
||||
fn decode_len() -> Result<usize, &'static str>
|
||||
where T: codec::DecodeLength, T: Len
|
||||
{
|
||||
U::decode_len(&mut RuntimeStorage)
|
||||
}
|
||||
}
|
||||
|
||||
/// A strongly-typed map in storage.
|
||||
pub trait StorageMap<K: Codec, V: Codec> {
|
||||
/// The type that get/take return.
|
||||
type Query;
|
||||
/// Something that can provide the default value of this storage type.
|
||||
type Default: StorageDefault<V>;
|
||||
|
||||
/// Get the prefix key in storage.
|
||||
fn prefix() -> &'static [u8];
|
||||
@@ -213,6 +261,7 @@ pub trait StorageMap<K: Codec, V: Codec> {
|
||||
|
||||
impl<K: Codec, V: Codec, U> StorageMap<K, V> for U where U: hashed::generator::StorageMap<K, V> {
|
||||
type Query = U::Query;
|
||||
type Default = U::Default;
|
||||
|
||||
fn prefix() -> &'static [u8] {
|
||||
<U as hashed::generator::StorageMap<K, V>>::prefix()
|
||||
@@ -260,18 +309,85 @@ pub trait AppendableStorageMap<K: Codec, V: Codec>: StorageMap<K, V> {
|
||||
/// Append the given item to the value in the storage.
|
||||
///
|
||||
/// `T` is required to implement `codec::EncodeAppend`.
|
||||
fn append<KeyArg: Borrow<K>, I: Encode>(key: KeyArg, items: &[I]) -> Result<(), &'static str>
|
||||
where V: EncodeAppend<Item=I>;
|
||||
fn append<'a, KeyArg, I, R>(
|
||||
key: KeyArg,
|
||||
items: R,
|
||||
) -> Result<(), &'static str> where
|
||||
KeyArg: Borrow<K>,
|
||||
I: 'a + codec::Encode,
|
||||
V: EncodeAppend<Item=I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator;
|
||||
|
||||
/// Append the given items to the value in the storage.
|
||||
///
|
||||
/// `T` is required to implement `codec::EncodeAppend`.
|
||||
///
|
||||
/// Upon any failure, it replaces `items` as the new value (assuming that the previous stored
|
||||
/// data is simply corrupt and no longer usable).
|
||||
///
|
||||
/// WARNING: use with care; if your use-case is not _exactly_ as what this function is doing,
|
||||
/// you should use append and sensibly handle failure within the runtime code if it happens.
|
||||
fn append_or_insert<'a, KeyArg, I, R>(
|
||||
key: KeyArg,
|
||||
items: R,
|
||||
) where
|
||||
KeyArg: Borrow<K>,
|
||||
I: 'a + codec::Encode + Clone,
|
||||
V: codec::EncodeAppend<Item=I> + FromIterator<I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator;
|
||||
}
|
||||
|
||||
impl<K: Codec, V: Codec, U> AppendableStorageMap<K, V> for U
|
||||
where U: hashed::generator::AppendableStorageMap<K, V>
|
||||
{
|
||||
fn append<KeyArg: Borrow<K>, I: Encode>(key: KeyArg, items: &[I]) -> Result<(), &'static str>
|
||||
where V: EncodeAppend<Item=I>
|
||||
fn append<'a, KeyArg, I, R>(
|
||||
key: KeyArg,
|
||||
items: R,
|
||||
) -> Result<(), &'static str> where
|
||||
KeyArg: Borrow<K>,
|
||||
I: 'a + codec::Encode,
|
||||
V: EncodeAppend<Item=I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
U::append(key.borrow(), items, &mut RuntimeStorage)
|
||||
}
|
||||
|
||||
fn append_or_insert<'a, KeyArg, I, R>(
|
||||
key: KeyArg,
|
||||
items: R,
|
||||
) where
|
||||
KeyArg: Borrow<K>,
|
||||
I: 'a + codec::Encode + Clone,
|
||||
V: codec::EncodeAppend<Item=I> + FromIterator<I>,
|
||||
R: IntoIterator<Item=&'a I> + Clone,
|
||||
R::IntoIter: ExactSizeIterator,
|
||||
{
|
||||
U::append_or_insert(key.borrow(), items, &mut RuntimeStorage)
|
||||
}
|
||||
}
|
||||
|
||||
/// A storage map with a decodable length.
|
||||
pub trait DecodeLengthStorageMap<K: Codec, V: Codec>: StorageMap<K, V> {
|
||||
/// Read the length of the value in a fast way, without decoding the entire value.
|
||||
///
|
||||
/// `T` is required to implement `Codec::DecodeLength`.
|
||||
///
|
||||
/// Has the same logic as [`StorageValue`](trait.StorageValue.html).
|
||||
fn decode_len<KeyArg: Borrow<K>>(key: KeyArg) -> Result<usize, &'static str>
|
||||
where V: codec::DecodeLength, V: Len;
|
||||
}
|
||||
|
||||
impl <K: Codec, V: Codec, U> DecodeLengthStorageMap<K, V> for U
|
||||
where U: hashed::generator::DecodeLengthStorageMap<K, V>
|
||||
{
|
||||
fn decode_len<KeyArg: Borrow<K>>(key: KeyArg) -> Result<usize, &'static str>
|
||||
where V: codec::DecodeLength, V: Len
|
||||
{
|
||||
U::decode_len(key.borrow(), &mut RuntimeStorage)
|
||||
}
|
||||
}
|
||||
|
||||
/// A storage map that can be enumerated.
|
||||
|
||||
@@ -172,6 +172,7 @@ macro_rules! __storage_items_internal {
|
||||
|
||||
impl $crate::storage::hashed::generator::StorageValue<$ty> for $name {
|
||||
type Query = $gettype;
|
||||
type Default = ();
|
||||
|
||||
/// Get the storage key.
|
||||
fn key() -> &'static [u8] {
|
||||
@@ -221,8 +222,8 @@ macro_rules! __storage_items_internal {
|
||||
|
||||
impl $crate::storage::hashed::generator::StorageMap<$kty, $ty> for $name {
|
||||
type Query = $gettype;
|
||||
|
||||
type Hasher = $crate::Blake2_256;
|
||||
type Default = ();
|
||||
|
||||
/// Get the prefix key in storage.
|
||||
fn prefix() -> &'static [u8] {
|
||||
@@ -795,18 +796,41 @@ mod test3 {
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code)]
|
||||
mod test_map_vec_append {
|
||||
mod test_append_and_len {
|
||||
use crate::storage::{AppendableStorageMap, DecodeLengthStorageMap, StorageMap, StorageValue};
|
||||
use runtime_io::{with_externalities, TestExternalities};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
type BlockNumber;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
struct NoDef(u32);
|
||||
|
||||
crate::decl_storage! {
|
||||
trait Store for Module<T: Trait> as Test {
|
||||
NoDefault: Option<NoDef>;
|
||||
|
||||
JustVec: Vec<u32>;
|
||||
JustVecWithDefault: Vec<u32> = vec![6, 9];
|
||||
OptionVec: Option<Vec<u32>>;
|
||||
OptionVecWithDefault: Option<Vec<u32>> = Some(vec![6, 9]);
|
||||
|
||||
MapVec: map u32 => Vec<u32>;
|
||||
MapVecWithDefault: map u32 => Vec<u32> = vec![6, 9];
|
||||
OptionMapVec: map u32 => Option<Vec<u32>>;
|
||||
OptionMapVecWithDefault: map u32 => Option<Vec<u32>> = Some(vec![6, 9]);
|
||||
|
||||
LinkedMapVec: linked_map u32 => Vec<u32>;
|
||||
LinkedMapVecWithDefault: linked_map u32 => Vec<u32> = vec![6, 9];
|
||||
OptionLinkedMapVec: linked_map u32 => Option<Vec<u32>>;
|
||||
OptionLinkedMapVecWithDefault: linked_map u32 => Option<Vec<u32>> = Some(vec![6, 9]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,20 +842,115 @@ mod test_map_vec_append {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_works() {
|
||||
use crate::storage::{AppendableStorageMap, StorageMap, StorageValue};
|
||||
use runtime_io::{with_externalities, TestExternalities};
|
||||
|
||||
fn default_for_option() {
|
||||
with_externalities(&mut TestExternalities::default(), || {
|
||||
let _ = MapVec::append(1, &[1, 2, 3]);
|
||||
let _ = MapVec::append(1, &[4, 5]);
|
||||
assert_eq!(OptionVecWithDefault::get(), Some(vec![6, 9]));
|
||||
assert_eq!(OptionVec::get(), None);
|
||||
assert_eq!(JustVec::get(), vec![]);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_works() {
|
||||
with_externalities(&mut TestExternalities::default(), || {
|
||||
let _ = MapVec::append(1, [1, 2, 3].iter());
|
||||
let _ = MapVec::append(1, [4, 5].iter());
|
||||
assert_eq!(MapVec::get(1), vec![1, 2, 3, 4, 5]);
|
||||
|
||||
let _ = JustVec::append(&[1, 2, 3]);
|
||||
let _ = JustVec::append(&[4, 5]);
|
||||
let _ = JustVec::append([1, 2, 3].iter());
|
||||
let _ = JustVec::append([4, 5].iter());
|
||||
assert_eq!(JustVec::get(), vec![1, 2, 3, 4, 5]);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_works_for_default() {
|
||||
with_externalities(&mut TestExternalities::default(), || {
|
||||
assert_eq!(JustVecWithDefault::get(), vec![6, 9]);
|
||||
let _ = JustVecWithDefault::append([1].iter());
|
||||
assert_eq!(JustVecWithDefault::get(), vec![6, 9, 1]);
|
||||
|
||||
assert_eq!(MapVecWithDefault::get(0), vec![6, 9]);
|
||||
let _ = MapVecWithDefault::append(0, [1].iter());
|
||||
assert_eq!(MapVecWithDefault::get(0), vec![6, 9, 1]);
|
||||
|
||||
assert_eq!(OptionVec::get(), None);
|
||||
let _ = OptionVec::append([1].iter());
|
||||
assert_eq!(OptionVec::get(), Some(vec![1]));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_or_put_works() {
|
||||
with_externalities(&mut TestExternalities::default(), || {
|
||||
let _ = MapVec::append_or_insert(1, [1, 2, 3].iter());
|
||||
let _ = MapVec::append_or_insert(1, [4, 5].iter());
|
||||
assert_eq!(MapVec::get(1), vec![1, 2, 3, 4, 5]);
|
||||
|
||||
let _ = JustVec::append_or_put([1, 2, 3].iter());
|
||||
let _ = JustVec::append_or_put([4, 5].iter());
|
||||
assert_eq!(JustVec::get(), vec![1, 2, 3, 4, 5]);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn len_works() {
|
||||
with_externalities(&mut TestExternalities::default(), || {
|
||||
JustVec::put(&vec![1, 2, 3, 4]);
|
||||
OptionVec::put(&vec![1, 2, 3, 4, 5]);
|
||||
MapVec::insert(1, &vec![1, 2, 3, 4, 5, 6]);
|
||||
LinkedMapVec::insert(2, &vec![1, 2, 3]);
|
||||
|
||||
assert_eq!(JustVec::decode_len().unwrap(), 4);
|
||||
assert_eq!(OptionVec::decode_len().unwrap(), 5);
|
||||
assert_eq!(MapVec::decode_len(1).unwrap(), 6);
|
||||
assert_eq!(LinkedMapVec::decode_len(2).unwrap(), 3);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn len_works_for_default() {
|
||||
with_externalities(&mut TestExternalities::default(), || {
|
||||
// vec
|
||||
assert_eq!(JustVec::get(), vec![]);
|
||||
assert_eq!(JustVec::decode_len(), Ok(0));
|
||||
|
||||
assert_eq!(JustVecWithDefault::get(), vec![6, 9]);
|
||||
assert_eq!(JustVecWithDefault::decode_len(), Ok(2));
|
||||
|
||||
assert_eq!(OptionVec::get(), None);
|
||||
assert_eq!(OptionVec::decode_len(), Ok(0));
|
||||
|
||||
assert_eq!(OptionVecWithDefault::get(), Some(vec![6, 9]));
|
||||
assert_eq!(OptionVecWithDefault::decode_len(), Ok(2));
|
||||
|
||||
// map
|
||||
assert_eq!(MapVec::get(0), vec![]);
|
||||
assert_eq!(MapVec::decode_len(0), Ok(0));
|
||||
|
||||
assert_eq!(MapVecWithDefault::get(0), vec![6, 9]);
|
||||
assert_eq!(MapVecWithDefault::decode_len(0), Ok(2));
|
||||
|
||||
assert_eq!(OptionMapVec::get(0), None);
|
||||
assert_eq!(OptionMapVec::decode_len(0), Ok(0));
|
||||
|
||||
assert_eq!(OptionMapVecWithDefault::get(0), Some(vec![6, 9]));
|
||||
assert_eq!(OptionMapVecWithDefault::decode_len(0), Ok(2));
|
||||
|
||||
// linked map
|
||||
assert_eq!(LinkedMapVec::get(0), vec![]);
|
||||
assert_eq!(LinkedMapVec::decode_len(0), Ok(0));
|
||||
|
||||
assert_eq!(LinkedMapVecWithDefault::get(0), vec![6, 9]);
|
||||
assert_eq!(LinkedMapVecWithDefault::decode_len(0), Ok(2));
|
||||
|
||||
assert_eq!(OptionLinkedMapVec::get(0), None);
|
||||
assert_eq!(OptionLinkedMapVec::decode_len(0), Ok(0));
|
||||
|
||||
assert_eq!(OptionLinkedMapVecWithDefault::get(0), Some(vec![6, 9]));
|
||||
assert_eq!(OptionLinkedMapVecWithDefault::decode_len(0), Ok(2));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,28 @@ use crate::sr_primitives::ConsensusEngineId;
|
||||
|
||||
use super::for_each_tuple;
|
||||
|
||||
/// A trait that can return the default value of a storage item. This must only ever be implemented
|
||||
/// for a special delegator struct for each storage item
|
||||
pub trait StorageDefault<V>: Sized {
|
||||
/// Return the default value of type `V`. `None`, if `V` does not have a proper default value.
|
||||
fn default() -> Option<V>;
|
||||
}
|
||||
|
||||
// FIXME #1466 This is needed for `storage_items!`. Should be removed once it is deprecated.
|
||||
impl<T: Default> StorageDefault<T> for () { fn default() -> Option<T> { Some(Default::default()) } }
|
||||
|
||||
/// Anything that can have a `::len()` method.
|
||||
pub trait Len {
|
||||
/// Return the length of data type.
|
||||
fn len(&self) -> usize;
|
||||
}
|
||||
|
||||
impl<T: IntoIterator + Clone,> Len for T where <T as IntoIterator>::IntoIter: ExactSizeIterator {
|
||||
fn len(&self) -> usize {
|
||||
self.clone().into_iter().len()
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait for querying a single fixed value from a type.
|
||||
pub trait Get<T> {
|
||||
/// Return a constant value.
|
||||
|
||||
@@ -578,7 +578,7 @@ impl<T: Trait> Module<T> {
|
||||
// We perform early return if we've reached the maximum capacity of the event list,
|
||||
// so `Events<T>` seems to be corrupted. Also, this has happened after the start of execution
|
||||
// (since the event list is cleared at the block initialization).
|
||||
if <Events<T>>::append(&[event]).is_err() {
|
||||
if <Events<T>>::append([event].into_iter()).is_err() {
|
||||
// The most sensible thing to do here is to just ignore this event and wait until the
|
||||
// new block.
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user