bip152: optimize.
This commit is contained in:
parent
049be2086d
commit
9ced2df5fa
@ -249,7 +249,7 @@ CompactBlock.prototype.initKey = function initKey() {
|
||||
};
|
||||
|
||||
CompactBlock.prototype.init = function init() {
|
||||
var i, last, ptx, offset;
|
||||
var i, last, ptx, offset, id;
|
||||
|
||||
if (this.totalTX === 0)
|
||||
throw new Error('Empty vectors.');
|
||||
@ -278,15 +278,19 @@ CompactBlock.prototype.init = function init() {
|
||||
for (i = 0; i < this.ids.length; i++) {
|
||||
while (this.available[i + offset])
|
||||
offset++;
|
||||
this.idMap[this.ids[i]] = i + offset;
|
||||
|
||||
id = this.ids[i];
|
||||
|
||||
// Fails on siphash collision
|
||||
assert(!this.idMap[id], 'Siphash collision.');
|
||||
|
||||
this.idMap[id] = i + offset;
|
||||
|
||||
// We're supposed to fail here if there's
|
||||
// more than 12 hash collisions, but we
|
||||
// don't have lowlevel access to our hash
|
||||
// table. Hopefully we don't get hashdos'd.
|
||||
}
|
||||
|
||||
// Fails on siphash collision
|
||||
assert(this.ids.length === Object.keys(this.idMap).length);
|
||||
};
|
||||
|
||||
CompactBlock.prototype.toBlock = function toBlock() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user