Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

snappy and minor block compression #1286

Merged
merged 9 commits into from
Jun 15, 2016

Conversation

rphmeier
Copy link
Contributor

adds some simple snappy bindings.

the blocks now don't contain any parent hash or number within them. Each chunk of blocks stores the parent hash and the number of the first contained within, and the rest can be recalculated.

@rphmeier rphmeier added the A0-pleasereview 🤓 Pull request needs code review. label Jun 14, 2016
let rlp = Rlp::new(&self.rlp);

let mut header = Header {
parent_hash: parent_hash,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future work: parent_hash, uncle_hash, difficulty and number can be calculated. We might want to flatten transaction trie as well and get rid of transactions_root

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncles_hash? really?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that the hash of the uncles RLP which can be calculated from the block uncle data?


// use initially 20MB for the reusable snappy buffers.
// should always be larger than PREFERRED_CHUNK_SIZE for fault tolerance.
const SNAPPY_BUFFER_SIZE: usize = 20 * 1024 * 1024;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using snappy_max_compressed_length() instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

considering the buffer gets grown automatically if it is too small, it might just make sense to initially
allocate just max_compressed_len(16MB)

once we encode data to RLP, the overhead will often push it slightly over 16MB, so it may need growing once or twice, but this is unlikely.

@arkpar
Copy link
Collaborator

arkpar commented Jun 15, 2016

Looks good in general

@rphmeier rphmeier merged commit 57218a4 into openethereum:pv64 Jun 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants