comments.

This commit is contained in:
Christopher Jeffrey 2016-02-24 20:54:39 -08:00
parent a8e6eda850
commit 27ecf6dde3

View File

@ -43,8 +43,8 @@ function Chain(options) {
this.pendingBlocks = {};
this.pendingSize = 0;
this.total = 0;
this.orphanLimit = options.orphanLimit || 10 * 1024 * 1024;
this.pendingLimit = options.pendingLimit || 10 * 1024 * 1024;
this.orphanLimit = options.orphanLimit || 20 * 1024 * 1024;
this.pendingLimit = options.pendingLimit || 20 * 1024 * 1024;
this.invalid = {};
this.bestHeight = -1;
this.lastUpdate = utils.now();
@ -1162,12 +1162,19 @@ Chain.prototype.add = function add(initial, peer, callback, force) {
assert(prev);
// Explanation: we try to keep as much data
// off the javascript heap as possible. Blocks
// in the future may be 8mb or 20mb, who knows.
// In fullnode-mode we store the blocks in
// "compact" form (the headers plus the raw
// Buffer object) until they're ready to be
// fully validated here. They are deserialized,
// validated, and emitted. Hopefully the deserialized
// blocks get cleaned up by the GC quickly.
if (block.type === 'compactblock') {
block = block.toBlock(peer);
if (!block)
return done(new Error('Failed to parse block.'));
if (block._raw === initial._raw)
initial = block;
}
// Do "contextual" verification on our block
@ -1281,7 +1288,7 @@ Chain.prototype.add = function add(initial, peer, callback, force) {
// Emit our block (and potentially resolved
// orphan) so the programmer can save it.
self.emit('block', block, entry, peer);
if (block !== initial)
if (block.hash('hex') !== initial.hash('hex'))
self.emit('resolved', block, entry, peer);
self.emit('add block', block);