remove _changed as it had no meaning
This commit is contained in:
parent
d85c4c9b9b
commit
5a60a03066
@ -47,8 +47,6 @@ class Transaction {
|
|||||||
this._id = null
|
this._id = null
|
||||||
this._buffer = null
|
this._buffer = null
|
||||||
this._hex = null
|
this._hex = null
|
||||||
|
|
||||||
this._changed = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get DEFAULT_SEQUENCE () { return 0xffffffff }
|
static get DEFAULT_SEQUENCE () { return 0xffffffff }
|
||||||
@ -60,38 +58,35 @@ class Transaction {
|
|||||||
static get ADVANCED_TRANSACTION_FLAG () { return 0x01 }
|
static get ADVANCED_TRANSACTION_FLAG () { return 0x01 }
|
||||||
|
|
||||||
get isCoinbase () {
|
get isCoinbase () {
|
||||||
if (this._isCoinbase !== null && this._changed === false) {
|
if (this._isCoinbase !== null) {
|
||||||
return this._isCoinbase
|
return this._isCoinbase
|
||||||
}
|
}
|
||||||
this._isCoinbase = this.ins.length === 1 && Transaction.isCoinbaseHash(this.ins[0].hash)
|
this._isCoinbase = this.ins.length === 1 && Transaction.isCoinbaseHash(this.ins[0].hash)
|
||||||
this._changed = false
|
|
||||||
return this._isCoinbase
|
return this._isCoinbase
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasWitnesses () {
|
get hasWitnesses () {
|
||||||
if (this._hasWitnesses !== null && this._changed === false) {
|
if (this._hasWitnesses !== null) {
|
||||||
return this._hasWitnesses
|
return this._hasWitnesses
|
||||||
}
|
}
|
||||||
this._hasWitnesses = this.ins.some((x) =>
|
this._hasWitnesses = this.ins.some((x) =>
|
||||||
x.witness.length !== 0
|
x.witness.length !== 0
|
||||||
)
|
)
|
||||||
this._changed = false
|
|
||||||
return this._hasWitnesses
|
return this._hasWitnesses
|
||||||
}
|
}
|
||||||
|
|
||||||
get weight () {
|
get weight () {
|
||||||
if (this._weight !== null && this._changed === false) {
|
if (this._weight !== null) {
|
||||||
return this._weight
|
return this._weight
|
||||||
}
|
}
|
||||||
const base = this.__byteLength(false)
|
const base = this.__byteLength(false)
|
||||||
const total = this.__byteLength(true)
|
const total = this.__byteLength(true)
|
||||||
this._weight = base * 3 + total
|
this._weight = base * 3 + total
|
||||||
this._changed = false
|
|
||||||
return this._weight
|
return this._weight
|
||||||
}
|
}
|
||||||
|
|
||||||
get virtualSize () {
|
get virtualSize () {
|
||||||
if (this._virtualSize !== null && this._changed === false) {
|
if (this._virtualSize !== null) {
|
||||||
return this._virtualSize
|
return this._virtualSize
|
||||||
}
|
}
|
||||||
this._virtualSize = Math.ceil(this.weight / 4)
|
this._virtualSize = Math.ceil(this.weight / 4)
|
||||||
@ -99,25 +94,23 @@ class Transaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get byteLength () {
|
get byteLength () {
|
||||||
if (this._byteLength !== null && this._changed === false) {
|
if (this._byteLength !== null) {
|
||||||
return this._byteLength
|
return this._byteLength
|
||||||
}
|
}
|
||||||
this._byteLength = this.__byteLength(true)
|
this._byteLength = this.__byteLength(true)
|
||||||
this._changed = false
|
|
||||||
return this._byteLength
|
return this._byteLength
|
||||||
}
|
}
|
||||||
|
|
||||||
get hash () {
|
get hash () {
|
||||||
if (this._hash !== null && this._changed === false) {
|
if (this._hash !== null) {
|
||||||
return this._hash
|
return this._hash
|
||||||
}
|
}
|
||||||
this._hash = bcrypto.hash256(this.__toBuffer(undefined, undefined, false))
|
this._hash = bcrypto.hash256(this.__toBuffer(undefined, undefined, false))
|
||||||
this._changed = false
|
|
||||||
return this._hash
|
return this._hash
|
||||||
}
|
}
|
||||||
|
|
||||||
get id () {
|
get id () {
|
||||||
if (this._id !== null && this._changed === false) {
|
if (this._id !== null) {
|
||||||
return this._id
|
return this._id
|
||||||
}
|
}
|
||||||
// transaction hash's are displayed in reverse order
|
// transaction hash's are displayed in reverse order
|
||||||
@ -126,16 +119,15 @@ class Transaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get buffer () {
|
get buffer () {
|
||||||
if (this._buffer !== null && this._changed === false) {
|
if (this._buffer !== null) {
|
||||||
return this._buffer
|
return this._buffer
|
||||||
}
|
}
|
||||||
this._buffer = this.__toBuffer(undefined, undefined, true)
|
this._buffer = this.__toBuffer(undefined, undefined, true)
|
||||||
this._changed = false
|
|
||||||
return this._buffer
|
return this._buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
get hex () {
|
get hex () {
|
||||||
if (this._hex !== null && this._changed === false) {
|
if (this._hex !== null) {
|
||||||
return this._hex
|
return this._hex
|
||||||
}
|
}
|
||||||
this._hex = this.buffer.toString('hex')
|
this._hex = this.buffer.toString('hex')
|
||||||
@ -463,8 +455,6 @@ class Transaction {
|
|||||||
this._id = null
|
this._id = null
|
||||||
this._buffer = null
|
this._buffer = null
|
||||||
this._hex = null
|
this._hex = null
|
||||||
|
|
||||||
this._changed = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user