chain: add genesis check.

This commit is contained in:
Christopher Jeffrey 2017-01-28 19:29:16 -08:00
parent 0f8fd1dc77
commit 5e1d8c743c
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1143,6 +1143,12 @@ Chain.prototype._add = co(function* add(block) {
// Mark the start time.
this.mark();
// Special case for genesis block.
if (hash === this.network.genesis.hash) {
this.emit('exists', block, block.getCoinbaseHeight());
throw new VerifyError(block, 'duplicate', 'duplicate', 0);
}
// Do we already have this block in the queue?
if (this.hasPending(hash)) {
this.emit('exists', block, block.getCoinbaseHeight());