coins: refactor.
This commit is contained in:
parent
67695b7e53
commit
dd2d9f48bd
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user