From 48855ae56fac747fb942e76b432b26b555c36ccd Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 22 Jun 2016 17:51:49 -0700 Subject: [PATCH] fix tests. non-rolling bloom filter for txdb. --- lib/bcoin/txdb.js | 9 ++++++++- test/protocol-test.js | 13 +++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/bcoin/txdb.js b/lib/bcoin/txdb.js index 19d49261..63cebd4b 100644 --- a/lib/bcoin/txdb.js +++ b/lib/bcoin/txdb.js @@ -62,8 +62,15 @@ function TXDB(db, options) { this.busy = false; this.jobs = []; this.locker = new bcoin.locker(this); + + // Try to optimize for up to 1m addresses. + // We use a regular bloom filter here + // because we never want members to + // lose membership, even if quality + // degrades. + // Memory used: 1.7mb this.filter = this.options.useFilter - ? new bcoin.bloom.rolling(800000, 0.01) + ? bcoin.bloom.fromRate(1000000, 0.001, -1) : null; } diff --git a/test/protocol-test.js b/test/protocol-test.js index da6a11cb..a3780479 100644 --- a/test/protocol-test.js +++ b/test/protocol-test.js @@ -7,6 +7,7 @@ var network = bcoin.network.get(); var utils = bcoin.utils; var fs = require('fs'); var alertData = fs.readFileSync(__dirname + '/data/alertTests.raw'); +var NetworkAddress = bcoin.packets.NetworkAddress; describe('Protocol', function() { var version = require('../package.json').version; @@ -35,8 +36,8 @@ describe('Protocol', function() { version: constants.VERSION, services: constants.LOCAL_SERVICES, ts: bcoin.now(), - remote: new bcoin.networkaddress(), - local: new bcoin.networkaddress(), + remote: new NetworkAddress(), + local: new NetworkAddress(), nonce: utils.nonce(), agent: constants.USER_AGENT, height: 0, @@ -54,8 +55,8 @@ describe('Protocol', function() { version: constants.VERSION, services: constants.LOCAL_SERVICES, ts: bcoin.now(), - remote: new bcoin.networkaddress(), - local: new bcoin.networkaddress(), + remote: new NetworkAddress(), + local: new NetworkAddress(), nonce: utils.nonce(), agent: constants.USER_AGENT, height: 10, @@ -73,13 +74,13 @@ describe('Protocol', function() { }); var hosts = [ - new bcoin.networkaddress({ + new NetworkAddress({ services: constants.LOCAL_SERVICES, host: '127.0.0.1', port: 8333, ts: Date.now() / 1000 | 0 }), - new bcoin.networkaddress({ + new NetworkAddress({ services: constants.LOCAL_SERVICES, host: '::123:456:789a', port: 18333,