Documentation
¶
Index ¶
- func NewErrUnspentNotExist(uxID string) error
- type BlockSigs
- type BlockTree
- type Blockchain
- func (bc *Blockchain) AddBlockWithTx(tx *bolt.Tx, sb *coin.SignedBlock) error
- func (bc *Blockchain) GetBlockByHash(hash cipher.SHA256) (*coin.SignedBlock, error)
- func (bc *Blockchain) GetBlockBySeq(seq uint64) (*coin.SignedBlock, error)
- func (bc *Blockchain) GetGenesisBlock() *coin.SignedBlock
- func (bc *Blockchain) Head() (*coin.SignedBlock, error)
- func (bc *Blockchain) HeadSeq() uint64
- func (bc *Blockchain) Len() uint64
- func (bc *Blockchain) UnspentPool() UnspentPool
- type ErrMissingSignature
- type ErrUnspentNotExist
- type UnspentGetter
- type UnspentPool
- type Unspents
- func (up *Unspents) Contains(h cipher.SHA256) bool
- func (up *Unspents) Get(h cipher.SHA256) (coin.UxOut, bool)
- func (up *Unspents) GetAll() (coin.UxArray, error)
- func (up *Unspents) GetArray(hashes []cipher.SHA256) (coin.UxArray, error)
- func (up *Unspents) GetUnspentsOfAddrs(addrs []cipher.Address) coin.AddressUxOuts
- func (up *Unspents) GetUxHash() cipher.SHA256
- func (up *Unspents) Len() uint64
- func (up *Unspents) ProcessBlock(b *coin.SignedBlock) bucket.TxHandler
- type Walker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewErrUnspentNotExist ¶
NewErrUnspentNotExist creates ErrUnspentNotExist from a UxID
Types ¶
type BlockSigs ¶
type BlockSigs interface {
AddWithTx(*bolt.Tx, cipher.SHA256, cipher.Sig) error
Get(hash cipher.SHA256) (cipher.Sig, bool, error)
}
BlockSigs block signature storage
type BlockTree ¶
type BlockTree interface {
AddBlockWithTx(tx *bolt.Tx, b *coin.Block) error
GetBlock(hash cipher.SHA256) *coin.Block
GetBlockInDepth(dep uint64, filter func(hps []coin.HashPair) cipher.SHA256) *coin.Block
}
BlockTree block storage
type Blockchain ¶
Blockchain maintain the buckets for blockchain
func NewBlockchain ¶
func NewBlockchain(db *bolt.DB, walker Walker) (*Blockchain, error)
NewBlockchain creates a new blockchain instance
func (*Blockchain) AddBlockWithTx ¶
func (bc *Blockchain) AddBlockWithTx(tx *bolt.Tx, sb *coin.SignedBlock) error
AddBlockWithTx adds signed block
func (*Blockchain) GetBlockByHash ¶
func (bc *Blockchain) GetBlockByHash(hash cipher.SHA256) (*coin.SignedBlock, error)
GetBlockByHash returns signed block of given hash
func (*Blockchain) GetBlockBySeq ¶
func (bc *Blockchain) GetBlockBySeq(seq uint64) (*coin.SignedBlock, error)
GetBlockBySeq returns signed block of given seq
func (*Blockchain) GetGenesisBlock ¶
func (bc *Blockchain) GetGenesisBlock() *coin.SignedBlock
GetGenesisBlock returns genesis block
func (*Blockchain) Head ¶
func (bc *Blockchain) Head() (*coin.SignedBlock, error)
Head returns head block, returns error if no block does exist
func (*Blockchain) HeadSeq ¶
func (bc *Blockchain) HeadSeq() uint64
HeadSeq returns the head block sequence
func (*Blockchain) UnspentPool ¶
func (bc *Blockchain) UnspentPool() UnspentPool
UnspentPool returns the unspent pool
type ErrMissingSignature ¶
ErrMissingSignature is returned if no matching signature is found for a block in the db
func (ErrMissingSignature) Error ¶
func (e ErrMissingSignature) Error() string
type ErrUnspentNotExist ¶
type ErrUnspentNotExist struct {
UxID string
}
ErrUnspentNotExist is returned if an unspent is not found in the pool
func (ErrUnspentNotExist) Error ¶
func (e ErrUnspentNotExist) Error() string
type UnspentGetter ¶
type UnspentGetter interface {
// GetUnspentsOfAddrs returns all unspent outputs of given addresses
GetUnspentsOfAddrs(addrs []cipher.Address) coin.AddressUxOuts
Get(cipher.SHA256) (coin.UxOut, bool)
}
UnspentGetter provides unspend pool related querying methods
type UnspentPool ¶
type UnspentPool interface {
Len() uint64 // Len returns the length of unspent outputs pool
Get(cipher.SHA256) (coin.UxOut, bool) // Get returns outpus
GetAll() (coin.UxArray, error)
GetArray(hashes []cipher.SHA256) (coin.UxArray, error)
GetUxHash() cipher.SHA256
GetUnspentsOfAddrs(addrs []cipher.Address) coin.AddressUxOuts
ProcessBlock(*coin.SignedBlock) bucket.TxHandler
Contains(cipher.SHA256) bool
}
UnspentPool unspent outputs pool
type Unspents ¶
Unspents unspent outputs pool
func NewUnspentPool ¶
NewUnspentPool creates new unspent pool instance
func (*Unspents) GetAll ¶
GetAll returns Pool as an array. Note: they are not in any particular order.
func (*Unspents) GetArray ¶
GetArray returns UxOut by given hash array, will return error when if any of the hashes do not exist. It MUST return this error, to prevent double spend attacks.
func (*Unspents) GetUnspentsOfAddrs ¶
func (up *Unspents) GetUnspentsOfAddrs(addrs []cipher.Address) coin.AddressUxOuts
GetUnspentsOfAddrs returns unspent outputs map of given addresses, the address as return map key, unspent outputs as value.
func (*Unspents) GetUxHash ¶
GetUxHash returns unspent output checksum for the Block. Must be called after Block is fully initialized, and before its outputs are added to the unspent pool
func (*Unspents) ProcessBlock ¶
func (up *Unspents) ProcessBlock(b *coin.SignedBlock) bucket.TxHandler
ProcessBlock updates the unspent pool based upon the published block