File tree Expand file tree Collapse file tree 6 files changed +18
-58
lines changed Expand file tree Collapse file tree 6 files changed +18
-58
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use std::fs::File;
2
2
use std:: io:: { BufWriter , Write } ;
3
3
use std:: path:: PathBuf ;
4
4
5
- use clap:: { Arg , ArgMatches , Command } ;
5
+ use clap:: ArgMatches ;
6
6
7
7
use crate :: callbacks:: Callback ;
8
8
@@ -22,20 +22,6 @@ impl Balances {
22
22
}
23
23
24
24
impl Callback for Balances {
25
- fn build_subcommand ( ) -> Command
26
- where
27
- Self : Sized ,
28
- {
29
- Command :: new ( "balances" )
30
- . about ( "Dumps all addresses with non-zero balance to CSV file" )
31
- . arg (
32
- Arg :: new ( "dump-folder" )
33
- . help ( "Folder to store csv file" )
34
- . index ( 1 )
35
- . required ( true ) ,
36
- )
37
- }
38
-
39
25
fn new ( matches : & ArgMatches ) -> anyhow:: Result < Self >
40
26
where
41
27
Self : Sized ,
Original file line number Diff line number Diff line change 1
- use clap:: { ArgMatches , Command } ;
1
+ use clap:: ArgMatches ;
2
2
3
3
pub mod balances;
4
4
pub mod opreturn;
@@ -9,12 +9,6 @@ pub mod unspentcsvdump;
9
9
/// The parser ensures that the blocks arrive in the correct order.
10
10
/// At this stage the main chain is already determined and orphans/stales are removed.
11
11
pub trait Callback {
12
- /// Builds Command to specify callback name and required args,
13
- /// exits if some required args are missing.
14
- fn build_subcommand ( ) -> Command
15
- where
16
- Self : Sized ;
17
-
18
12
/// Instantiates callback
19
13
fn new ( matches : & ArgMatches ) -> anyhow:: Result < Self >
20
14
where
Original file line number Diff line number Diff line change 1
- use clap:: { ArgMatches , Command } ;
1
+ use clap:: ArgMatches ;
2
2
3
3
use crate :: callbacks:: Callback ;
4
4
5
5
#[ derive( Default ) ]
6
6
pub struct OpReturn ;
7
7
8
8
impl Callback for OpReturn {
9
- fn build_subcommand ( ) -> Command
10
- where
11
- Self : Sized ,
12
- {
13
- Command :: new ( "opreturn" )
14
- . about ( "Shows embedded OP_RETURN data that is representable as UTF8" )
15
- }
16
-
17
9
fn new ( _: & ArgMatches ) -> anyhow:: Result < Self >
18
10
where
19
11
Self : Sized ,
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use bitcoin::hashes::{sha256d, Hash};
2
2
use std:: collections:: HashMap ;
3
3
use std:: io:: Write ;
4
4
5
- use clap:: { ArgMatches , Command } ;
5
+ use clap:: ArgMatches ;
6
6
7
7
use crate :: callbacks:: Callback ;
8
8
@@ -174,13 +174,6 @@ impl SimpleStats {
174
174
}
175
175
176
176
impl Callback for SimpleStats {
177
- fn build_subcommand ( ) -> Command
178
- where
179
- Self : Sized ,
180
- {
181
- Command :: new ( "simplestats" ) . about ( "Shows various Blockchain stats" )
182
- }
183
-
184
177
fn new ( _: & ArgMatches ) -> anyhow:: Result < Self >
185
178
where
186
179
Self : Sized ,
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use std::fs::File;
2
2
use std:: io:: { BufWriter , Write } ;
3
3
use std:: path:: PathBuf ;
4
4
5
- use clap:: { Arg , ArgMatches , Command } ;
5
+ use clap:: ArgMatches ;
6
6
7
7
/// Dumps the UTXOs along with address in a csv file
8
8
pub struct UnspentCsvDump {
@@ -22,20 +22,6 @@ impl UnspentCsvDump {
22
22
}
23
23
24
24
impl crate :: callbacks:: Callback for UnspentCsvDump {
25
- fn build_subcommand ( ) -> Command
26
- where
27
- Self : Sized ,
28
- {
29
- Command :: new ( "unspentcsvdump" )
30
- . about ( "Dumps the unspent outputs to CSV file" )
31
- . arg (
32
- Arg :: new ( "dump-folder" )
33
- . help ( "Folder to store csv file" )
34
- . index ( 1 )
35
- . required ( true ) ,
36
- )
37
- }
38
-
39
25
fn new ( matches : & ArgMatches ) -> anyhow:: Result < Self >
40
26
where
41
27
Self : Sized ,
Original file line number Diff line number Diff line change @@ -95,10 +95,19 @@ pub fn command() -> Command {
95
95
. value_parser ( clap:: value_parser!( u64 ) )
96
96
. help ( "Specify last block for parsing (inclusive) (default: all known blocks)" ) )
97
97
// Add callbacks
98
- . subcommand ( UnspentCsvDump :: build_subcommand ( ) )
99
- . subcommand ( SimpleStats :: build_subcommand ( ) )
100
- . subcommand ( Balances :: build_subcommand ( ) )
101
- . subcommand ( OpReturn :: build_subcommand ( ) )
98
+ . subcommand ( Command :: new ( "unspentcsvdump" ) . about ( "Dumps the unspent outputs to CSV file" ) . arg (
99
+ Arg :: new ( "dump-folder" )
100
+ . help ( "Folder to store csv file" )
101
+ . index ( 1 )
102
+ . required ( true ) ) )
103
+ . subcommand ( Command :: new ( "simplestats" ) . about ( "Shows various Blockchain stats" ) )
104
+ . subcommand ( Command :: new ( "balances" ) . about ( "Dumps all addresses with non-zero balance to CSV file" ) . arg (
105
+ Arg :: new ( "dump-folder" )
106
+ . help ( "Folder to store csv file" )
107
+ . index ( 1 )
108
+ . required ( true ) ,
109
+ ) )
110
+ . subcommand ( Command :: new ( "opreturn" ) . about ( "Shows embedded OP_RETURN data that is representable as UTF8" ) )
102
111
}
103
112
104
113
/// Returns default directory. TODO: test on windows
You can’t perform that action at this time.
0 commit comments