Documentation
¶
Overview ¶
Copyright (C) 2018 go-dappley authors
This file is part of the go-dappley library.
the go-dappley library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either pubKeyHash 3 of the License, or (at your option) any later pubKeyHash.
the go-dappley library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Gc eneral Public License along with the go-dappley library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-dappley authors ¶
This file is part of the go-dappley library.
the go-dappley library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either pubKeyHash 3 of the License, or (at your option) any later pubKeyHash.
the go-dappley library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-dappley library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-dappley authors ¶
This file is part of the go-dappley library.
the go-dappley library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either pubKeyHash 3 of the License, or (at your option) any later pubKeyHash.
the go-dappley library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-dappley library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func Checksum(payload []byte) []byte
- func GetAddressPayloadLength() int
- func HashAddress(address string) []byte
- func IsHashEqual(h1 Hash, h2 Hash) bool
- func IsParentBlockHash(parentBlk, childBlk *Block) bool
- func IsParentBlockHeight(parentBlk, childBlk *Block) bool
- func WaitDoneOrTimeout(done Done, timeOut int)
- type Address
- type Addresses
- type Block
- func Deserialize(d []byte) *Block
- func FakeNewBlockWithTimestamp(t int64, transactions []*Transaction, parent *Block) *Block
- func GenerateBlockWithCbtx(addr Address, lastblock *Block) *Block
- func GenerateMockBlock() *Block
- func NewBlock(transactions []*Transaction, parent *Block) *Block
- func NewGenesisBlock(address string) *Block
- func (b *Block) CalculateHash() Hash
- func (b *Block) CalculateHashWithNonce(nonce int64) Hash
- func (b *Block) CalculateHashWithoutNonce() Hash
- func (b *Block) FindTransactionById(txid []byte) *Transaction
- func (b *Block) FromProto(pb proto.Message)
- func (b *Block) GetCoinbaseTransaction() *Transaction
- func (b *Block) GetHash() Hash
- func (b *Block) GetHeader() *BlockHeader
- func (b *Block) GetHeight() uint64
- func (b *Block) GetNonce() int64
- func (b *Block) GetPrevHash() Hash
- func (b *Block) GetSign() Hash
- func (b *Block) GetTimestamp() int64
- func (b *Block) GetTransactions() []*Transaction
- func (b *Block) HashTransactions() []byte
- func (parent *Block) IsParentBlock(child *Block) bool
- func (b *Block) Rollback(txPool *TransactionPool)
- func (b *Block) Serialize() []byte
- func (b *Block) SetHash(hash Hash)
- func (b *Block) SetNonce(nonce int64)
- func (b *Block) SignBlock(key string, data []byte) bool
- func (b *Block) ToProto() proto.Message
- func (b *Block) VerifyHash() bool
- func (b *Block) VerifyTransactions(utxo UTXOIndex) bool
- type BlockHeader
- type BlockHeaderStream
- type BlockPool
- func (pool *BlockPool) BlockRequestCh() chan BlockRequestPars
- func (pool *BlockPool) GetBlockchain() *Blockchain
- func (pool *BlockPool) GetSyncState() bool
- func (pool *BlockPool) Push(block *Block, pid peer.ID)
- func (pool *BlockPool) SetBlockchain(bc *Blockchain)
- func (pool *BlockPool) SetSyncState(sync bool)
- func (pool *BlockPool) VerifyTransactions(utxo UTXOIndex, forkBlks []*Block) bool
- type BlockPoolInterface
- type BlockRequestPars
- type BlockStream
- type Blockchain
- func CreateBlockchain(address Address, db storage.Storage, consensus Consensus, ...) *Blockchain
- func GenerateMockBlockchain(size int) *Blockchain
- func GenerateMockBlockchainWithCoinbaseTxOnly(size int) *Blockchain
- func GetBlockchain(db storage.Storage, consensus Consensus, transactionPoolLimit uint32) (*Blockchain, error)
- func (bc *Blockchain) AddBlockToDb(block *Block) error
- func (bc *Blockchain) AddBlockToTail(block *Block) error
- func (bc *Blockchain) FindTransaction(ID []byte) (Transaction, error)
- func (bc *Blockchain) FindTransactionFromIndexBlock(txID []byte, blockId []byte) (Transaction, error)
- func (bc *Blockchain) GetBlockByHash(hash Hash) (*Block, error)
- func (bc *Blockchain) GetBlockByHeight(height uint64) (*Block, error)
- func (bc *Blockchain) GetBlockPool() BlockPoolInterface
- func (bc *Blockchain) GetConsensus() Consensus
- func (bc *Blockchain) GetDb() storage.Storage
- func (bc *Blockchain) GetMaxHeight() uint64
- func (bc *Blockchain) GetTailBlock() (*Block, error)
- func (bc *Blockchain) GetTailBlockHash() Hash
- func (bc *Blockchain) GetTxPool() *TransactionPool
- func (bc *Blockchain) IsHigherThanBlockchain(block *Block) bool
- func (bc *Blockchain) IsInBlockchain(hash Hash) bool
- func (bc *Blockchain) Iterator() *Blockchain
- func (bc *Blockchain) MergeFork(forkBlks []*Block, forkParentHash Hash)
- func (bc *Blockchain) Next() (*Block, error)
- func (bc *Blockchain) NextFromIndex(indexHash []byte) (*Block, error)
- func (bc *Blockchain) Rollback(targetHash Hash) bool
- func (bc *Blockchain) SetBlockPool(blockPool BlockPoolInterface)
- func (bc *Blockchain) SetConsensus(consensus Consensus)
- func (bc *Blockchain) SetTailBlockHash(tailBlockHash Hash)
- func (bc *Blockchain) String() string
- type Consensus
- type Done
- type Hash
- type KeyPair
- type NetService
- type PubKeyHash
- type RcvedBlock
- type ScEngine
- type TXInput
- type TXOutput
- type Transaction
- func (tx *Transaction) Execute(index UTXOIndex, sc ScEngine)
- func (tx *Transaction) FindAllTxinsInUtxoPool(utxoPool UTXOIndex) ([]*UTXO, error)
- func (tx *Transaction) FromProto(pb proto.Message)
- func (tx *Transaction) GetContract() string
- func (tx *Transaction) GetContractAddress() Address
- func (tx *Transaction) GetToHashBytes() []byte
- func (tx *Transaction) Hash() []byte
- func (tx Transaction) IsCoinbase() bool
- func (tx Transaction) Serialize() []byte
- func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevUtxos []*UTXO) error
- func (tx Transaction) String() string
- func (tx *Transaction) ToProto() proto.Message
- func (tx *Transaction) TrimmedCopy() Transaction
- func (tx *Transaction) Verify(utxo *UTXOIndex, blockHeight uint64) bool
- type TransactionPool
- type TxIndex
- type UTXO
- type UTXOIndex
- func (utxos *UTXOIndex) ApplyTransaction(tx *Transaction) error
- func (utxos UTXOIndex) DeepCopy() UTXOIndex
- func (utxos UTXOIndex) FindUTXO(txid []byte, vout int) *UTXO
- func (utxos UTXOIndex) FindUTXOByVin(pubkeyHash []byte, txid []byte, vout int) *UTXO
- func (utxos UTXOIndex) GetAllUTXOsByPubKeyHash(pubkeyHash []byte) []*UTXO
- func (utxos UTXOIndex) GetUTXOsByAmount(pubkeyHash []byte, amount *common.Amount) ([]*UTXO, error)
- func (utxos UTXOIndex) Save(mapkey string, db storage.Storage) error
- func (utxos *UTXOIndex) UpdateUtxoState(txs []*Transaction, db storage.Storage) ([]*Transaction, error)
Constants ¶
const BlockCacheLRUCacheLimit = 1024
const BlockPoolMaxSize = 100
const ContractTxouputIndex = 0
const ForkCacheLRUCacheLimit = 128
const LengthForBlockToBeConsideredHistory = 100
Variables ¶
var ( ErrBlockDoesNotExist = errors.New("ERROR: Block does not exist in blockchain") ErrNotAbleToGetLastBlockHash = errors.New("ERROR: Not able to get last block hash in blockchain") ErrTransactionNotFound = errors.New("ERROR: Transaction not found") ErrDuplicatedBlock = errors.New("ERROR: Block already exists in blockchain") )
var ( ErrIncorrectPublicKey = errors.New("Public key is not correct") ErrEmptyPublicKeyHash = errors.New("Empty public key hash") )
var ( ErrInsufficientFund = errors.New("transaction: the balance is insufficient") ErrInvalidAmount = errors.New("transaction: amount is invalid (must be > 0)") ErrTXInputNotFound = errors.New("transaction: transaction input not found") ErrNewUserPubKeyHash = errors.New("transaction: create pubkeyhash error") )
var (
ErrInvalidAddress = errors.New("Invalid Address")
)
var (
ErrInvalidPubKeyHashVersion = errors.New("Invalid Public Key Hash Version ")
)
var (
// tx metrics
MetricsTxDoubleSpend = dapmetrics.NewCounter("dap.txpool.doublespend")
)
Metrics for core
Functions ¶
func GetAddressPayloadLength ¶ added in v0.1.2
func GetAddressPayloadLength() int
GetAddressPayloadLength get the payload length
func HashAddress ¶
func IsHashEqual ¶ added in v0.1.2
func IsParentBlockHash ¶
func IsParentBlockHeight ¶
func WaitDoneOrTimeout ¶ added in v0.1.2
Types ¶
type Address ¶
type Address struct {
Address string
}
func NewAddress ¶
func (Address) GetPubKeyHash ¶ added in v0.1.2
GetPubKeyHash decodes the address to the original public key hash. If unsuccessful, return false
func (Address) IsContract ¶ added in v0.1.2
isContract checks if an address is a Contract address
func (Address) ValidateAddress ¶
ValidateAddress checks if an address is valid
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func Deserialize ¶
func FakeNewBlockWithTimestamp ¶
func FakeNewBlockWithTimestamp(t int64, transactions []*Transaction, parent *Block) *Block
func GenerateBlockWithCbtx ¶ added in v0.1.2
func GenerateMockBlock ¶
func GenerateMockBlock() *Block
func NewBlock ¶
func NewBlock(transactions []*Transaction, parent *Block) *Block
func NewGenesisBlock ¶
func (*Block) CalculateHash ¶
func (*Block) CalculateHashWithNonce ¶
func (*Block) CalculateHashWithoutNonce ¶ added in v0.1.2
func (*Block) FindTransactionById ¶
func (b *Block) FindTransactionById(txid []byte) *Transaction
func (*Block) GetCoinbaseTransaction ¶
func (b *Block) GetCoinbaseTransaction() *Transaction
func (*Block) GetHeader ¶ added in v0.1.2
func (b *Block) GetHeader() *BlockHeader
func (*Block) GetPrevHash ¶
func (*Block) GetTimestamp ¶
func (*Block) GetTransactions ¶
func (b *Block) GetTransactions() []*Transaction
func (*Block) HashTransactions ¶
func (*Block) IsParentBlock ¶ added in v0.1.2
func (*Block) Rollback ¶
func (b *Block) Rollback(txPool *TransactionPool)
func (*Block) VerifyHash ¶
func (*Block) VerifyTransactions ¶
type BlockHeader ¶
type BlockHeader struct {
// contains filtered or unexported fields
}
func (*BlockHeader) FromProto ¶
func (bh *BlockHeader) FromProto(pb proto.Message)
func (*BlockHeader) ToProto ¶
func (bh *BlockHeader) ToProto() proto.Message
type BlockHeaderStream ¶
type BlockPool ¶
type BlockPool struct {
// contains filtered or unexported fields
}
func NewBlockPool ¶
func (*BlockPool) BlockRequestCh ¶
func (pool *BlockPool) BlockRequestCh() chan BlockRequestPars
func (*BlockPool) GetBlockchain ¶
func (pool *BlockPool) GetBlockchain() *Blockchain
func (*BlockPool) GetSyncState ¶ added in v0.1.2
func (*BlockPool) SetBlockchain ¶
func (pool *BlockPool) SetBlockchain(bc *Blockchain)
func (*BlockPool) SetSyncState ¶ added in v0.1.2
type BlockPoolInterface ¶ added in v0.1.2
type BlockPoolInterface interface {
SetBlockchain(bc *Blockchain)
BlockRequestCh() chan BlockRequestPars
GetBlockchain() *Blockchain
GetSyncState() bool
SetSyncState(bool)
VerifyTransactions(utxo UTXOIndex, forkBlks []*Block) bool
Push(block *Block, pid peer.ID)
}
type BlockRequestPars ¶
type BlockRequestPars struct {
BlockHash Hash
Pid peer.ID
}
type BlockStream ¶
type BlockStream struct {
Header *BlockHeaderStream
Transactions []*Transaction
}
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
func CreateBlockchain ¶
func CreateBlockchain(address Address, db storage.Storage, consensus Consensus, transactionPoolLimit uint32) *Blockchain
CreateBlockchain creates a new blockchain db
func GenerateMockBlockchain ¶
func GenerateMockBlockchain(size int) *Blockchain
func GenerateMockBlockchainWithCoinbaseTxOnly ¶
func GenerateMockBlockchainWithCoinbaseTxOnly(size int) *Blockchain
func GetBlockchain ¶
func (*Blockchain) AddBlockToDb ¶ added in v0.1.1
func (bc *Blockchain) AddBlockToDb(block *Block) error
AddBlockToDb record the new block in the database
func (*Blockchain) AddBlockToTail ¶ added in v0.1.1
func (bc *Blockchain) AddBlockToTail(block *Block) error
func (*Blockchain) FindTransaction ¶
func (bc *Blockchain) FindTransaction(ID []byte) (Transaction, error)
TODO: optimize performance
func (*Blockchain) FindTransactionFromIndexBlock ¶
func (bc *Blockchain) FindTransactionFromIndexBlock(txID []byte, blockId []byte) (Transaction, error)
func (*Blockchain) GetBlockByHash ¶
func (bc *Blockchain) GetBlockByHash(hash Hash) (*Block, error)
func (*Blockchain) GetBlockByHeight ¶ added in v0.1.2
func (bc *Blockchain) GetBlockByHeight(height uint64) (*Block, error)
func (*Blockchain) GetBlockPool ¶ added in v0.1.1
func (bc *Blockchain) GetBlockPool() BlockPoolInterface
func (*Blockchain) GetConsensus ¶ added in v0.1.1
func (bc *Blockchain) GetConsensus() Consensus
func (*Blockchain) GetDb ¶ added in v0.1.1
func (bc *Blockchain) GetDb() storage.Storage
func (*Blockchain) GetMaxHeight ¶
func (bc *Blockchain) GetMaxHeight() uint64
func (*Blockchain) GetTailBlock ¶
func (bc *Blockchain) GetTailBlock() (*Block, error)
func (*Blockchain) GetTailBlockHash ¶ added in v0.1.1
func (bc *Blockchain) GetTailBlockHash() Hash
func (*Blockchain) GetTxPool ¶ added in v0.1.1
func (bc *Blockchain) GetTxPool() *TransactionPool
func (*Blockchain) IsHigherThanBlockchain ¶ added in v0.1.1
func (bc *Blockchain) IsHigherThanBlockchain(block *Block) bool
func (*Blockchain) IsInBlockchain ¶
func (bc *Blockchain) IsInBlockchain(hash Hash) bool
func (*Blockchain) Iterator ¶
func (bc *Blockchain) Iterator() *Blockchain
func (*Blockchain) MergeFork ¶
func (bc *Blockchain) MergeFork(forkBlks []*Block, forkParentHash Hash)
func (*Blockchain) Next ¶
func (bc *Blockchain) Next() (*Block, error)
func (*Blockchain) NextFromIndex ¶
func (bc *Blockchain) NextFromIndex(indexHash []byte) (*Block, error)
func (*Blockchain) Rollback ¶ added in v0.1.1
func (bc *Blockchain) Rollback(targetHash Hash) bool
rollback the blockchain to a block with the targetHash
func (*Blockchain) SetBlockPool ¶ added in v0.1.2
func (bc *Blockchain) SetBlockPool(blockPool BlockPoolInterface)
func (*Blockchain) SetConsensus ¶ added in v0.1.1
func (bc *Blockchain) SetConsensus(consensus Consensus)
func (*Blockchain) SetTailBlockHash ¶ added in v0.1.1
func (bc *Blockchain) SetTailBlockHash(tailBlockHash Hash)
func (*Blockchain) String ¶
func (bc *Blockchain) String() string
type Consensus ¶
type Consensus interface {
Validate(block *Block) bool
Setup(NetService, string)
SetKey(string)
// Start runs the consensus algorithm and begins to produce blocks
Start()
// Stop ceases the consensus algorithm and block production
Stop()
// IsProducingBlock returns true if this node itself is currently producing a block
IsProducingBlock() bool
// TODO: Should separate the concept of producers from PoW
AddProducer(string) error
GetProducers() []string
}
type KeyPair ¶
type KeyPair struct {
PrivateKey ecdsa.PrivateKey
PublicKey []byte
}
func GetKeyPairByString ¶ added in v0.1.2
func NewKeyPair ¶
func NewKeyPair() *KeyPair
func (KeyPair) GenerateAddress ¶
type NetService ¶
type NetService interface {
BroadcastBlock(block *Block) error
GetPeerID() peer.ID
GetBlockchain() *Blockchain
}
type PubKeyHash ¶ added in v0.1.2
type PubKeyHash struct {
PubKeyHash []byte
}
func NewContractPubKeyHash ¶ added in v0.1.2
func NewContractPubKeyHash() PubKeyHash
NewContractPubKeyHash generates a smart Contract public key hash
func NewUserPubKeyHash ¶ added in v0.1.2
func NewUserPubKeyHash(pubKey []byte) (PubKeyHash, error)
NewUserPubKeyHash hashes a public key and returns a user type public key hash
func (PubKeyHash) GenerateAddress ¶ added in v0.1.2
func (pkh PubKeyHash) GenerateAddress() Address
GenerateAddress generates an address from a public key hash
func (PubKeyHash) GetPubKeyHash ¶ added in v0.1.2
func (pkh PubKeyHash) GetPubKeyHash() []byte
GetPubKeyHash gets the public key hash
func (PubKeyHash) IsContract ¶ added in v0.1.2
func (pkh PubKeyHash) IsContract() (bool, error)
GenerateAddress generates an address from a public key hash
type RcvedBlock ¶
type RcvedBlock struct {
Block *Block
Pid peer.ID
}
type ScEngine ¶ added in v0.1.2
type ScEngine interface {
ImportSourceCode(source string)
Execute()
}
type TXInput ¶
func MockTxInputs ¶
func MockTxInputs() []TXInput
func MockTxInputsWithPubkey ¶ added in v0.1.2
type TXOutput ¶
type TXOutput struct {
Value *common.Amount
PubKeyHash PubKeyHash
Contract string
}
func MockTxOutputs ¶
func MockTxOutputs() []TXOutput
func NewContractTXOutput ¶ added in v0.1.2
func (*TXOutput) IsLockedWithKey ¶
type Transaction ¶
func MockTransaction ¶
func MockTransaction() *Transaction
func NewCoinbaseTX ¶
func NewCoinbaseTX(to, data string, blockHeight uint64, tip *common.Amount) Transaction
NewCoinbaseTX creates a new coinbase transaction
func NewUTXOTransaction ¶
func NewUTXOTransaction(utxos []*UTXO, from, to Address, amount *common.Amount, senderKeyPair KeyPair, tip *common.Amount, contract string) (Transaction, error)
NewUTXOTransaction creates a new transaction
func (*Transaction) Execute ¶ added in v0.1.2
func (tx *Transaction) Execute(index UTXOIndex, sc ScEngine)
Execute executes the smart contract the transaction points to. it doesnt do anything if is a normal transaction
func (*Transaction) FindAllTxinsInUtxoPool ¶
func (tx *Transaction) FindAllTxinsInUtxoPool(utxoPool UTXOIndex) ([]*UTXO, error)
FindAllTxinsInUtxoPool Find the transaction in a utxo pool. Returns true only if all Vins are found in the utxo pool
func (*Transaction) FromProto ¶
func (tx *Transaction) FromProto(pb proto.Message)
func (*Transaction) GetContract ¶ added in v0.1.2
func (tx *Transaction) GetContract() string
GetContract returns the smart contract code in a transaction
func (*Transaction) GetContractAddress ¶ added in v0.1.2
func (tx *Transaction) GetContractAddress() Address
GetContractAddress gets the smart contract's address if a transaction deploys a smart contract
func (*Transaction) GetToHashBytes ¶ added in v0.1.2
func (tx *Transaction) GetToHashBytes() []byte
GetToHashBytes Get bytes for hash
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() []byte
Hash returns the hash of the Transaction
func (Transaction) IsCoinbase ¶
func (tx Transaction) IsCoinbase() bool
func (Transaction) Serialize ¶
func (tx Transaction) Serialize() []byte
Serialize returns a serialized Transaction
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevUtxos []*UTXO) error
Sign signs each input of a Transaction
func (Transaction) String ¶
func (tx Transaction) String() string
String returns a human-readable representation of a transaction
func (*Transaction) ToProto ¶
func (tx *Transaction) ToProto() proto.Message
func (*Transaction) TrimmedCopy ¶
func (tx *Transaction) TrimmedCopy() Transaction
TrimmedCopy creates a trimmed copy of Transaction to be used in signing
type TransactionPool ¶
func NewTransactionPool ¶
func NewTransactionPool(limit uint32) *TransactionPool
func (*TransactionPool) Push ¶ added in v0.1.2
func (txPool *TransactionPool) Push(tx Transaction)
func (*TransactionPool) RemoveMultipleTransactions ¶
func (txPool *TransactionPool) RemoveMultipleTransactions(txs []*Transaction)
func (*TransactionPool) ValidTxns ¶ added in v0.1.2
func (txPool *TransactionPool) ValidTxns(filter filterTx) []*Transaction
type UTXOIndex ¶ added in v0.1.2
type UTXOIndex struct {
// contains filtered or unexported fields
}
UTXOIndex holds all unspent TXOutputs indexed by public key hash.
func GetUTXOIndexAtBlockHash ¶ added in v0.1.2
GetUTXOIndexAtBlockHash returns the previous snapshot of UTXOIndex when the block of given hash was the tail block.
func LoadUTXOIndex ¶ added in v0.1.2
LoadUTXOIndex returns the UTXOIndex fetched from db.
func NewUTXOIndex ¶ added in v0.1.2
func NewUTXOIndex() UTXOIndex
NewUTXOIndex initializes an UTXOIndex instance
func (*UTXOIndex) ApplyTransaction ¶ added in v0.1.2
func (utxos *UTXOIndex) ApplyTransaction(tx *Transaction) error
func (UTXOIndex) FindUTXO ¶ added in v0.1.2
FindUTXO returns the UTXO instance of the corresponding TXOutput in the transaction (identified by txid and vout) if the TXOutput is unspent. Otherwise, it returns nil.
func (UTXOIndex) FindUTXOByVin ¶ added in v0.1.2
FindUTXOByVin returns the UTXO instance identified by pubkeyHash, txid and vout
func (UTXOIndex) GetAllUTXOsByPubKeyHash ¶ added in v0.1.2
GetAllUTXOsByPubKeyHash returns all current UTXOs identified by pubkey.
func (UTXOIndex) GetUTXOsByAmount ¶ added in v0.1.2
GetUTXOsByAmount returns a number of UTXOs that has a sum more than or equal to the amount
func (*UTXOIndex) UpdateUtxoState ¶ added in v0.1.2
func (utxos *UTXOIndex) UpdateUtxoState(txs []*Transaction, db storage.Storage) ([]*Transaction, error)
Update removes the UTXOs spent in the transactions in newBlk from the index and adds UTXOs generated in the transactions to the index. The index will be saved to db as a result. If saving failed, index won't be updated.