Author

Topic: Bloom filter examples? (Read 975 times)

jr. member
Activity: 50
Merit: 54
January 13, 2015, 07:00:08 AM
#5
At a guess, the payload would be something like this:

Code:
01 ......... Filter bytes: 1
0000 ....... Filter: 00000000
00000000 ... nHashFuncs: 0
00000000 ... nTweak: 0/none
00 ......... nFlags: BLOOM_UPDATE_NONE

You'd have to determine for yourself whether an empty filter or an nHashFuncs of zero is permitted.  It might even be possible to set nFilterBytes to 0 and omit the filter field entirely.

Note that you don't need a filter to inhibit receiving transaction invs---that's the default connection mode if you set the relay flag to 0x00 in the version message.  (This would normally be done in conduction with setting the services bitfield to 0x0000000000000000 to indicate you're not running a full node.)

legendary
Activity: 1260
Merit: 1019
January 13, 2015, 03:56:26 AM
#4
Too difficult for me  Cry with my little knowledge of English
Can you help me with very basic examples?

Let us say, that I know how to create packets:

Code:
const QByteArray NetSocket::packet ( const char* type, const QByteArray& payload )
{
  return MyByteArray ( )
    .putInt32 ( MAGIC_ID )            // magic prefix in low-endian
    .putAscii ( type, 12 )               // command padded to 12 bytes
    .putInt32 ( payload.size ( ) )     // data size
    .append ( MyKey32 ( payload.constData ( ), payload.size ( ) ).constData ( ), 4 ) // data checksum
    .append ( payload );  // data itself
}

And the results are (several basic examples):

verack packet:
Code:
f9 be b4 d9 76 65 72 61 63 6b 00 00 00 00 00 00
00 00 00 00 5d f6 e0 e2
getaddr packet
Code:
f9 be b4 d9 67 65 74 61 64 64 72 00 00 00 00 00
00 00 00 00 5d f6 e0 e2
mempool packet
Code:
f9 be b4 d9 6d 65 6d 70 6f 6f 6c 00 00 00 00 00
00 00 00 00 5d f6 e0 e2

What will be the very basic filterload packet which sets mask to all zeros and disables all incoming traffic?
jr. member
Activity: 50
Merit: 54
January 03, 2015, 09:07:19 AM
#3
We recently added docs about bloom filters and merkleblocks to the Bitcoin.org developer documentation.  You probably want to read this first:

https://bitcoin.org/en/developer-reference#filterload

And then look at the Python example here:

https://bitcoin.org/en/developer-examples#creating-a-bloom-filter

I also agree with Mike: I found reading the BitcoinJ sources very useful when writing the above linked documentation (and, of course, I depended on BIP37 for design details).
legendary
Activity: 1526
Merit: 1134
January 02, 2015, 03:17:19 PM
#2
You can look at the source of bitcoinj to see how it works, or read BIP 37.
legendary
Activity: 1260
Merit: 1019
January 02, 2015, 12:02:26 PM
#1
Are there good examples (with raw dumps) how to create and use bloom filters?

Let us say, that I have three addresses 1addr1xxxxxxx, 1addr2xxxxxx and 1addr3xxxxxxx
I want to reduce traffic to my node. I want to receive only transactions funding my addresses
I have to create filterload protocol packet and send it to my peers.

Can you point me to good and easy-to-understand sources?
Thank you
Jump to: