Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğ
Ğcli-v2s
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
clients
Rust
Ğcli-v2s
Commits
bb913abb
Verified
Commit
bb913abb
authored
2 years ago
by
Pascal Engélibert
Browse files
Options
Downloads
Patches
Plain Diff
feat: online command
parent
45cce8b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/commands/smith.rs
+87
-1
87 additions, 1 deletion
src/commands/smith.rs
src/main.rs
+3
-0
3 additions, 0 deletions
src/main.rs
with
90 additions
and
1 deletion
src/commands/smith.rs
+
87
−
1
View file @
bb913abb
use
crate
::{
gdev
,
Client
};
use
crate
::{
cache
,
gdev
,
indexer
::
*
,
Args
,
Client
};
use
anyhow
::{
anyhow
,
Result
};
use
anyhow
::{
anyhow
,
Result
};
use
sp_core
::{
crypto
::
AccountId32
,
sr25519
::
Pair
,
Pair
as
_
};
use
sp_core
::{
crypto
::
AccountId32
,
sr25519
::
Pair
,
Pair
as
_
};
...
@@ -76,3 +76,89 @@ pub async fn go_offline(pair: Pair, client: Client) -> Result<()> {
...
@@ -76,3 +76,89 @@ pub async fn go_offline(pair: Pair, client: Client) -> Result<()> {
Ok
(())
Ok
(())
}
}
pub
async
fn
online
(
client
:
Client
,
args
:
&
Args
)
->
Result
<
()
>
{
let
parent_hash
=
client
.storage
()
.fetch
(
&
gdev
::
storage
()
.system
()
.parent_hash
(),
None
)
.await
?
.unwrap
();
let
gql_client
=
reqwest
::
Client
::
builder
()
.user_agent
(
"gcli/0.1.0"
)
.build
()
?
;
let
mut
identity_cache
=
cache
::
IdentityCache
::
new
(
&
client
,
if
args
.no_indexer
{
None
}
else
{
Some
(
Indexer
{
gql_client
,
gql_url
:
&
args
.indexer
,
})
},
);
let
online_authorities
=
client
.storage
()
.fetch
(
&
gdev
::
storage
()
.authority_members
()
.online_authorities
(),
Some
(
parent_hash
),
)
.await
?
.unwrap_or_default
();
println!
(
"Online:"
);
for
identity_id
in
online_authorities
{
println!
(
" {}"
,
identity_cache
.fetch_identity
(
identity_id
,
parent_hash
)
.await
.unwrap_or_else
(|
_
|
format!
(
"{identity_id}"
))
);
}
let
incoming_authorities
=
client
.storage
()
.fetch
(
&
gdev
::
storage
()
.authority_members
()
.incoming_authorities
(),
Some
(
parent_hash
),
)
.await
?
.unwrap_or_default
();
println!
(
"Incoming:"
);
for
identity_id
in
incoming_authorities
{
println!
(
" {}"
,
identity_cache
.fetch_identity
(
identity_id
,
parent_hash
)
.await
.unwrap_or_else
(|
_
|
format!
(
"{identity_id}"
))
);
}
let
outgoing_authorities
=
client
.storage
()
.fetch
(
&
gdev
::
storage
()
.authority_members
()
.outgoing_authorities
(),
Some
(
parent_hash
),
)
.await
?
.unwrap_or_default
();
println!
(
"Outgoing:"
);
for
identity_id
in
outgoing_authorities
{
println!
(
" {}"
,
identity_cache
.fetch_identity
(
identity_id
,
parent_hash
)
.await
.unwrap_or_else
(|
_
|
format!
(
"{identity_id}"
))
);
}
Ok
(())
}
This diff is collapsed.
Click to expand it.
src/main.rs
+
3
−
0
View file @
bb913abb
...
@@ -123,6 +123,8 @@ pub enum Subcommand {
...
@@ -123,6 +123,8 @@ pub enum Subcommand {
OneshotBalance
{
OneshotBalance
{
account
:
sp_core
::
crypto
::
AccountId32
,
account
:
sp_core
::
crypto
::
AccountId32
,
},
},
/// List online authorities
Online
,
#[clap(hide
=
true
)]
#[clap(hide
=
true
)]
Repart
{
Repart
{
// Number of transactions per block to target
// Number of transactions per block to target
...
@@ -280,6 +282,7 @@ async fn main() -> Result<()> {
...
@@ -280,6 +282,7 @@ async fn main() -> Result<()> {
Subcommand
::
OneshotBalance
{
account
}
=>
{
Subcommand
::
OneshotBalance
{
account
}
=>
{
commands
::
oneshot
::
oneshot_account_balance
(
client
,
account
)
.await
?
commands
::
oneshot
::
oneshot_account_balance
(
client
,
account
)
.await
?
}
}
Subcommand
::
Online
=>
commands
::
smith
::
online
(
client
,
&
args
)
.await
?
,
Subcommand
::
Repart
{
Subcommand
::
Repart
{
target
,
target
,
actual_repart
,
actual_repart
,
...
...
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