txdb

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2017 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package txdb provides storage for Chain Protocol blockchain data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeSnapshot

func DecodeSnapshot(data []byte) (*state.Snapshot, error)

DecodeSnapshot decodes a snapshot from the Chain Core's binary, protobuf representation of the snapshot.

func LoadBlock

func LoadBlock(db dbm.DB, height uint64) *legacy.Block

Types

type BlockStoreStateJSON

type BlockStoreStateJSON struct {
	Height uint64
}

func LoadBlockStoreStateJSON

func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON

func (BlockStoreStateJSON) Save

func (bsj BlockStoreStateJSON) Save(db dbm.DB)

type SnapshotHeightJSON

type SnapshotHeightJSON struct {
	Height uint64
}

func LoadSnapshotHeightJSON

func LoadSnapshotHeightJSON(db dbm.DB) SnapshotHeightJSON

func (SnapshotHeightJSON) Save

func (bsj SnapshotHeightJSON) Save(db dbm.DB)

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

func NewStore(db dbm.DB) *Store

NewStore creates and returns a new Store object.

For testing purposes, it is usually much faster and more convenient to use package bytom/protocol/memstore instead.

func (*Store) FinalizeBlock

func (s *Store) FinalizeBlock(ctx context.Context, height uint64) error

func (*Store) GetBlock

func (s *Store) GetBlock(height uint64) (*legacy.Block, error)

func (*Store) GetRawBlock

func (s *Store) GetRawBlock(height uint64) ([]byte, error)

func (*Store) GetSnapshot

func (s *Store) GetSnapshot(ctx context.Context, height uint64) ([]byte, error)

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) Height

func (s *Store) Height() uint64

Height returns the height of the blockchain.

func (*Store) LatestSnapshot

func (s *Store) LatestSnapshot(ctx context.Context) (*state.Snapshot, uint64, error)

LatestSnapshot returns the most recent state snapshot stored in the database and its corresponding block height.

func (*Store) SaveBlock

func (s *Store) SaveBlock(block *legacy.Block) error

SaveBlock persists a new block in the database.

func (*Store) SaveSnapshot

func (s *Store) SaveSnapshot(ctx context.Context, height uint64, snapshot *state.Snapshot) error

SaveSnapshot saves a state snapshot to the database.

Directories

Path Synopsis
internal
storage
Package storage is a generated protocol buffer package.
Package storage is a generated protocol buffer package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL