From dd2d9f48bdb236ed60583c272d9ed3abc2c74c03 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 26 Nov 2016 20:17:01 -0800 Subject: [PATCH] coins: refactor. --- lib/blockchain/coins.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/blockchain/coins.js b/lib/blockchain/coins.js index 65b37f7f..591400d1 100644 --- a/lib/blockchain/coins.js +++ b/lib/blockchain/coins.js @@ -262,7 +262,7 @@ Coins.prototype.toRaw = function toRaw() { if (!output) continue; - output.toRaw(bw); + output.toWriter(bw); } // Render the buffer with all @@ -331,7 +331,7 @@ Coins.prototype.fromRaw = function fromRaw(data, hash, index) { // Store the offset and size // in the compressed coin object. - coin = CoinEntry.fromRaw(br); + coin = CoinEntry.fromReader(br); this.outputs.push(coin); pos++; @@ -515,10 +515,9 @@ CoinEntry.prototype.toCoin = function toCoin(coins, index) { /** * Slice off the part of the buffer * relevant to this particular coin. - * @returns {Buffer} */ -CoinEntry.prototype.toRaw = function toRaw(bw) { +CoinEntry.prototype.toWriter = function toWriter(bw) { var raw; if (this.output) { @@ -544,12 +543,12 @@ CoinEntry.prototype.toRaw = function toRaw(bw) { * @returns {CoinEntry} */ -CoinEntry.fromRaw = function fromRaw(br) { - var coin = new CoinEntry(); - coin.offset = br.offset; - coin.size = skipCoin(br); - coin.raw = br.data; - return coin; +CoinEntry.fromReader = function fromReader(br) { + var entry = new CoinEntry(); + entry.offset = br.offset; + entry.size = skipCoin(br); + entry.raw = br.data; + return entry; }; /** @@ -560,9 +559,9 @@ CoinEntry.fromRaw = function fromRaw(br) { */ CoinEntry.fromTX = function fromTX(tx, index) { - var coin = new CoinEntry(); - coin.output = tx.outputs[index]; - return coin; + var entry = new CoinEntry(); + entry.output = tx.outputs[index]; + return entry; }; /**