Documentation ¶
Index ¶
- func FindBlockNonce(h *types.BlockHeader, target types.BlockID)
- func JustChainIndexes(blocks []types.Block) []types.ChainIndex
- func JustHeaders(blocks []types.Block) []types.BlockHeader
- func JustTransactionIDs(blocks []types.Block) [][]types.TransactionID
- func JustTransactions(blocks []types.Block) [][]types.Transaction
- type ChainSim
- func (cs *ChainSim) Fork() *ChainSim
- func (cs *ChainSim) MineBlock() types.Block
- func (cs *ChainSim) MineBlockWithSiacoinOutputs(scos ...types.SiacoinOutput) types.Block
- func (cs *ChainSim) MineBlockWithTxns(txns ...types.Transaction) types.Block
- func (cs *ChainSim) MineBlocks(n int) []types.Block
- func (cs *ChainSim) TxnWithSiacoinOutputs(scos ...types.SiacoinOutput) types.Transaction
- type EphemeralStore
- func (es *EphemeralStore) AddCheckpoint(c consensus.Checkpoint) error
- func (es *EphemeralStore) BestIndex(height uint64) (types.ChainIndex, error)
- func (es *EphemeralStore) Checkpoint(index types.ChainIndex) (consensus.Checkpoint, error)
- func (es *EphemeralStore) Close() error
- func (es *EphemeralStore) ExtendBest(index types.ChainIndex) error
- func (es *EphemeralStore) Flush() error
- func (es *EphemeralStore) Header(index types.ChainIndex) (types.BlockHeader, error)
- func (es *EphemeralStore) RewindBest() error
- type FlatStore
- func (fs *FlatStore) AddCheckpoint(c consensus.Checkpoint) error
- func (fs *FlatStore) BestIndex(height uint64) (index types.ChainIndex, err error)
- func (fs *FlatStore) Checkpoint(index types.ChainIndex) (c consensus.Checkpoint, err error)
- func (fs *FlatStore) Close() (err error)
- func (fs *FlatStore) ExtendBest(index types.ChainIndex) error
- func (fs *FlatStore) Flush() error
- func (fs *FlatStore) Header(index types.ChainIndex) (types.BlockHeader, error)
- func (fs *FlatStore) RewindBest() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindBlockNonce ¶
func FindBlockNonce(h *types.BlockHeader, target types.BlockID)
FindBlockNonce finds a block nonce meeting the target.
func JustChainIndexes ¶
func JustChainIndexes(blocks []types.Block) []types.ChainIndex
JustChainIndexes returns only the chain index of each block.
func JustHeaders ¶
func JustHeaders(blocks []types.Block) []types.BlockHeader
JustHeaders renters only the headers of each block.
func JustTransactionIDs ¶
func JustTransactionIDs(blocks []types.Block) [][]types.TransactionID
JustTransactionIDs returns only the transaction ids included in each block.
func JustTransactions ¶
func JustTransactions(blocks []types.Block) [][]types.Transaction
JustTransactions returns only the transactions of each block.
Types ¶
type ChainSim ¶
type ChainSim struct { Genesis consensus.Checkpoint Chain []types.Block State consensus.State // contains filtered or unexported fields }
ChainSim represents a simulation of a blockchain.
func NewChainSim ¶
func NewChainSim() *ChainSim
NewChainSim returns a new ChainSim useful for simulating forks.
func (*ChainSim) MineBlockWithSiacoinOutputs ¶
func (cs *ChainSim) MineBlockWithSiacoinOutputs(scos ...types.SiacoinOutput) types.Block
MineBlockWithSiacoinOutputs mines a block with a transaction containing the specified siacoin outputs. The ChainSim must have funds equal to or exceeding the sum of the outputs.
func (*ChainSim) MineBlockWithTxns ¶
func (cs *ChainSim) MineBlockWithTxns(txns ...types.Transaction) types.Block
MineBlockWithTxns mine a block with the given transaction.
func (*ChainSim) MineBlocks ¶
MineBlocks mine a number of blocks.
func (*ChainSim) TxnWithSiacoinOutputs ¶
func (cs *ChainSim) TxnWithSiacoinOutputs(scos ...types.SiacoinOutput) types.Transaction
TxnWithSiacoinOutputs returns a transaction containing the specified outputs. The ChainSim must have funds equal to or exceeding the sum of the outputs.
type EphemeralStore ¶
type EphemeralStore struct {
// contains filtered or unexported fields
}
EphemeralStore implements chain.ManagerStore in memory.
func NewEphemeralStore ¶
func NewEphemeralStore(c consensus.Checkpoint) *EphemeralStore
NewEphemeralStore returns an in-memory chain.ManagerStore.
func (*EphemeralStore) AddCheckpoint ¶
func (es *EphemeralStore) AddCheckpoint(c consensus.Checkpoint) error
AddCheckpoint implements chain.ManagerStore.
func (*EphemeralStore) BestIndex ¶
func (es *EphemeralStore) BestIndex(height uint64) (types.ChainIndex, error)
BestIndex implements chain.ManagerStore.
func (*EphemeralStore) Checkpoint ¶
func (es *EphemeralStore) Checkpoint(index types.ChainIndex) (consensus.Checkpoint, error)
Checkpoint implements chain.ManagerStore.
func (*EphemeralStore) Close ¶
func (es *EphemeralStore) Close() error
Close implements chain.ManagerStore.
func (*EphemeralStore) ExtendBest ¶
func (es *EphemeralStore) ExtendBest(index types.ChainIndex) error
ExtendBest implements chain.ManagerStore.
func (*EphemeralStore) Flush ¶
func (es *EphemeralStore) Flush() error
Flush implements chain.ManagerStore.
func (*EphemeralStore) Header ¶
func (es *EphemeralStore) Header(index types.ChainIndex) (types.BlockHeader, error)
Header implements chain.ManagerStore.
func (*EphemeralStore) RewindBest ¶
func (es *EphemeralStore) RewindBest() error
RewindBest implements chain.ManagerStore.
type FlatStore ¶
type FlatStore struct {
// contains filtered or unexported fields
}
FlatStore implements chain.ManagerStore with persistent files.
func NewFlatStore ¶
func NewFlatStore(dir string, c consensus.Checkpoint) (*FlatStore, consensus.Checkpoint, error)
NewFlatStore returns a FlatStore that stores data in the specified dir.
func (*FlatStore) AddCheckpoint ¶
func (fs *FlatStore) AddCheckpoint(c consensus.Checkpoint) error
AddCheckpoint implements chain.ManagerStore.
func (*FlatStore) BestIndex ¶
func (fs *FlatStore) BestIndex(height uint64) (index types.ChainIndex, err error)
BestIndex implements chain.ManagerStore.
func (*FlatStore) Checkpoint ¶
func (fs *FlatStore) Checkpoint(index types.ChainIndex) (c consensus.Checkpoint, err error)
Checkpoint implements chain.ManagerStore.
func (*FlatStore) ExtendBest ¶
func (fs *FlatStore) ExtendBest(index types.ChainIndex) error
ExtendBest implements chain.ManagerStore.
func (*FlatStore) Header ¶
func (fs *FlatStore) Header(index types.ChainIndex) (types.BlockHeader, error)
Header implements chain.ManagerStore.
func (*FlatStore) RewindBest ¶
RewindBest implements chain.ManagerStore.