Bitcoin Forum
September 30, 2022, 10:53:44 PM *
News: Latest Bitcoin Core release: 23.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bloom filter examples?  (Read 949 times)
amaclin (OP)
Legendary
*
Offline Offline

Activity: 1260
Merit: 1018


View Profile
January 02, 2015, 05: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
1664578424
Hero Member
*
Offline Offline

Posts: 1664578424

View Profile Personal Message (Offline)

Ignore
1664578424
Reply with quote  #2

1664578424
Report to moderator
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1664578424
Hero Member
*
Offline Offline

Posts: 1664578424

View Profile Personal Message (Offline)

Ignore
1664578424
Reply with quote  #2

1664578424
Report to moderator
1664578424
Hero Member
*
Offline Offline

Posts: 1664578424

View Profile Personal Message (Offline)

Ignore
1664578424
Reply with quote  #2

1664578424
Report to moderator
Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1056


View Profile
January 02, 2015, 08:17:19 PM
 #2

You can look at the source of bitcoinj to see how it works, or read BIP 37.
harding
Jr. Member
*
Offline Offline

Activity: 50
Merit: 46


View Profile WWW
January 03, 2015, 02:07:19 PM
 #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).
amaclin (OP)
Legendary
*
Offline Offline

Activity: 1260
Merit: 1018


View Profile
January 13, 2015, 08: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?
harding
Jr. Member
*
Offline Offline

Activity: 50
Merit: 46


View Profile WWW
January 13, 2015, 12:00:08 PM
 #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.)

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!