addrindexer: use network for getPrefix.

This commit is contained in:
Nodar Chkuaselidze 2019-05-17 20:23:40 +04:00
parent 7e49be2a07
commit 0f6ef910b0
No known key found for this signature in database
GPG Key ID: 8E1B4DC29040BD90
3 changed files with 9 additions and 6 deletions

View File

@ -141,7 +141,7 @@ class AddrIndexer extends Indexer {
let hasAddress = false; let hasAddress = false;
for (const addr of tx.getAddresses(view)) { for (const addr of tx.getAddresses(view)) {
const prefix = addr.getPrefix(); const prefix = addr.getPrefix(this.network);
if (prefix < 0) if (prefix < 0)
continue; continue;
@ -178,7 +178,7 @@ class AddrIndexer extends Indexer {
let hasAddress = false; let hasAddress = false;
for (const addr of tx.getAddresses(view)) { for (const addr of tx.getAddresses(view)) {
const prefix = addr.getPrefix(); const prefix = addr.getPrefix(this.network);
if (prefix < 0) if (prefix < 0)
continue; continue;
@ -223,7 +223,7 @@ class AddrIndexer extends Indexer {
throw new Error('Limit above max of ${this.maxTxs}.'); throw new Error('Limit above max of ${this.maxTxs}.');
const hash = Address.getHash(addr); const hash = Address.getHash(addr);
const prefix = addr.getPrefix(); const prefix = addr.getPrefix(this.network);
const opts = { const opts = {
limit, limit,

View File

@ -20,9 +20,12 @@ class AddrIndexer {
/** /**
* Create TX address index. * Create TX address index.
* @constructor * @constructor
* @param {Network} network
*/ */
constructor() { constructor(network) {
this.network = network;
// Map of addr->entries. // Map of addr->entries.
this.index = new BufferMap(); this.index = new BufferMap();
@ -36,7 +39,7 @@ class AddrIndexer {
} }
getKey(addr) { getKey(addr) {
const prefix = addr.getPrefix(); const prefix = addr.getPrefix(this.network);
if (prefix < 0) if (prefix < 0)
return null; return null;

View File

@ -73,7 +73,7 @@ class Mempool extends EventEmitter {
this.spents = new BufferMap(); this.spents = new BufferMap();
this.rejects = new RollingFilter(120000, 0.000001); this.rejects = new RollingFilter(120000, 0.000001);
this.addrindex = new AddrIndexer(); this.addrindex = new AddrIndexer(this.network);
} }
/** /**