mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-29 00:59:58 -07:00
global: snapshot
This commit is contained in:
19
crates/brk_parser/src/block.rs
Normal file
19
crates/brk_parser/src/block.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use bitcoin::Block;
|
||||
|
||||
pub trait BlockExtended {
|
||||
fn coinbase_tag(&self) -> String;
|
||||
}
|
||||
|
||||
impl BlockExtended for Block {
|
||||
fn coinbase_tag(&self) -> String {
|
||||
let Some(input) = self.txdata.first().and_then(|tx| tx.input.first()) else {
|
||||
return String::new();
|
||||
};
|
||||
let bytes = input.script_sig.as_bytes();
|
||||
String::from_utf8_lossy(bytes)
|
||||
.chars()
|
||||
.filter(|&c| c != '\u{FFFD}' && (c >= ' ' || c == '\n' || c == '\r' || c == '\t'))
|
||||
.take(1_024)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ mod blk_index_to_blk_path;
|
||||
mod blk_index_to_blk_recap;
|
||||
mod blk_metadata;
|
||||
mod blk_recap;
|
||||
mod block;
|
||||
mod block_state;
|
||||
mod error;
|
||||
mod utils;
|
||||
@@ -22,6 +23,7 @@ mod xor_index;
|
||||
|
||||
use blk_index_to_blk_recap::*;
|
||||
use blk_metadata::*;
|
||||
pub use block::*;
|
||||
use block_state::*;
|
||||
pub use error::*;
|
||||
use utils::*;
|
||||
|
||||
Reference in New Issue
Block a user