Short-circuit bloom checking if we will always return true. #2338

Merged
merged 1 commit into from Feb 26, 2013

Conversation

Projects
None yet
6 participants
Contributor

TheBlueMatt commented Feb 25, 2013

This allows full nodes to use bloom filters as an optimization when downloading blocks (dont double-relay txn) as long as we have a sufficiently large mempool.

Short-circuit bloom checking if we will always return true.
This allows full nodes to use bloom filters as an optimization.
Contributor

TheBlueMatt commented Feb 25, 2013

I figure I get this simply included in the protocol so that we can later bother with the actual download optimizations.

Automatic sanity-testing: WARNING, see http://jenkins.bluematt.me/pull-tester/cbfc77352d095d562860fa8695ada5ac73cf7f67 for binaries and test log.

This pull decreases total test coverage, please add unit tests to test all new code and help us add test cases for existing code.
Coverage report can be found at http://jenkins.bluematt.me/pull-tester/cbfc77352d095d562860fa8695ada5ac73cf7f67/bitcoin/src/total.coverage/

Contributor

mikehearn commented Feb 25, 2013

Hah, neat. Do the merkle blocks generated by such a filter have much overhead for the representation vs just a generic list of hashes?

Owner

sipa commented Feb 25, 2013

@mikehearn 8 bytes + 0.25 byte/tx + overhead of sending the transactions in separate messages instead of inline in a block.

Contributor

mikehearn commented Feb 25, 2013

Actually 32.25 bytes per tx (we chatted about it offline)

Contributor

TheBlueMatt commented Feb 25, 2013

Yea, I think thats pretty good considering you have to atleast transfer the 32-byte sha256 hash of the tx (atleast given that you've already received most, if not all, of the txn in question).

Member

gmaxwell commented Feb 25, 2013

@TheBlueMatt not horrible, though a protocol made just for this could transmit— say— 8 bytes instead, and then just pull the whole block in the insanely rare case that there is a collision. Probably not worth doing inside the bitcoin p2p protocol however.

Contributor

TheBlueMatt commented Feb 25, 2013

Yea, absolutely could do better, but since this is already in the protocol, I figured I might as well enable it without wasting tons of CPU cycles hashing.

gavinandresen added a commit that referenced this pull request Feb 26, 2013

Merge pull request #2338 from TheBlueMatt/bloom
Short-circuit bloom checking if we will always return true.

@gavinandresen gavinandresen merged commit 65497f4 into bitcoin:master Feb 26, 2013

laudney pushed a commit to reddcoin-project/reddcoin that referenced this pull request Mar 19, 2014

Merge pull request #2338 from TheBlueMatt/bloom
Short-circuit bloom checking if we will always return true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment