btc: refactor verify error.
This commit is contained in:
parent
ef1eb23ea3
commit
2f543ea465
@ -39,25 +39,21 @@ function VerifyError(msg, code, reason, score) {
|
|||||||
|
|
||||||
this.type = 'VerifyError';
|
this.type = 'VerifyError';
|
||||||
|
|
||||||
|
assert(typeof code === 'string');
|
||||||
|
asssert(typeof reason === 'string');
|
||||||
|
assert(score >= 0);
|
||||||
|
|
||||||
this.hash = msg.hash();
|
this.hash = msg.hash();
|
||||||
this.height = msg.height;
|
this.malleated = false;
|
||||||
|
|
||||||
if (msg.getCoinbaseHeight && this.height === -1)
|
|
||||||
this.height = msg.getCoinbaseHeight();
|
|
||||||
|
|
||||||
if (score == null)
|
|
||||||
score = -1;
|
|
||||||
|
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.reason = score === -1 ? null : reason;
|
this.reason = reason;
|
||||||
this.score = score;
|
this.score = score;
|
||||||
this.malleated = false;
|
|
||||||
this.message = 'Verification failure: '
|
this.message = 'Verification failure: ' + reason
|
||||||
+ reason
|
+ ' (code=' + code + ', score=' + score
|
||||||
+ ' (code=' + code
|
+ ', hash=' + util.revHex(this.hash.toString('hex'))
|
||||||
+ ', score=' + score
|
+ ')';
|
||||||
+ ', height=' + this.height
|
|
||||||
+ ', hash=' + util.revHex(this.hash.toString('hex')) + ')';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
util.inherits(VerifyError, Error);
|
util.inherits(VerifyError, Error);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user