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

View File

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

View File

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