bip152: minor. add assertion.
This commit is contained in:
parent
de9f37b290
commit
33c32d32c1
@ -132,8 +132,11 @@ CompactBlock.prototype.fromRaw = function fromRaw(data) {
|
||||
|
||||
this.totalTX += idCount;
|
||||
|
||||
for (let i = 0; i < idCount; i++)
|
||||
this.ids.push(br.readU32() + br.readU16() * 0x100000000);
|
||||
for (let i = 0; i < idCount; i++) {
|
||||
const lo = br.readU32();
|
||||
const hi = br.readU16();
|
||||
this.ids.push(hi * 0x100000000 + lo);
|
||||
}
|
||||
|
||||
const txCount = br.readVarint();
|
||||
|
||||
@ -259,8 +262,8 @@ CompactBlock.prototype.writeRaw = function writeRaw(bw, witness) {
|
||||
|
||||
for (const id of this.ids) {
|
||||
const lo = id % 0x100000000;
|
||||
let hi = (id - lo) / 0x100000000;
|
||||
hi &= 0xffff;
|
||||
const hi = (id - lo) / 0x100000000;
|
||||
assert(hi <= 0xffff);
|
||||
bw.writeU32(lo);
|
||||
bw.writeU16(hi);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user