config: rename useCheckpoints. allow implicit noAuth on localhost.
This commit is contained in:
parent
2fdbdfc087
commit
cbb45db801
@ -273,9 +273,7 @@ pool.open().then(function() {
|
|||||||
var bcoin = require('bcoin').set('main');
|
var bcoin = require('bcoin').set('main');
|
||||||
|
|
||||||
var node = bcoin.fullnode({
|
var node = bcoin.fullnode({
|
||||||
prune: false,
|
checkpoints: true,
|
||||||
useCheckpoints: true,
|
|
||||||
debug: true,
|
|
||||||
// Primary wallet passphrase
|
// Primary wallet passphrase
|
||||||
passsphrase: 'node',
|
passsphrase: 'node',
|
||||||
logLevel: 'info'
|
logLevel: 'info'
|
||||||
|
|||||||
@ -176,7 +176,7 @@ Chain.prototype._open = co(function* open() {
|
|||||||
|
|
||||||
this.logger.info('Chain is loading.');
|
this.logger.info('Chain is loading.');
|
||||||
|
|
||||||
if (this.options.useCheckpoints)
|
if (this.options.checkpoints)
|
||||||
this.logger.info('Checkpoints are enabled.');
|
this.logger.info('Checkpoints are enabled.');
|
||||||
|
|
||||||
if (this.options.coinCache)
|
if (this.options.coinCache)
|
||||||
@ -566,7 +566,7 @@ Chain.prototype.verifyDuplicates = co(function* verifyDuplicates(block, prev, st
|
|||||||
* function will check the block reward, the sigops,
|
* function will check the block reward, the sigops,
|
||||||
* the tx values, and execute and verify the scripts (it
|
* the tx values, and execute and verify the scripts (it
|
||||||
* will attempt to do this on the worker pool). If
|
* will attempt to do this on the worker pool). If
|
||||||
* useCheckpoints is enabled, it will skip verification
|
* `checkpoints` is enabled, it will skip verification
|
||||||
* for historical data.
|
* for historical data.
|
||||||
* @private
|
* @private
|
||||||
* @see TX#checkInputs
|
* @see TX#checkInputs
|
||||||
@ -1344,7 +1344,7 @@ Chain.prototype.verifyCheckpoint = function verifyCheckpoint(prev, hash) {
|
|||||||
var height = prev.height + 1;
|
var height = prev.height + 1;
|
||||||
var checkpoint;
|
var checkpoint;
|
||||||
|
|
||||||
if (!this.options.useCheckpoints)
|
if (!this.options.checkpoints)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
checkpoint = this.network.checkpointMap[height];
|
checkpoint = this.network.checkpointMap[height];
|
||||||
@ -1682,7 +1682,7 @@ Chain.prototype.isFull = function isFull() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Chain.prototype.isInitial = function isInitial() {
|
Chain.prototype.isInitial = function isInitial() {
|
||||||
if (this.options.useCheckpoints) {
|
if (this.options.checkpoints) {
|
||||||
if (this.height < this.network.lastCheckpoint)
|
if (this.height < this.network.lastCheckpoint)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1716,7 +1716,7 @@ Chain.prototype.maybeSync = function maybeSync() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Chain.prototype.hasChainwork = function hasChainwork() {
|
Chain.prototype.hasChainwork = function hasChainwork() {
|
||||||
if (this.options.useCheckpoints)
|
if (this.options.checkpoints)
|
||||||
return this.height >= this.network.lastCheckpoint;
|
return this.height >= this.network.lastCheckpoint;
|
||||||
|
|
||||||
return this.tip.chainwork.cmp(this.network.pow.chainwork) >= 0;
|
return this.tip.chainwork.cmp(this.network.pow.chainwork) >= 0;
|
||||||
@ -2313,7 +2313,7 @@ function ChainOptions(options) {
|
|||||||
this.coinCache = 0;
|
this.coinCache = 0;
|
||||||
this.entryCache = (2016 + 1) * 2 + 100;
|
this.entryCache = (2016 + 1) * 2 + 100;
|
||||||
this.orphanLimit = 20 << 20;
|
this.orphanLimit = 20 << 20;
|
||||||
this.useCheckpoints = false;
|
this.checkpoints = false;
|
||||||
|
|
||||||
if (options)
|
if (options)
|
||||||
this.fromOptions(options);
|
this.fromOptions(options);
|
||||||
@ -2405,9 +2405,9 @@ ChainOptions.prototype.fromOptions = function fromOptions(options) {
|
|||||||
this.orphanLimit = options.orphanLimit;
|
this.orphanLimit = options.orphanLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.useCheckpoints != null) {
|
if (options.checkpoints != null) {
|
||||||
assert(typeof options.useCheckpoints === 'boolean');
|
assert(typeof options.checkpoints === 'boolean');
|
||||||
this.useCheckpoints = options.useCheckpoints;
|
this.checkpoints = options.checkpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@ -353,7 +353,7 @@ ChainEntry.prototype.getMedianTimeAsync = co(function* getMedianTimeAsync() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ChainEntry.prototype.isHistorical = function isHistorical() {
|
ChainEntry.prototype.isHistorical = function isHistorical() {
|
||||||
if (this.chain.options.useCheckpoints) {
|
if (this.chain.options.checkpoints) {
|
||||||
if (this.height + 1 <= this.chain.network.lastCheckpoint)
|
if (this.height + 1 <= this.chain.network.lastCheckpoint)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,11 +10,12 @@
|
|||||||
/* jshint -W069 */
|
/* jshint -W069 */
|
||||||
/* jshint noyield: true */
|
/* jshint noyield: true */
|
||||||
|
|
||||||
var EventEmitter = require('events').EventEmitter;
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var HTTPBase = require('./base');
|
var HTTPBase = require('./base');
|
||||||
var util = require('../utils/util');
|
var util = require('../utils/util');
|
||||||
var co = require('../utils/co');
|
var co = require('../utils/co');
|
||||||
|
var IP = require('../utils/ip');
|
||||||
var base58 = require('../utils/base58');
|
var base58 = require('../utils/base58');
|
||||||
var Amount = require('../btc/amount');
|
var Amount = require('../btc/amount');
|
||||||
var Address = require('../primitives/address');
|
var Address = require('../primitives/address');
|
||||||
@ -1782,6 +1783,13 @@ HTTPOptions.prototype.fromOptions = function fromOptions(options) {
|
|||||||
this.ca = options.ca;
|
this.ca = options.ca;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow no-auth implicitly
|
||||||
|
// if we're listening locally.
|
||||||
|
if (!options.apiKey && !options.serviceKey) {
|
||||||
|
if (IP.isLoopback(this.host))
|
||||||
|
this.noAuth = true;
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -689,7 +689,7 @@ Pool.prototype.resolveHeaders = function resolveHeaders(peer) {
|
|||||||
Pool.prototype.getNextTip = function getNextTip(height) {
|
Pool.prototype.getNextTip = function getNextTip(height) {
|
||||||
var i, next;
|
var i, next;
|
||||||
|
|
||||||
if (this.options.useCheckpoints) {
|
if (this.options.checkpoints) {
|
||||||
for (i = 0; i < this.network.checkpoints.length; i++) {
|
for (i = 0; i < this.network.checkpoints.length; i++) {
|
||||||
next = this.network.checkpoints[i];
|
next = this.network.checkpoints[i];
|
||||||
if (next.height > height)
|
if (next.height > height)
|
||||||
@ -1803,7 +1803,7 @@ Pool.prototype._handleHeaders = co(function* handleHeaders(peer, packet) {
|
|||||||
node = new HeaderEntry(hash, height);
|
node = new HeaderEntry(hash, height);
|
||||||
|
|
||||||
if (node.height === this.headerTip.height) {
|
if (node.height === this.headerTip.height) {
|
||||||
if (this.options.useCheckpoints) {
|
if (this.options.checkpoints) {
|
||||||
if (node.hash !== this.headerTip.hash) {
|
if (node.hash !== this.headerTip.hash) {
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
'Peer sent an invalid checkpoint (%s).',
|
'Peer sent an invalid checkpoint (%s).',
|
||||||
@ -3164,7 +3164,7 @@ function PoolOptions(options) {
|
|||||||
this.address = new NetAddress();
|
this.address = new NetAddress();
|
||||||
|
|
||||||
this.witness = true;
|
this.witness = true;
|
||||||
this.useCheckpoints = false;
|
this.checkpoints = false;
|
||||||
this.spv = false;
|
this.spv = false;
|
||||||
this.listen = false;
|
this.listen = false;
|
||||||
this.headers = false;
|
this.headers = false;
|
||||||
@ -3236,12 +3236,12 @@ PoolOptions.prototype.fromOptions = function fromOptions(options) {
|
|||||||
this.witness = this.chain.options.witness;
|
this.witness = this.chain.options.witness;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.useCheckpoints != null) {
|
if (options.checkpoints != null) {
|
||||||
assert(typeof options.useCheckpoints === 'boolean');
|
assert(typeof options.checkpoints === 'boolean');
|
||||||
assert(options.useCheckpoints === this.chain.options.useCheckpoints);
|
assert(options.checkpoints === this.chain.options.checkpoints);
|
||||||
this.useCheckpoints = options.useCheckpoints;
|
this.checkpoints = options.checkpoints;
|
||||||
} else {
|
} else {
|
||||||
this.useCheckpoints = this.chain.options.useCheckpoints;
|
this.checkpoints = this.chain.options.checkpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.spv != null) {
|
if (options.spv != null) {
|
||||||
|
|||||||
@ -174,11 +174,14 @@ config.parseData = function parseData(data, prefix, dirname) {
|
|||||||
options.witness = bool(data.witness);
|
options.witness = bool(data.witness);
|
||||||
options.forceWitness = bool(data.forcewitness);
|
options.forceWitness = bool(data.forcewitness);
|
||||||
options.prune = bool(data.prune);
|
options.prune = bool(data.prune);
|
||||||
options.useCheckpoints = bool(data.usecheckpoints);
|
options.checkpoints = bool(data.checkpoints);
|
||||||
options.coinCache = mul(data.coincache, 1024 * 1024);
|
options.coinCache = mul(data.coincache, 1024 * 1024);
|
||||||
options.indexTX = bool(data.indextx);
|
options.indexTX = bool(data.indextx);
|
||||||
options.indexAddress = bool(data.indexaddress);
|
options.indexAddress = bool(data.indexaddress);
|
||||||
|
|
||||||
|
if (data.usecheckpoints != null)
|
||||||
|
options.checkpoints = bool(data.usecheckpoints);
|
||||||
|
|
||||||
// Mempool
|
// Mempool
|
||||||
options.limitFree = bool(data.limitfree);
|
options.limitFree = bool(data.limitfree);
|
||||||
options.limitFreeRelay = bool(data.limitfreerelay);
|
options.limitFreeRelay = bool(data.limitfreerelay);
|
||||||
@ -235,7 +238,7 @@ config.parseData = function parseData(data, prefix, dirname) {
|
|||||||
// Alias
|
// Alias
|
||||||
if (options.fast) {
|
if (options.fast) {
|
||||||
options.headers = true;
|
options.headers = true;
|
||||||
options.useCheckpoints = true;
|
options.checkpoints = true;
|
||||||
options.cacheSize = 200 << 20;
|
options.cacheSize = 200 << 20;
|
||||||
options.coinCache = 65 << 20;
|
options.coinCache = 65 << 20;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,7 @@ function FullNode(options) {
|
|||||||
witness: this.options.witness,
|
witness: this.options.witness,
|
||||||
forceWitness: this.options.forceWitness,
|
forceWitness: this.options.forceWitness,
|
||||||
prune: this.options.prune,
|
prune: this.options.prune,
|
||||||
useCheckpoints: this.options.useCheckpoints,
|
checkpoints: this.options.checkpoints,
|
||||||
coinCache: this.options.coinCache,
|
coinCache: this.options.coinCache,
|
||||||
indexTX: this.options.indexTX,
|
indexTX: this.options.indexTX,
|
||||||
indexAddress: this.options.indexAddress
|
indexAddress: this.options.indexAddress
|
||||||
@ -142,7 +142,7 @@ function FullNode(options) {
|
|||||||
maxFiles: this.options.walletMaxFiles,
|
maxFiles: this.options.walletMaxFiles,
|
||||||
cacheSize: this.options.walletCacheSize,
|
cacheSize: this.options.walletCacheSize,
|
||||||
witness: false,
|
witness: false,
|
||||||
useCheckpoints: this.options.useCheckpoints,
|
checkpoints: this.options.checkpoints,
|
||||||
startHeight: this.options.startHeight,
|
startHeight: this.options.startHeight,
|
||||||
wipeNoReally: this.options.wipeNoReally,
|
wipeNoReally: this.options.wipeNoReally,
|
||||||
verify: false
|
verify: false
|
||||||
|
|||||||
@ -53,7 +53,7 @@ function SPVNode(options) {
|
|||||||
cacheSize: this.options.cacheSize,
|
cacheSize: this.options.cacheSize,
|
||||||
witness: this.options.witness,
|
witness: this.options.witness,
|
||||||
forceWitness: this.options.forceWitness,
|
forceWitness: this.options.forceWitness,
|
||||||
useCheckpoints: this.options.useCheckpoints,
|
checkpoints: this.options.checkpoints,
|
||||||
spv: true
|
spv: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ function SPVNode(options) {
|
|||||||
maxFiles: this.options.walletMaxFiles,
|
maxFiles: this.options.walletMaxFiles,
|
||||||
cacheSize: this.options.walletCacheSize,
|
cacheSize: this.options.walletCacheSize,
|
||||||
witness: false,
|
witness: false,
|
||||||
useCheckpoints: this.options.useCheckpoints,
|
checkpoints: this.options.checkpoints,
|
||||||
startHeight: this.options.startHeight,
|
startHeight: this.options.startHeight,
|
||||||
wipeNoReally: this.options.wipeNoReally,
|
wipeNoReally: this.options.wipeNoReally,
|
||||||
verify: true,
|
verify: true,
|
||||||
|
|||||||
@ -1919,7 +1919,7 @@ WalletDB.prototype._addBlock = co(function* addBlock(entry, txs) {
|
|||||||
// Sync the state to the new tip.
|
// Sync the state to the new tip.
|
||||||
yield this.syncState(tip);
|
yield this.syncState(tip);
|
||||||
|
|
||||||
if (this.options.useCheckpoints) {
|
if (this.options.checkpoints) {
|
||||||
if (tip.height <= this.network.lastCheckpoint)
|
if (tip.height <= this.network.lastCheckpoint)
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@ -2169,7 +2169,7 @@ function WalletOptions(options) {
|
|||||||
|
|
||||||
this.spv = false;
|
this.spv = false;
|
||||||
this.witness = false;
|
this.witness = false;
|
||||||
this.useCheckpoints = false;
|
this.checkpoints = false;
|
||||||
this.startHeight = 0;
|
this.startHeight = 0;
|
||||||
this.keepBlocks = this.network.block.keepBlocks;
|
this.keepBlocks = this.network.block.keepBlocks;
|
||||||
this.wipeNoReally = false;
|
this.wipeNoReally = false;
|
||||||
@ -2236,9 +2236,9 @@ WalletOptions.prototype.fromOptions = function fromOptions(options) {
|
|||||||
this.witness = options.witness;
|
this.witness = options.witness;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.useCheckpoints != null) {
|
if (options.checkpoints != null) {
|
||||||
assert(typeof options.useCheckpoints === 'boolean');
|
assert(typeof options.checkpoints === 'boolean');
|
||||||
this.useCheckpoints = options.useCheckpoints;
|
this.checkpoints = options.checkpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.startHeight != null) {
|
if (options.startHeight != null) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user