add connect method.
This commit is contained in:
parent
ecaec7b5d9
commit
3f0ac32334
3
bin/node
3
bin/node
@ -20,8 +20,9 @@ node.open(function(err) {
|
|||||||
if (err)
|
if (err)
|
||||||
throw err;
|
throw err;
|
||||||
|
|
||||||
node.startSync();
|
|
||||||
|
|
||||||
if (node.options.mine)
|
if (node.options.mine)
|
||||||
node.miner.start();
|
node.miner.start();
|
||||||
|
else
|
||||||
|
node.startSync();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -127,7 +127,7 @@ Chain.prototype._init = function _init() {
|
|||||||
|
|
||||||
this.on('invalid', function(block, data) {
|
this.on('invalid', function(block, data) {
|
||||||
utils.debug(
|
utils.debug(
|
||||||
'Invalid block at height %d: hash=%s',
|
'Invalid block at height %d: hash=%s (%s)',
|
||||||
data.height,
|
data.height,
|
||||||
utils.revHex(data.hash),
|
utils.revHex(data.hash),
|
||||||
getHost()
|
getHost()
|
||||||
|
|||||||
@ -194,6 +194,10 @@ Fullnode.prototype.sendBlock = function sendBlock(item, callback) {
|
|||||||
return this.pool.sendBlock(item, callback);
|
return this.pool.sendBlock(item, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Fullnode.prototype.connect = function connect() {
|
||||||
|
return this.pool.connect();
|
||||||
|
};
|
||||||
|
|
||||||
Fullnode.prototype.startSync = function startSync() {
|
Fullnode.prototype.startSync = function startSync() {
|
||||||
return this.pool.startSync();
|
return this.pool.startSync();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -362,7 +362,7 @@ Miner.prototype.iterate = function iterate() {
|
|||||||
if (err.type === 'VerifyError')
|
if (err.type === 'VerifyError')
|
||||||
utils.debug('Miner: %s could not be added to chain.', self.block.rhash);
|
utils.debug('Miner: %s could not be added to chain.', self.block.rhash);
|
||||||
self.emit('error', err);
|
self.emit('error', err);
|
||||||
return self.iterate();
|
return self.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit our newly found block
|
// Emit our newly found block
|
||||||
|
|||||||
@ -165,9 +165,11 @@ Pool.prototype.open = function open(callback) {
|
|||||||
this.once('open', callback);
|
this.once('open', callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype._init = function _init() {
|
Pool.prototype.connect = function connect() {
|
||||||
var self = this;
|
assert(this.loaded, 'Pool is not loaded.');
|
||||||
var i;
|
|
||||||
|
if (this.connected)
|
||||||
|
return;
|
||||||
|
|
||||||
if (this.originalSeeds.length > 0) {
|
if (this.originalSeeds.length > 0) {
|
||||||
this._addLoader();
|
this._addLoader();
|
||||||
@ -178,6 +180,13 @@ Pool.prototype._init = function _init() {
|
|||||||
this.connected = true;
|
this.connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.startServer();
|
||||||
|
};
|
||||||
|
|
||||||
|
Pool.prototype._init = function _init() {
|
||||||
|
var self = this;
|
||||||
|
var i;
|
||||||
|
|
||||||
this.chain.on('block', function(block, entry, peer) {
|
this.chain.on('block', function(block, entry, peer) {
|
||||||
// Emit merkle txs after the fact
|
// Emit merkle txs after the fact
|
||||||
if (block.type === 'merkleblock') {
|
if (block.type === 'merkleblock') {
|
||||||
@ -224,8 +233,6 @@ Pool.prototype._init = function _init() {
|
|||||||
(this.options.wallets || []).forEach(function(wallet) {
|
(this.options.wallets || []).forEach(function(wallet) {
|
||||||
self.addWallet(wallet);
|
self.addWallet(wallet);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.startServer();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype.getBlocks = function getBlocks(peer, top, stop, callback) {
|
Pool.prototype.getBlocks = function getBlocks(peer, top, stop, callback) {
|
||||||
@ -510,6 +517,8 @@ Pool.prototype.startSync = function startSync() {
|
|||||||
this._startInterval();
|
this._startInterval();
|
||||||
this._startTimer();
|
this._startTimer();
|
||||||
|
|
||||||
|
this.connect();
|
||||||
|
|
||||||
if (!this.peers.load) {
|
if (!this.peers.load) {
|
||||||
this._addLoader();
|
this._addLoader();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -150,6 +150,10 @@ SPVNode.prototype.sendBlock = function sendBlock(item, callback) {
|
|||||||
return this.pool.sendBlock(item, callback);
|
return this.pool.sendBlock(item, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SPVNode.prototype.connect = function connect() {
|
||||||
|
return this.pool.connect();
|
||||||
|
};
|
||||||
|
|
||||||
SPVNode.prototype.startSync = function startSync() {
|
SPVNode.prototype.startSync = function startSync() {
|
||||||
return this.pool.startSync();
|
return this.pool.startSync();
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user