Skip to content

Commit

Permalink
feat(Node): use blockchain checkpoints by default
Browse files Browse the repository at this point in the history
By default, supply a recent checkpoint when creating a Blockchain, in order to speed up the initial sync.
  • Loading branch information
mappum committed Jun 2, 2015
1 parent 611858b commit bbc89f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ module.exports = {
nonce: 414098458
})
},
checkpoints: {
livenet: {
height: 359000,
header: new bitcore.BlockHeader({
version: 3,
prevHash: u.toHash('000000000000000006ecee94daaa034bbd026cad52a9d3c6a5b7972716e5d566'),
merkleRoot: u.toHash('1e24b829d04e8e6fcb71fa0de364d6c0fa952c1cdb5fad446cf2a94dd203867a'),
time: 1433195458,
bits: 0x18171a8b,
nonce: 3020402664
})
},
testnet: {
height: 446000,
header: new bitcore.BlockHeader({
version: 3,
prevHash: u.toHash('00000000003d7bfe7baf59981a749017112b8018f0977356a3a21ea81a04d79d'),
merkleRoot: u.toHash('8a5829f9ac43b54819a02e44b2754458179de46c748f2d110bf97a0b02595267'),
time: 1432987428,
bits: 0x1a3fffc0,
nonce: 3771678460
})
}
},
maxTarget: new BN('ffff0000000000000000000000000000000000000000000000000000', 'hex'),
zeroHash: new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
timestampThreshold: 500000000,
Expand Down
4 changes: 3 additions & 1 deletion lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var PeerGroup = require('./peerGroup.js')
var BlockStream = require('../lib/blockStream.js')
var TransactionStream = require('../lib/transactionStream.js')
var Wallet = require('../lib/wallet.js')
var constants = require('../lib/constants.js')

var Node = module.exports = function (opts, cb) {
var self = this
Expand All @@ -30,7 +31,8 @@ var Node = module.exports = function (opts, cb) {
peerGroup: this.peers,
path: this.path + '/' + (opts.chainPath || this.network.name + '.chain'),
store: opts.chainStore,
to: opts.to
to: opts.to,
checkpoint: constants.checkpoints[this.network.name]
})
this.chain.on('error', this._error.bind(this))

Expand Down

0 comments on commit bbc89f5

Please sign in to comment.