Class: CoinView

coins.CoinView

new CoinView()

Represents a coin viewpoint: a snapshot of Coins objects.

Properties:
Name Type Description
map Object
undo UndoCoins
Source:

Methods

(static) fromFast(br, tx) → {CoinView}

Read serialized view data from a buffer reader as it pertains to a transaction.

Parameters:
Name Type Description
br BufferReader
tx TX
Source:
Returns:
Type
CoinView

(static) fromRaw(data, tx) → {CoinView}

Read serialized view data from a buffer as it pertains to a transaction.

Parameters:
Name Type Description
data Buffer
tx TX
Source:
Returns:
Type
CoinView

(static) fromReader(br, tx) → {CoinView}

Read serialized view data from a buffer reader as it pertains to a transaction.

Parameters:
Name Type Description
br BufferReader
tx TX
Source:
Returns:
Type
CoinView

add(coins)

Add coins to the collection.

Parameters:
Name Type Description
coins Coins
Source:

addCoin(coin)

Add a coin to the collection.

Parameters:
Name Type Description
coin Coin
Source:

addOutput(hash, index, output)

Add an output to the collection.

Parameters:
Name Type Description
hash Hash
index Number
output Output
Source:

addTX(tx, height)

Add a tx to the collection.

Parameters:
Name Type Description
tx TX
height Number
Source:

ensureInputs(db, tx) → {Promise}

Read all input coins into unspent map.

Parameters:
Name Type Description
db ChainDB
tx TX
Source:
Returns:
  • Returns {Boolean}.
Type
Promise

(private) fromFast(br, tx)

Read serialized view data from a buffer reader as it pertains to a transaction.

Parameters:
Name Type Description
br BufferReader
tx TX
Source:

(private) fromReader(br, tx)

Read serialized view data from a buffer reader as it pertains to a transaction.

Parameters:
Name Type Description
br BufferReader
tx TX
Source:

get(hash) → {Coins}

Get coins.

Parameters:
Name Type Description
hash Hash
Source:
Returns:

coins

Type
Coins

getCoin(input) → {Coin}

Get a single coin by input.

Parameters:
Name Type Description
input Input
Source:
Returns:
Type
Coin

getEntry(input) → {CoinEntry}

Get a single entry by input.

Parameters:
Name Type Description
input Input
Source:
Returns:
Type
CoinEntry

getFastSize() → {Number}

Calculate serialization size.

Source:
Returns:
Type
Number

getHeight(input) → {Number}

Get coins height by input.

Parameters:
Name Type Description
input Input
Source:
Returns:
Type
Number

getOutput(input) → {Output}

Get a single output by input.

Parameters:
Name Type Description
input Input
Source:
Returns:
Type
Output

has(hash) → {Boolean}

Test whether the view has an entry.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
Type
Boolean

hasEntry(input) → {Boolean}

Test whether the view has an entry by input.

Parameters:
Name Type Description
input Input
Source:
Returns:
Type
Boolean

isCoinbase(input) → {Boolean}

Get coins coinbase flag by input.

Parameters:
Name Type Description
input Input
Source:
Returns:
Type
Boolean

readCoins(db, tx) → {Promise}

Retrieve coins from database.

Parameters:
Name Type Description
db ChainDB
tx TX
Source:
Returns:
  • Returns Coins.
Type
Promise

remove(coins) → {Boolean}

Remove coins from the collection.

Parameters:
Name Type Description
coins Coins
Source:
Returns:
Type
Boolean

removeOutput(hash, index) → {Boolean}

Remove an output.

Parameters:
Name Type Description
hash Hash
index Number
Source:
Returns:
Type
Boolean

removeTX(tx, height)

Remove a tx from the collection.

Parameters:
Name Type Description
tx TX
height Number
Source:

spendFrom(coins, index) → {Boolean}

Spend a coin from coins object.

Parameters:
Name Type Description
coins Coins
index Number
Source:
Returns:
Type
Boolean

spendInputs(db, tx) → {Promise}

Spend coins for transaction.

Parameters:
Name Type Description
db ChainDB
tx TX
Source:
Returns:
  • Returns {Boolean}.
Type
Promise

spendOutput(hash, index) → {Boolean}

Spend an output.

Parameters:
Name Type Description
hash Hash
index Number
Source:
Returns:
Type
Boolean

toArray() → {Array:.<Coins:>}

Convert collection to an array.

Source:
Returns:
Type
Array:.<Coins:>

toFast(bw, tx)

Write coin data to buffer writer as it pertains to a transaction.

Parameters:
Name Type Description
bw BufferWriter
tx TX
Source:

toRaw(tx) → {Buffer}

Serialize coin data to as it pertains to a transaction.

Parameters:
Name Type Description
tx TX
Source:
Returns:
Type
Buffer

toWriter(bw, tx)

Write coin data to buffer writer as it pertains to a transaction.

Parameters:
Name Type Description
bw BufferWriter
tx TX
Source: