This commit is contained in:
Christopher Jeffrey 2016-01-08 16:47:23 -08:00
parent d56f7a3733
commit 8087601a7f
2 changed files with 19 additions and 10 deletions

View File

@ -52,11 +52,12 @@ function Chain(options) {
this.fromJSON(require('./protocol/preload-full'));
this.storage = null;
//this.resetHeight(133000);
//this.resetHeight(145000);
this.resetHeight(350000);
if (0)
// this.resetHeight(133000);
// this.resetHeight(145000);
// this.resetHeight(350000);
// if (0)
this.fromJSON({
v: 2,
type: 'chain',
@ -73,6 +74,7 @@ function Chain(options) {
]
});
// if (0)
if (!this.options.fullNode)
this.fromJSON(network.preload);
@ -281,7 +283,7 @@ Chain.prototype.resetTime = function resetTime(ts) {
Chain.prototype.add = function add(block, peer) {
var initial = block;
var code = Chain.codes.unchanged;
var hash, prevHash, prevHeight, entry;
var hash, prevHash, prevHeight, entry, tip;
if (this.loading) {
this.once('load', function() {
@ -351,22 +353,29 @@ Chain.prototype.add = function add(block, peer) {
code = Chain.codes.unchanged;
break;
}
// Get _our_ tip as opposed to
// the attempted alternate tip.
tip = this.index.entries[entry.height];
// The block has equal chainwork (an
// alternate tip). Reset the chain, find
// a new peer, and wait to see who wins.
this.resetHeight(entry.height - 1);
this.emit('fork', entry.height, entry.hash);
this.emit('fork', {
height: prevHeight + 1,
blocks: [tip.hash, entry.hash],
checkpoint: null
});
code = Chain.codes.forked;
break;
}
// Do "contextual" verification on our block
// now that we're certain it's previous
// now that we're certain its previous
// block is in the chain.
if (!block.postVerify()) {
throw new Error;
//code = Chain.codes.invalid;
//break;
code = Chain.codes.invalid;
break;
}
// Attempt to add block to the chain index.

View File

@ -592,7 +592,7 @@ HDPublicKey.prototype.deriveString = function deriveString(path) {
};
HD.prototype.getPrivate = function getPrivate() {
return this.pair.getPublic.apply(this.pair, arguments);
return this.pair.getPrivate.apply(this.pair, arguments);
};
HD.prototype.sign = function sign(msg) {