bufferutils: add varIntBuffer

This commit is contained in:
Daniel Cousens 2014-10-17 13:07:14 +11:00
parent c0c47f076a
commit 2214ccfdd8
4 changed files with 22 additions and 10 deletions

View file

@ -120,13 +120,7 @@ Block.prototype.toBuffer = function(headersOnly) {
if (headersOnly || !this.transactions) return buffer
function varIntBuffer(i) {
var ib = new Buffer(bufferutils.varIntSize(i))
bufferutils.writeVarInt(ib, i, 0)
return ib
}
var txLenBuffer = varIntBuffer(this.transactions.length)
var txLenBuffer = bufferutils.varIntBuffer(this.transactions.length)
var txBuffers = this.transactions.map(function(tx) {
return tx.toBuffer()
})