Author

Topic: Merkle Tree Bits bug?? (Read 633 times)

member
Activity: 60
Merit: 10
http://xingfeng.org
January 20, 2014, 05:03:42 AM
#2
oh...it's my problem....when calculation the bottom node, it's must make height + 1 tree
member
Activity: 60
Merit: 10
http://xingfeng.org
January 20, 2014, 02:55:28 AM
#1
a. send net message:

    1. filterload( BloomFilter( 100, 0.000001, BLOOM_UPDATE_NONE ) );

    2. filteradd( fromhex("27a1f12771de5cc3b73941664b2537c15316be43") );

    3. getdata( fromhex("0000000000000001cfee50480e82a9fd91bbee46b8ef2c8cbb0dcdfd658eac68"), MSG_FILTERED_BLOCK );

b. wait net message with merkle block data.
    merkleblock:
        CBlockHeader
              .....
        CPartialMerkleTree
              nTransactions
              vHash
              vBits

nTransactions = 640;
Code:
size_t get_tree_height( size_t nTransactions )
{
    double v = log( double( nTransactions ) ) / log( 2.0f ); // log2(nTransactions)
    if( fmod( v, 1 ) > 0 )
    {
        return size_t( v ) + 1;
    }
    return size_t( v );
}
so, i'm calculation the merkle tree height = 10;
and check it, because  2^9=512, and  2^10=1024.
so i think it's right height with the transaction count.

and
count(vHash)=11;
tohex(vBits) = "ff0700";

expand the vBits to :
  (true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false)

at prefix, has 11's true.
and, this tree branch count equal 1.
so, in the branch tree bottom, has 2 true node, (and the 2 tx-hash).
your can draw a tree bitmap to check it.
i think, i can get 2 tx?
( but...Im only put a filter key...maby it's bloom filter to two record. )

c. wait net message with "tx".
    im only revice 1 tx.. not 2 tx??

so, im think it's the vBits BUG?? it is not the filter problem.

and,  when im add other filter key, when the branch count greater 2, the bottom tx count is right. not this problem.
example:

block: 0000000000000000e0adedd30a9cdce5638bf507c769956dd8563ecfd2ff2a82
key:
    27a1f12771de5cc3b73941664b2537c15316be43
    8485f40e69b1bd95660a0b866ac250532d52c085
    cf14cc39c079f294049e94e11543f342277fc863

Im test the branch bottom's true node count was equal 3 from my calc_bottom_function.
it's right tx count with it.


The problem only be in branch count equal 1 ??
Jump to: