Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
496128d5
Commit
496128d5
authored
3 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
feat(cli): add subcommand utils storage-key-prefix
parent
e01bc04b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!28
Smiths sub-wot
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Cargo.lock
+1
-0
1 addition, 0 deletions
Cargo.lock
Cargo.toml
+1
-0
1 addition, 0 deletions
Cargo.toml
node/src/cli.rs
+4
-0
4 additions, 0 deletions
node/src/cli.rs
node/src/cli/utils.rs
+68
-0
68 additions, 0 deletions
node/src/cli/utils.rs
node/src/command.rs
+1
-0
1 addition, 0 deletions
node/src/command.rs
with
75 additions
and
0 deletions
Cargo.lock
+
1
−
0
View file @
496128d5
...
...
@@ -1268,6 +1268,7 @@ dependencies = [
"sp-consensus-babe",
"sp-core",
"sp-finality-grandpa",
"sp-io",
"sp-keyring",
"sp-keystore",
"sp-membership",
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
1
−
0
View file @
496128d5
...
...
@@ -84,6 +84,7 @@ sp-consensus = { git = "https://github.com/librelois/substrate.git", branch = "d
sp-consensus-babe
=
{
git
=
"https://github.com/librelois/substrate.git"
,
branch
=
"duniter-monthly-2022-01"
}
sp-core
=
{
git
=
"https://github.com/librelois/substrate.git"
,
branch
=
"duniter-monthly-2022-01"
}
sp-finality-grandpa
=
{
git
=
"https://github.com/librelois/substrate.git"
,
branch
=
"duniter-monthly-2022-01"
}
sp-io
=
{
git
=
"https://github.com/librelois/substrate.git"
,
branch
=
"duniter-monthly-2022-01"
}
sp-offchain
=
{
git
=
"https://github.com/librelois/substrate.git"
,
branch
=
"duniter-monthly-2022-01"
}
sp-keyring
=
{
git
=
"https://github.com/librelois/substrate.git"
,
branch
=
"duniter-monthly-2022-01"
}
sp-keystore
=
{
git
=
"https://github.com/librelois/substrate.git"
,
branch
=
"duniter-monthly-2022-01"
}
...
...
This diff is collapsed.
Click to expand it.
node/src/cli.rs
+
4
−
0
View file @
496128d5
...
...
@@ -15,6 +15,7 @@
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
pub
mod
key
;
pub
mod
utils
;
use
sc_cli
::
RunCmd
;
use
std
::
str
::
FromStr
;
...
...
@@ -60,6 +61,9 @@ pub enum Subcommand {
/// Revert the chain to a previous state.
Revert
(
sc_cli
::
RevertCmd
),
/// Some tools for developers and advanced testers
Utils
(
utils
::
UtilsSubCommand
),
/// The custom benchmark subcommmand benchmarking runtime pallets.
#[structopt(name
=
"benchmark"
,
about
=
"Benchmark runtime pallets."
)]
Benchmark
(
frame_benchmarking_cli
::
BenchmarkCmd
),
...
...
This diff is collapsed.
Click to expand it.
node/src/cli/utils.rs
0 → 100644
+
68
−
0
View file @
496128d5
// Copyright 2021 Axiom-Team
//
// This file is part of Substrate-Libre-Currency.
//
// Substrate-Libre-Currency is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Substrate-Libre-Currency is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
use
sc_cli
::{
Error
,
SubstrateCli
};
use
sp_io
::
hashing
::
twox_128
;
use
structopt
::
StructOpt
;
#[derive(Debug,
StructOpt)]
pub
enum
UtilsSubCommand
{
/// Compute the raw storage key prefix
StorageKeyPrefix
(
StorageKeyPrefixCmd
),
}
impl
UtilsSubCommand
{
/// Run the command
pub
fn
run
<
C
:
SubstrateCli
>
(
&
self
,
cli
:
&
C
)
->
Result
<
(),
Error
>
{
match
self
{
Self
::
StorageKeyPrefix
(
cmd
)
=>
cmd
.run
(
cli
),
}
}
}
#[derive(Debug,
StructOpt)]
pub
struct
StorageKeyPrefixCmd
{
/// Pallet name
#[structopt(short
=
"p"
,
long)]
pallet_name
:
Option
<
String
>
,
/// Storage item name
#[structopt(short
=
"i"
,
long)]
item_name
:
Option
<
String
>
,
}
impl
StorageKeyPrefixCmd
{
/// Run the command
pub
fn
run
<
C
:
SubstrateCli
>
(
&
self
,
_cli
:
&
C
)
->
Result
<
(),
Error
>
{
let
mut
key_prefix
=
Vec
::
new
();
let
mut
print_key_prefix
=
false
;
if
let
Some
(
ref
pallet_name
)
=
self
.pallet_name
{
print_key_prefix
=
true
;
let
pallet_prefix
=
twox_128
(
pallet_name
.as_bytes
());
println!
(
"Pallet prefix: 0x{}"
,
hex
::
encode
(
&
pallet_prefix
));
key_prefix
.extend_from_slice
(
&
pallet_prefix
[
..
]);
}
if
let
Some
(
ref
item_name
)
=
self
.item_name
{
let
item_prefix
=
twox_128
(
item_name
.as_bytes
());
println!
(
"Item prefix: 0x{}"
,
hex
::
encode
(
item_prefix
));
key_prefix
.extend_from_slice
(
&
item_prefix
[
..
]);
}
if
print_key_prefix
{
println!
(
"Key prefix: 0x{}"
,
hex
::
encode
(
key_prefix
));
}
Ok
(())
}
}
This diff is collapsed.
Click to expand it.
node/src/command.rs
+
1
−
0
View file @
496128d5
...
...
@@ -147,6 +147,7 @@ pub fn run() -> sc_cli::Result<()> {
match
&
cli
.subcommand
{
Some
(
Subcommand
::
Key
(
cmd
))
=>
cmd
.run
(
&
cli
),
Some
(
Subcommand
::
Utils
(
cmd
))
=>
cmd
.run
(
&
cli
),
Some
(
Subcommand
::
BuildSpec
(
cmd
))
=>
{
let
runner
=
cli
.create_runner
(
cmd
)
?
;
runner
.sync_run
(|
config
|
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment