Revert function hoisting removal
This commit is contained in:
parent
17c89fdc5e
commit
a88aa33348
1 changed files with 22 additions and 22 deletions
|
@ -7,13 +7,13 @@ const typeforce = require('typeforce')
|
||||||
const types = require('./types')
|
const types = require('./types')
|
||||||
const varuint = require('varuint-bitcoin')
|
const varuint = require('varuint-bitcoin')
|
||||||
|
|
||||||
const varSliceSize = (someScript) => {
|
function varSliceSize (someScript) {
|
||||||
const length = someScript.length
|
const length = someScript.length
|
||||||
|
|
||||||
return varuint.encodingLength(length) + length
|
return varuint.encodingLength(length) + length
|
||||||
}
|
}
|
||||||
|
|
||||||
const vectorSize = (someVector) => {
|
function vectorSize (someVector) {
|
||||||
const length = someVector.length
|
const length = someVector.length
|
||||||
|
|
||||||
return varuint.encodingLength(length) + someVector.reduce((sum, witness) => {
|
return varuint.encodingLength(length) + someVector.reduce((sum, witness) => {
|
||||||
|
@ -241,24 +241,24 @@ class Transaction {
|
||||||
|
|
||||||
let tbuffer, toffset
|
let tbuffer, toffset
|
||||||
|
|
||||||
const writeSlice = (slice) => {
|
function writeSlice (slice) {
|
||||||
toffset += slice.copy(tbuffer, toffset)
|
toffset += slice.copy(tbuffer, toffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeUInt32 = (i) => {
|
function writeUInt32 (i) {
|
||||||
toffset = tbuffer.writeUInt32LE(i, toffset)
|
toffset = tbuffer.writeUInt32LE(i, toffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeUInt64 = (i) => {
|
function writeUInt64 (i) {
|
||||||
toffset = bufferutils.writeUInt64LE(tbuffer, i, toffset)
|
toffset = bufferutils.writeUInt64LE(tbuffer, i, toffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeVarInt = (i) => {
|
function writeVarInt (i) {
|
||||||
varuint.encode(i, tbuffer, toffset)
|
varuint.encode(i, tbuffer, toffset)
|
||||||
toffset += varuint.encode.bytes
|
toffset += varuint.encode.bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeVarSlice = (slice) => {
|
function writeVarSlice (slice) {
|
||||||
writeVarInt(slice.length)
|
writeVarInt(slice.length)
|
||||||
writeSlice(slice)
|
writeSlice(slice)
|
||||||
}
|
}
|
||||||
|
@ -354,37 +354,37 @@ class Transaction {
|
||||||
|
|
||||||
let offset = initialOffset || 0
|
let offset = initialOffset || 0
|
||||||
|
|
||||||
const writeSlice = (slice) => {
|
function writeSlice (slice) {
|
||||||
offset += slice.copy(buffer, offset)
|
offset += slice.copy(buffer, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeUInt8 = (i) => {
|
function writeUInt8 (i) {
|
||||||
offset = buffer.writeUInt8(i, offset)
|
offset = buffer.writeUInt8(i, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeUInt32 = (i) => {
|
function writeUInt32 (i) {
|
||||||
offset = buffer.writeUInt32LE(i, offset)
|
offset = buffer.writeUInt32LE(i, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeInt32 = (i) => {
|
function writeInt32 (i) {
|
||||||
offset = buffer.writeInt32LE(i, offset)
|
offset = buffer.writeInt32LE(i, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeUInt64 = (i) => {
|
function writeUInt64 (i) {
|
||||||
offset = bufferutils.writeUInt64LE(buffer, i, offset)
|
offset = bufferutils.writeUInt64LE(buffer, i, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeVarInt = (i) => {
|
function writeVarInt (i) {
|
||||||
varuint.encode(i, buffer, offset)
|
varuint.encode(i, buffer, offset)
|
||||||
offset += varuint.encode.bytes
|
offset += varuint.encode.bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeVarSlice = (slice) => {
|
function writeVarSlice (slice) {
|
||||||
writeVarInt(slice.length)
|
writeVarInt(slice.length)
|
||||||
writeSlice(slice)
|
writeSlice(slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
const writeVector = (vector) => {
|
function writeVector (vector) {
|
||||||
writeVarInt(vector.length)
|
writeVarInt(vector.length)
|
||||||
vector.forEach(writeVarSlice)
|
vector.forEach(writeVarSlice)
|
||||||
}
|
}
|
||||||
|
@ -451,40 +451,40 @@ class Transaction {
|
||||||
Transaction.fromBuffer = (buffer, __noStrict) => {
|
Transaction.fromBuffer = (buffer, __noStrict) => {
|
||||||
let offset = 0
|
let offset = 0
|
||||||
|
|
||||||
const readSlice = (n) => {
|
function readSlice (n) {
|
||||||
offset += n
|
offset += n
|
||||||
return buffer.slice(offset - n, offset)
|
return buffer.slice(offset - n, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const readUInt32 = () => {
|
function readUInt32 () {
|
||||||
const i = buffer.readUInt32LE(offset)
|
const i = buffer.readUInt32LE(offset)
|
||||||
offset += 4
|
offset += 4
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
const readInt32 = () => {
|
function readInt32 () {
|
||||||
const i = buffer.readInt32LE(offset)
|
const i = buffer.readInt32LE(offset)
|
||||||
offset += 4
|
offset += 4
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
const readUInt64 = () => {
|
function readUInt64 () {
|
||||||
const i = bufferutils.readUInt64LE(buffer, offset)
|
const i = bufferutils.readUInt64LE(buffer, offset)
|
||||||
offset += 8
|
offset += 8
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
const readVarInt = () => {
|
function readVarInt () {
|
||||||
const vi = varuint.decode(buffer, offset)
|
const vi = varuint.decode(buffer, offset)
|
||||||
offset += varuint.decode.bytes
|
offset += varuint.decode.bytes
|
||||||
return vi
|
return vi
|
||||||
}
|
}
|
||||||
|
|
||||||
const readVarSlice = () => {
|
function readVarSlice () {
|
||||||
return readSlice(readVarInt())
|
return readSlice(readVarInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
const readVector = () => {
|
function readVector () {
|
||||||
const count = readVarInt()
|
const count = readVarInt()
|
||||||
const vector = []
|
const vector = []
|
||||||
for (var i = 0; i < count; i++) vector.push(readVarSlice())
|
for (var i = 0; i < count; i++) vector.push(readVarSlice())
|
||||||
|
|
Loading…
Reference in a new issue