fixed bits order in merkleblock
This commit is contained in:
parent
b98b0ac28d
commit
f12b498e9d
|
@ -243,7 +243,18 @@ impl ConnectionFilter {
|
||||||
// build partial merkle tree
|
// build partial merkle tree
|
||||||
let (hashes, flags) = PartialMerkleTree::build(all_hashes, all_flags);
|
let (hashes, flags) = PartialMerkleTree::build(all_hashes, all_flags);
|
||||||
result.merkleblock.hashes.extend(hashes);
|
result.merkleblock.hashes.extend(hashes);
|
||||||
result.merkleblock.flags = flags.to_bytes().into();
|
// to_bytes() converts [true, false, true] to 0b10100000
|
||||||
|
// while protocol requires [true, false, true] to be serialized as 0x00000101
|
||||||
|
result.merkleblock.flags = flags.to_bytes().into_iter()
|
||||||
|
.map(|b|
|
||||||
|
((b & 0b10000000) >> 7) |
|
||||||
|
((b & 0b01000000) >> 5) |
|
||||||
|
((b & 0b00100000) >> 3) |
|
||||||
|
((b & 0b00010000) >> 1) |
|
||||||
|
((b & 0b00001000) << 1) |
|
||||||
|
((b & 0b00000100) << 3) |
|
||||||
|
((b & 0b00000010) << 5) |
|
||||||
|
((b & 0b00000001) << 7)).collect::<Vec<u8>>().into();
|
||||||
Some(result)
|
Some(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,7 +346,7 @@ mod tests {
|
||||||
let match_tx1 = vec![(tx1_hash.clone(), tx1)];
|
let match_tx1 = vec![(tx1_hash.clone(), tx1)];
|
||||||
let match_tx2 = vec![(tx2_hash.clone(), tx2)];
|
let match_tx2 = vec![(tx2_hash.clone(), tx2)];
|
||||||
let no_match_bytes = Bytes::from(vec![0x00]);
|
let no_match_bytes = Bytes::from(vec![0x00]);
|
||||||
let match_bytes = Bytes::from(vec![0x80]);
|
let match_bytes = Bytes::from(vec![0x01]);
|
||||||
|
|
||||||
// This peer will provide blocks
|
// This peer will provide blocks
|
||||||
let peer_index1 = local_node.create_sync_session(0, DummyOutboundSyncConnection::new());
|
let peer_index1 = local_node.create_sync_session(0, DummyOutboundSyncConnection::new());
|
||||||
|
|
Loading…
Reference in New Issue