optimize memblock parsing.
This commit is contained in:
parent
f1bbd7736a
commit
3fb5a36f8d
@ -113,7 +113,7 @@ MemBlock.prototype.getCoinbaseHeight = function getCoinbaseHeight() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
MemBlock.prototype.fromRaw = function fromRaw(data) {
|
MemBlock.prototype.fromRaw = function fromRaw(data) {
|
||||||
var p = bcoin.reader(data);
|
var p = bcoin.reader(data, true);
|
||||||
var height = -1;
|
var height = -1;
|
||||||
var inCount, input;
|
var inCount, input;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ MemBlock.prototype.fromRaw = function fromRaw(data) {
|
|||||||
this.totalTX = p.readVarint();
|
this.totalTX = p.readVarint();
|
||||||
|
|
||||||
if (this.version > 1 && this.totalTX > 0) {
|
if (this.version > 1 && this.totalTX > 0) {
|
||||||
p.readU32(); // Technically signed
|
p.seek(4);
|
||||||
inCount = p.readVarint();
|
inCount = p.readVarint();
|
||||||
|
|
||||||
if (inCount === 0) {
|
if (inCount === 0) {
|
||||||
@ -134,13 +134,13 @@ MemBlock.prototype.fromRaw = function fromRaw(data) {
|
|||||||
inCount = p.readVarint();
|
inCount = p.readVarint();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inCount > 0)
|
if (inCount > 0) {
|
||||||
input = bcoin.input.fromRaw(p);
|
p.seek(36);
|
||||||
|
input = p.readVarBytes();
|
||||||
|
height = bcoin.script.getCoinbaseHeight(input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input)
|
|
||||||
height = bcoin.script.getCoinbaseHeight(input.script.raw);
|
|
||||||
|
|
||||||
this.coinbaseHeight = height;
|
this.coinbaseHeight = height;
|
||||||
this.raw = p.data;
|
this.raw = p.data;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user