txdb: give txdb a reference to wallet.
This commit is contained in:
parent
827f72ebc0
commit
09d8ee224c
@ -35,22 +35,19 @@ var BufferWriter = require('./writer');
|
||||
* TXDB
|
||||
* @exports TXDB
|
||||
* @constructor
|
||||
* @param {WalletDB} db
|
||||
* @param {WalletID} id
|
||||
* @param {Wallet} wallet
|
||||
*/
|
||||
|
||||
function TXDB(db, id) {
|
||||
function TXDB(wallet) {
|
||||
if (!(this instanceof TXDB))
|
||||
return new TXDB(db, id);
|
||||
return new TXDB(wallet);
|
||||
|
||||
this.id = id || null;
|
||||
this.walletdb = db;
|
||||
this.db = db.db;
|
||||
this.logger = db.logger;
|
||||
this.network = db.network;
|
||||
this.options = db.options;
|
||||
this.busy = false;
|
||||
this.jobs = [];
|
||||
this.wallet = wallet;
|
||||
this.walletdb = wallet.db;
|
||||
this.db = wallet.db.db;
|
||||
this.logger = wallet.db.logger;
|
||||
this.network = wallet.db.network;
|
||||
this.options = wallet.db.options;
|
||||
this.locker = new bcoin.locker(this);
|
||||
this.current = null;
|
||||
this.coinCache = new bcoin.lru(10000, 1);
|
||||
@ -62,8 +59,8 @@ function TXDB(db, id) {
|
||||
*/
|
||||
|
||||
TXDB.prototype.prefix = function prefix(key) {
|
||||
assert(this.id);
|
||||
return 't/' + this.id + '/' + key;
|
||||
assert(this.wallet.id);
|
||||
return 't/' + this.wallet.id + '/' + key;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -207,7 +204,7 @@ TXDB.prototype.commit = function commit(callback) {
|
||||
*/
|
||||
|
||||
TXDB.prototype.getInfo = function getInfo(tx, callback) {
|
||||
this.walletdb.getPathInfo(this.id, tx, callback);
|
||||
this.walletdb.getPathInfo(this.wallet.id, tx, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -61,7 +61,7 @@ function Wallet(db, options) {
|
||||
this.accountDepth = 0;
|
||||
this.token = constants.ZERO_HASH;
|
||||
this.tokenDepth = 0;
|
||||
this.tx = new TXDB(this.db);
|
||||
this.tx = new TXDB(this);
|
||||
|
||||
this.account = null;
|
||||
|
||||
@ -128,7 +128,6 @@ Wallet.prototype.fromOptions = function fromOptions(options) {
|
||||
|
||||
this.id = id;
|
||||
this.token = token;
|
||||
this.tx.id = this.id;
|
||||
|
||||
return this;
|
||||
};
|
||||
@ -1792,7 +1791,6 @@ Wallet.prototype.fromJSON = function fromJSON(json) {
|
||||
this.accountDepth = json.accountDepth;
|
||||
this.token = new Buffer(json.token, 'hex');
|
||||
this.master = MasterKey.fromJSON(json.master);
|
||||
this.tx.id = this.id;
|
||||
|
||||
return this;
|
||||
};
|
||||
@ -1834,7 +1832,6 @@ Wallet.prototype.fromRaw = function fromRaw(data) {
|
||||
this.token = p.readBytes(32);
|
||||
this.tokenDepth = p.readU32();
|
||||
this.master = MasterKey.fromRaw(p.readVarBytes());
|
||||
this.tx.id = this.id;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user