wallet: rename some methods.

This commit is contained in:
Christopher Jeffrey 2017-10-27 20:30:23 -07:00
parent eaf2fa5ea2
commit aedbe27b6e
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 10 additions and 12 deletions

View File

@ -71,7 +71,6 @@ function Plugin(node) {
Object.setPrototypeOf(Plugin.prototype, EventEmitter.prototype); Object.setPrototypeOf(Plugin.prototype, EventEmitter.prototype);
Plugin.prototype.init = function init() { Plugin.prototype.init = function init() {
this.client.on('error', err => this.emit('error', err));
this.wdb.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)); this.http.on('error', err => this.emit('error', err));
}; };

View File

@ -77,7 +77,6 @@ Object.setPrototypeOf(WalletNode.prototype, Node.prototype);
*/ */
WalletNode.prototype._init = function _init() { WalletNode.prototype._init = function _init() {
this.client.on('error', err => this.error(err));
this.wdb.on('error', err => this.error(err)); this.wdb.on('error', err => this.error(err));
this.http.on('error', err => this.error(err)); this.http.on('error', err => this.error(err));

View File

@ -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} * @returns {Promise}
*/ */
WalletDB.prototype.resync = async function resync() { WalletDB.prototype.syncNode = async function syncNode() {
const unlock = await this.txLock.lock(); const unlock = await this.txLock.lock();
try { try {
this.logger.info('Resyncing from server...'); this.logger.info('Resyncing from server...');
await this.setFilter(); await this.setFilter();
await this.sync(); await this.syncChain();
await this.resend(); await this.resend();
} finally { } finally {
unlock(); unlock();
@ -212,7 +212,7 @@ WalletDB.prototype.bind = function bind() {
this.client.on('open', async () => { this.client.on('open', async () => {
try { try {
await this.resync(); await this.syncNode();
} catch (e) { } catch (e) {
this.emit('error', e); this.emit('error', e);
} }
@ -385,7 +385,7 @@ WalletDB.prototype.watch = async function watch() {
* @returns {Promise} * @returns {Promise}
*/ */
WalletDB.prototype.sync = async function sync() { WalletDB.prototype.syncChain = async function syncChain() {
if (!this.client) if (!this.client)
return; return;
@ -1415,7 +1415,7 @@ WalletDB.prototype.getState = async function getState() {
* @returns {Promise} * @returns {Promise}
*/ */
WalletDB.prototype.syncState = async function syncState(tip) { WalletDB.prototype.syncTip = async function syncTip(tip) {
const b = this.db.batch(); const b = this.db.batch();
const state = this.state.clone(); const state = this.state.clone();
@ -1722,7 +1722,7 @@ WalletDB.prototype.rollback = async function rollback(height) {
assert(tip); assert(tip);
await this.revert(tip.height); 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. // Sync the state to the new tip.
await this.syncState(tip); await this.syncTip(tip);
if (this.options.checkpoints) { if (this.options.checkpoints) {
if (tip.height <= this.network.lastCheckpoint) if (tip.height <= this.network.lastCheckpoint)
@ -1872,7 +1872,7 @@ WalletDB.prototype._removeBlock = async function _removeBlock(entry) {
const map = await this.getBlockMap(tip.height); const map = await this.getBlockMap(tip.height);
if (!map) { if (!map) {
await this.syncState(prev); await this.syncTip(prev);
return 0; return 0;
} }
@ -1885,7 +1885,7 @@ WalletDB.prototype._removeBlock = async function _removeBlock(entry) {
} }
// Sync the state to the previous tip. // Sync the state to the previous tip.
await this.syncState(prev); await this.syncTip(prev);
this.logger.warning('Disconnected wallet block %s (tx=%d).', this.logger.warning('Disconnected wallet block %s (tx=%d).',
util.revHex(tip.hash), total); util.revHex(tip.hash), total);