-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
98 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,35 @@ | ||
use super::*; | ||
|
||
pub(crate) fn run(options: Options) -> Result { | ||
let index = Index::open(&options)?; | ||
index.update()?; | ||
serde_json::to_writer(io::stdout(), &index.info()?)?; | ||
Ok(()) | ||
#[derive(Debug, Parser)] | ||
pub(crate) struct Info { | ||
#[clap(long)] | ||
transactions: bool, | ||
} | ||
|
||
impl Info { | ||
pub(crate) fn run(self, options: Options) -> Result { | ||
let index = Index::open(&options)?; | ||
index.update()?; | ||
let info = index.info()?; | ||
|
||
if self.transactions { | ||
println!("start\tend\tcount\telapsed"); | ||
|
||
for window in info.transactions.windows(2) { | ||
let start = &window[0]; | ||
let end = &window[1]; | ||
println!( | ||
"{}\t{}\t{}\t{:.2}", | ||
start.starting_block_count, | ||
end.starting_block_count, | ||
end.starting_block_count - start.starting_block_count, | ||
(end.starting_timestamp - start.starting_timestamp) as f64 / 1000.0 / 60.0 | ||
); | ||
} | ||
} else { | ||
serde_json::to_writer(io::stdout(), &info)?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,17 @@ | ||
use super::*; | ||
|
||
#[test] | ||
fn custom_index_size() { | ||
fn custom_index_path() { | ||
let rpc_server = test_bitcoincore_rpc::spawn(); | ||
rpc_server.mine_blocks(1); | ||
|
||
let output = CommandBuilder::new("--max-index-size 1mib --index-ordinals find 0") | ||
let tempdir = TempDir::new().unwrap(); | ||
|
||
let index_path = tempdir.path().join("foo.redb"); | ||
|
||
CommandBuilder::new(format!("--index {} index", index_path.display())) | ||
.rpc_server(&rpc_server) | ||
.expected_stdout("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0:0\n") | ||
.run(); | ||
|
||
assert_eq!( | ||
output | ||
.tempdir | ||
.path() | ||
.join(if cfg!(target_os = "macos") { | ||
"Library/Application Support/" | ||
} else { | ||
".local/share" | ||
}) | ||
.join("ord") | ||
.join("index.redb") | ||
.metadata() | ||
.unwrap() | ||
.len(), | ||
1 << 20 | ||
); | ||
assert!(index_path.is_file()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ mod command_builder; | |
mod epochs; | ||
mod expected; | ||
mod find; | ||
mod index; | ||
mod info; | ||
mod list; | ||
mod parse; | ||
|