diff --git a/lib/wallet/plugin.js b/lib/wallet/plugin.js index 847e9364..4cd4ec25 100644 --- a/lib/wallet/plugin.js +++ b/lib/wallet/plugin.js @@ -71,7 +71,6 @@ function Plugin(node) { Object.setPrototypeOf(Plugin.prototype, EventEmitter.prototype); Plugin.prototype.init = function init() { - this.client.on('error', err => this.emit('error', err)); this.wdb.on('error', err => this.emit('error', err)); this.http.on('error', err => this.emit('error', err)); }; diff --git a/lib/wallet/server.js b/lib/wallet/server.js index ecbb55aa..162aa79f 100644 --- a/lib/wallet/server.js +++ b/lib/wallet/server.js @@ -77,7 +77,6 @@ Object.setPrototypeOf(WalletNode.prototype, Node.prototype); */ WalletNode.prototype._init = function _init() { - this.client.on('error', err => this.error(err)); this.wdb.on('error', err => this.error(err)); this.http.on('error', err => this.error(err)); diff --git a/lib/wallet/walletdb.js b/lib/wallet/walletdb.js index ce7f1939..193b65c7 100644 --- a/lib/wallet/walletdb.js +++ b/lib/wallet/walletdb.js @@ -176,16 +176,16 @@ WalletDB.prototype.load = async function load() { }; /** - * Initialize state with server on every connect. + * Sync state with server on every connect. * @returns {Promise} */ -WalletDB.prototype.resync = async function resync() { +WalletDB.prototype.syncNode = async function syncNode() { const unlock = await this.txLock.lock(); try { this.logger.info('Resyncing from server...'); await this.setFilter(); - await this.sync(); + await this.syncChain(); await this.resend(); } finally { unlock(); @@ -212,7 +212,7 @@ WalletDB.prototype.bind = function bind() { this.client.on('open', async () => { try { - await this.resync(); + await this.syncNode(); } catch (e) { this.emit('error', e); } @@ -385,7 +385,7 @@ WalletDB.prototype.watch = async function watch() { * @returns {Promise} */ -WalletDB.prototype.sync = async function sync() { +WalletDB.prototype.syncChain = async function syncChain() { if (!this.client) return; @@ -1415,7 +1415,7 @@ WalletDB.prototype.getState = async function getState() { * @returns {Promise} */ -WalletDB.prototype.syncState = async function syncState(tip) { +WalletDB.prototype.syncTip = async function syncTip(tip) { const b = this.db.batch(); const state = this.state.clone(); @@ -1722,7 +1722,7 @@ WalletDB.prototype.rollback = async function rollback(height) { assert(tip); await this.revert(tip.height); - await this.syncState(tip); + await this.syncTip(tip); }; /** @@ -1804,7 +1804,7 @@ WalletDB.prototype._addBlock = async function _addBlock(entry, txs) { } // Sync the state to the new tip. - await this.syncState(tip); + await this.syncTip(tip); if (this.options.checkpoints) { if (tip.height <= this.network.lastCheckpoint) @@ -1872,7 +1872,7 @@ WalletDB.prototype._removeBlock = async function _removeBlock(entry) { const map = await this.getBlockMap(tip.height); if (!map) { - await this.syncState(prev); + await this.syncTip(prev); return 0; } @@ -1885,7 +1885,7 @@ WalletDB.prototype._removeBlock = async function _removeBlock(entry) { } // Sync the state to the previous tip. - await this.syncState(prev); + await this.syncTip(prev); this.logger.warning('Disconnected wallet block %s (tx=%d).', util.revHex(tip.hash), total);