Documentation ¶
Overview ¶
Package txdb provides storage for Chain Protocol blockchain data structures.
Index ¶
- func DecodeSnapshot(data []byte) (*state.Snapshot, error)
- func ListenBlocks(ctx context.Context, dbURL string) (<-chan uint64, error)
- type Store
- func (s *Store) FinalizeBlock(ctx context.Context, height uint64) error
- func (s *Store) GetBlock(ctx context.Context, height uint64) (*legacy.Block, error)
- func (s *Store) GetRawBlock(ctx context.Context, height uint64) ([]byte, error)
- func (s *Store) GetSnapshot(ctx context.Context, height uint64) ([]byte, error)
- func (s *Store) Height(ctx context.Context) (uint64, error)
- func (s *Store) LatestSnapshot(ctx context.Context) (*state.Snapshot, uint64, error)
- func (s *Store) LatestSnapshotInfo(ctx context.Context) (height uint64, size uint64, err error)
- func (s *Store) SaveBlock(ctx context.Context, block *legacy.Block) error
- func (s *Store) SaveSnapshot(ctx context.Context, height uint64, snapshot *state.Snapshot) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeSnapshot ¶
DecodeSnapshot decodes a snapshot from the Chain Core's binary, protobuf representation of the snapshot.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
A Store encapsulates storage for blockchain validation. It satisfies the interface protocol.Store, and provides additional methods for querying current data.
func NewStore ¶
NewStore creates and returns a new Store object.
For testing purposes, it is usually much faster and more convenient to use package chain/protocol/memstore instead.
func (*Store) FinalizeBlock ¶
func (*Store) GetBlock ¶
GetBlock looks up the block with the provided block height. If no block is found at that height, it returns an error that wraps sql.ErrNoRows.
func (*Store) GetRawBlock ¶
GetRawBlock queries the database for the block at the provided height. The block is returned as raw bytes.
func (*Store) GetSnapshot ¶
GetSnapshot returns the state snapshot stored at the provided height, in Chain Core's binary protobuf representation. If no snapshot exists at the provided height, an error is returned.
func (*Store) LatestSnapshot ¶
LatestSnapshot returns the most recent state snapshot stored in the database and its corresponding block height.
func (*Store) LatestSnapshotInfo ¶
LatestSnapshotInfo returns the height and size of the most recent state snapshot stored in the database.