fix tests. non-rolling bloom filter for txdb.

This commit is contained in:
Christopher Jeffrey 2016-06-22 17:51:49 -07:00
parent aec1ebbdd3
commit 48855ae56f
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 15 additions and 7 deletions

View File

@ -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;
}

View File

@ -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,