fix buffertools in Transaction
This commit is contained in:
parent
3d901a12f2
commit
d2e7c7fc19
|
@ -11,7 +11,7 @@ function spec(b) {
|
||||||
var Put = b.Put || require('bufferput');
|
var Put = b.Put || require('bufferput');
|
||||||
var Parser = b.Parser || require('./util/BinaryParser').class();
|
var Parser = b.Parser || require('./util/BinaryParser').class();
|
||||||
var Step = b.Step || require('step');
|
var Step = b.Step || require('step');
|
||||||
var buffertools = require('buffertools');
|
var buffertools = b.buffertools || require('buffertools');
|
||||||
|
|
||||||
var error = b.error || require('./util/error');
|
var error = b.error || require('./util/error');
|
||||||
var VerificationError = error.VerificationError;
|
var VerificationError = error.VerificationError;
|
||||||
|
@ -29,14 +29,14 @@ function spec(b) {
|
||||||
this.s = Buffer.isBuffer(data.s) ? data.s :
|
this.s = Buffer.isBuffer(data.s) ? data.s :
|
||||||
Buffer.isBuffer(data.script) ? data.script : util.EMPTY_BUFFER;
|
Buffer.isBuffer(data.script) ? data.script : util.EMPTY_BUFFER;
|
||||||
this.q = data.q ? data.q : data.sequence;
|
this.q = data.q ? data.q : data.sequence;
|
||||||
};
|
}
|
||||||
|
|
||||||
TransactionIn.prototype.getScript = function getScript() {
|
TransactionIn.prototype.getScript = function getScript() {
|
||||||
return new Script(this.s);
|
return new Script(this.s);
|
||||||
};
|
};
|
||||||
|
|
||||||
TransactionIn.prototype.isCoinBase = function isCoinBase() {
|
TransactionIn.prototype.isCoinBase = function isCoinBase() {
|
||||||
return this.o.compare(COINBASE_OP) === 0;
|
return buffertools.compare(this.o, COINBASE_OP) === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
TransactionIn.prototype.serialize = function serialize() {
|
TransactionIn.prototype.serialize = function serialize() {
|
||||||
|
@ -153,11 +153,12 @@ function spec(b) {
|
||||||
bufs.push(txout.serialize());
|
bufs.push(txout.serialize());
|
||||||
});
|
});
|
||||||
|
|
||||||
var buf = new Buffer(4);
|
buf = new Buffer(4);
|
||||||
buf.writeUInt32LE(this.lock_time, 0);
|
buf.writeUInt32LE(this.lock_time, 0);
|
||||||
bufs.push(buf);
|
bufs.push(buf);
|
||||||
|
|
||||||
return this._buffer = Buffer.concat(bufs);
|
this._buffer = Buffer.concat(bufs);
|
||||||
|
return this._buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.getBuffer = function getBuffer() {
|
Transaction.prototype.getBuffer = function getBuffer() {
|
||||||
|
@ -174,7 +175,7 @@ function spec(b) {
|
||||||
Transaction.prototype.checkHash = function checkHash() {
|
Transaction.prototype.checkHash = function checkHash() {
|
||||||
if (!this.hash || !this.hash.length) return false;
|
if (!this.hash || !this.hash.length) return false;
|
||||||
|
|
||||||
return this.calcHash().compare(this.hash) == 0;
|
return buffertools.compare(this.calcHash(), this.hash) === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.getHash = function getHash() {
|
Transaction.prototype.getHash = function getHash() {
|
||||||
|
@ -315,7 +316,7 @@ function spec(b) {
|
||||||
// Spent output detected, retrieve transaction that spends it
|
// Spent output detected, retrieve transaction that spends it
|
||||||
blockChain.getConflictingTransactions(outpoints, function (err, results) {
|
blockChain.getConflictingTransactions(outpoints, function (err, results) {
|
||||||
if (results.length) {
|
if (results.length) {
|
||||||
if (results[0].getHash().compare(self.getHash()) == 0) {
|
if (buffertools.compare(results[0].getHash(), self.getHash()) === 0) {
|
||||||
log.warn("Detected tx re-add (recoverable db corruption): "
|
log.warn("Detected tx re-add (recoverable db corruption): "
|
||||||
+ util.formatHashAlt(results[0].getHash()));
|
+ util.formatHashAlt(results[0].getHash()));
|
||||||
// TODO: Needs to return an error for the memory pool case?
|
// TODO: Needs to return an error for the memory pool case?
|
||||||
|
|
Loading…
Reference in New Issue