Hi ๐๐ผ
rcasatta / bitcoin_slices Goto Github PK
View Code? Open in Web Editor NEWParse Bitcoin objects without allocations
License: MIT License
Parse Bitcoin objects without allocations
License: MIT License
Hi ๐๐ผ
Even though one could serialize / deserialize to roundtrip I think it's worthy implementing feature-gated conversion because the validity of the invariance could be used to optimize a bit
Since there is no analysis
In blocks_iterator I would like to parse BlockExtra
using this crate like drafter here.
But how can I access the content of extra data like the field outpoint_values
?
Visitor trait should somehow be extended, not sure if an associated object that can be left empty in this lib could serve this purpose
implement Bitcoin p2p types https://github.com/rust-bitcoin/rust-bitcoin/tree/3417585a53451a28e0c3172dd752814b61d68f73/bitcoin/src/network
May be useful to use a visitor model in resources-constrained devices
and other things to use it correctly downstream
The bitcoin
crate currently provides number of useful types that could be returned in Visitor
methods instead. This would of course make the dependency mandatory. (But most, if not all, Bitcoin projects will depend on it anyway.) If it's considered too large, perhaps it'll make more sense after crate smashing.
Some noteworthy types:
&Script
Sequence
LockTime
Amount
block::Version
CompactTarget
I'd be happy to help making other types more easily usable with this crate.
Suppose a use case to find a Transaction in a Block, once found the parsing of the block should be interrupted early.
Like returning a bool from visit_transaction indicating to continue to parse or not?
While you usually don't parse those from a byte slice, it is useful as return type of the relative functions and as database key
like the one we use in bench
struct Sum(u64);
impl Visitor for Sum {
fn visit_tx_out(&mut self, _vout: usize, tx_out: &TxOut) {
self.0 += tx_out.value();
}
}
let mut sum = Sum(0);
let block = Block::visit(BENCH_BLOCK, &mut sum).unwrap();
assert_eq!(sum.0, 2883682728990);
This library cannot consume Read
by design because it needs a borrowed slice to create objects.
A rotating buffer filling data from a Read
input and producing borrowed objects could overcome this limitation and read from streams. The buffer should rotate back every once in a while to be limited in size. It must be long enough to support the maximum size of the object to be read, luckily bitcoin objects are limited in size by consensus so there is an upper limit, at worse 4MB.
They should contain almost identical information, so it's better to update the readme and obtain the same updated in the doc home page using: #![doc = include_str!("../README.md")]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.