config: rename useCheckpoints. allow implicit noAuth on localhost.

This commit is contained in:
Christopher Jeffrey 2017-01-23 03:19:19 -08:00
parent 2fdbdfc087
commit cbb45db801
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
9 changed files with 42 additions and 33 deletions

View File

@ -273,9 +273,7 @@ pool.open().then(function() {
var bcoin = require('bcoin').set('main');
var node = bcoin.fullnode({
prune: false,
useCheckpoints: true,
debug: true,
checkpoints: true,
// Primary wallet passphrase
passsphrase: 'node',
logLevel: 'info'

View File

@ -176,7 +176,7 @@ Chain.prototype._open = co(function* open() {
this.logger.info('Chain is loading.');
if (this.options.useCheckpoints)
if (this.options.checkpoints)
this.logger.info('Checkpoints are enabled.');
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,
* the tx values, and execute and verify the scripts (it
* 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.
* @private
* @see TX#checkInputs
@ -1344,7 +1344,7 @@ Chain.prototype.verifyCheckpoint = function verifyCheckpoint(prev, hash) {
var height = prev.height + 1;
var checkpoint;
if (!this.options.useCheckpoints)
if (!this.options.checkpoints)
return true;
checkpoint = this.network.checkpointMap[height];
@ -1682,7 +1682,7 @@ Chain.prototype.isFull = function isFull() {
*/
Chain.prototype.isInitial = function isInitial() {
if (this.options.useCheckpoints) {
if (this.options.checkpoints) {
if (this.height < this.network.lastCheckpoint)
return true;
}
@ -1716,7 +1716,7 @@ Chain.prototype.maybeSync = function maybeSync() {
*/
Chain.prototype.hasChainwork = function hasChainwork() {
if (this.options.useCheckpoints)
if (this.options.checkpoints)
return this.height >= this.network.lastCheckpoint;
return this.tip.chainwork.cmp(this.network.pow.chainwork) >= 0;
@ -2313,7 +2313,7 @@ function ChainOptions(options) {
this.coinCache = 0;
this.entryCache = (2016 + 1) * 2 + 100;
this.orphanLimit = 20 << 20;
this.useCheckpoints = false;
this.checkpoints = false;
if (options)
this.fromOptions(options);
@ -2405,9 +2405,9 @@ ChainOptions.prototype.fromOptions = function fromOptions(options) {
this.orphanLimit = options.orphanLimit;
}
if (options.useCheckpoints != null) {
assert(typeof options.useCheckpoints === 'boolean');
this.useCheckpoints = options.useCheckpoints;
if (options.checkpoints != null) {
assert(typeof options.checkpoints === 'boolean');
this.checkpoints = options.checkpoints;
}
return this;

View File

@ -353,7 +353,7 @@ ChainEntry.prototype.getMedianTimeAsync = co(function* getMedianTimeAsync() {
*/
ChainEntry.prototype.isHistorical = function isHistorical() {
if (this.chain.options.useCheckpoints) {
if (this.chain.options.checkpoints) {
if (this.height + 1 <= this.chain.network.lastCheckpoint)
return true;
}

View File

@ -10,11 +10,12 @@
/* jshint -W069 */
/* jshint noyield: true */
var EventEmitter = require('events').EventEmitter;
var assert = require('assert');
var EventEmitter = require('events').EventEmitter;
var HTTPBase = require('./base');
var util = require('../utils/util');
var co = require('../utils/co');
var IP = require('../utils/ip');
var base58 = require('../utils/base58');
var Amount = require('../btc/amount');
var Address = require('../primitives/address');
@ -1782,6 +1783,13 @@ HTTPOptions.prototype.fromOptions = function fromOptions(options) {
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;
};

View File

@ -689,7 +689,7 @@ Pool.prototype.resolveHeaders = function resolveHeaders(peer) {
Pool.prototype.getNextTip = function getNextTip(height) {
var i, next;
if (this.options.useCheckpoints) {
if (this.options.checkpoints) {
for (i = 0; i < this.network.checkpoints.length; i++) {
next = this.network.checkpoints[i];
if (next.height > height)
@ -1803,7 +1803,7 @@ Pool.prototype._handleHeaders = co(function* handleHeaders(peer, packet) {
node = new HeaderEntry(hash, height);
if (node.height === this.headerTip.height) {
if (this.options.useCheckpoints) {
if (this.options.checkpoints) {
if (node.hash !== this.headerTip.hash) {
this.logger.warning(
'Peer sent an invalid checkpoint (%s).',
@ -3164,7 +3164,7 @@ function PoolOptions(options) {
this.address = new NetAddress();
this.witness = true;
this.useCheckpoints = false;
this.checkpoints = false;
this.spv = false;
this.listen = false;
this.headers = false;
@ -3236,12 +3236,12 @@ PoolOptions.prototype.fromOptions = function fromOptions(options) {
this.witness = this.chain.options.witness;
}
if (options.useCheckpoints != null) {
assert(typeof options.useCheckpoints === 'boolean');
assert(options.useCheckpoints === this.chain.options.useCheckpoints);
this.useCheckpoints = options.useCheckpoints;
if (options.checkpoints != null) {
assert(typeof options.checkpoints === 'boolean');
assert(options.checkpoints === this.chain.options.checkpoints);
this.checkpoints = options.checkpoints;
} else {
this.useCheckpoints = this.chain.options.useCheckpoints;
this.checkpoints = this.chain.options.checkpoints;
}
if (options.spv != null) {

View File

@ -174,11 +174,14 @@ config.parseData = function parseData(data, prefix, dirname) {
options.witness = bool(data.witness);
options.forceWitness = bool(data.forcewitness);
options.prune = bool(data.prune);
options.useCheckpoints = bool(data.usecheckpoints);
options.checkpoints = bool(data.checkpoints);
options.coinCache = mul(data.coincache, 1024 * 1024);
options.indexTX = bool(data.indextx);
options.indexAddress = bool(data.indexaddress);
if (data.usecheckpoints != null)
options.checkpoints = bool(data.usecheckpoints);
// Mempool
options.limitFree = bool(data.limitfree);
options.limitFreeRelay = bool(data.limitfreerelay);
@ -235,7 +238,7 @@ config.parseData = function parseData(data, prefix, dirname) {
// Alias
if (options.fast) {
options.headers = true;
options.useCheckpoints = true;
options.checkpoints = true;
options.cacheSize = 200 << 20;
options.coinCache = 65 << 20;
}

View File

@ -69,7 +69,7 @@ function FullNode(options) {
witness: this.options.witness,
forceWitness: this.options.forceWitness,
prune: this.options.prune,
useCheckpoints: this.options.useCheckpoints,
checkpoints: this.options.checkpoints,
coinCache: this.options.coinCache,
indexTX: this.options.indexTX,
indexAddress: this.options.indexAddress
@ -142,7 +142,7 @@ function FullNode(options) {
maxFiles: this.options.walletMaxFiles,
cacheSize: this.options.walletCacheSize,
witness: false,
useCheckpoints: this.options.useCheckpoints,
checkpoints: this.options.checkpoints,
startHeight: this.options.startHeight,
wipeNoReally: this.options.wipeNoReally,
verify: false

View File

@ -53,7 +53,7 @@ function SPVNode(options) {
cacheSize: this.options.cacheSize,
witness: this.options.witness,
forceWitness: this.options.forceWitness,
useCheckpoints: this.options.useCheckpoints,
checkpoints: this.options.checkpoints,
spv: true
});
@ -85,7 +85,7 @@ function SPVNode(options) {
maxFiles: this.options.walletMaxFiles,
cacheSize: this.options.walletCacheSize,
witness: false,
useCheckpoints: this.options.useCheckpoints,
checkpoints: this.options.checkpoints,
startHeight: this.options.startHeight,
wipeNoReally: this.options.wipeNoReally,
verify: true,

View File

@ -1919,7 +1919,7 @@ WalletDB.prototype._addBlock = co(function* addBlock(entry, txs) {
// Sync the state to the new tip.
yield this.syncState(tip);
if (this.options.useCheckpoints) {
if (this.options.checkpoints) {
if (tip.height <= this.network.lastCheckpoint)
return total;
}
@ -2169,7 +2169,7 @@ function WalletOptions(options) {
this.spv = false;
this.witness = false;
this.useCheckpoints = false;
this.checkpoints = false;
this.startHeight = 0;
this.keepBlocks = this.network.block.keepBlocks;
this.wipeNoReally = false;
@ -2236,9 +2236,9 @@ WalletOptions.prototype.fromOptions = function fromOptions(options) {
this.witness = options.witness;
}
if (options.useCheckpoints != null) {
assert(typeof options.useCheckpoints === 'boolean');
this.useCheckpoints = options.useCheckpoints;
if (options.checkpoints != null) {
assert(typeof options.checkpoints === 'boolean');
this.checkpoints = options.checkpoints;
}
if (options.startHeight != null) {