headerfs

package
v0.0.0-...-dfc2b99 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: ISC Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockHeaderSize is the size in bytes of the Block header type.
	BlockHeaderSize = 80

	// FilterHeaderSize is the size in bytes of the RegularFilter
	// header type.
	FilterHeaderSize = 32

	TotalSize = BlockHeaderSize + FilterHeaderSize
)

Variables

View Source
var (
	// ErrHeightNotFound is returned when a specified height isn't found in
	// a target index.
	ErrHeightNotFound = Err.CodeWithDetail("ErrHeightNotFound",
		"target height not found in index")

	// ErrHashNotFound is returned when a specified block hash isn't found
	// in a target index.
	ErrHashNotFound = Err.CodeWithDetail("ErrHashNotFound",
		"target hash not found in index")
)
View Source
var Err er.ErrorType = er.NewErrorType("headerfs.Err")
View Source
var ErrHeaderNotFound = er.GenericErrorType.Code("headerfs.ErrHeaderNotFound")

ErrHeaderNotFound is returned when a target header on disk (flat file) can't be found.

Functions

This section is empty.

Types

type BlockHeader

type BlockHeader struct {
	*wire.BlockHeader
	// Height is the height of this block header within the current main
	// chain.
	Height uint32
}

BlockHeader is a Bitcoin block header that also has its height included.

type FilterHeader

type FilterHeader struct {
	// HeaderHash is the hash of the block header that this filter header
	// corresponds to.
	HeaderHash chainhash.Hash

	// FilterHash is the filter header itself.
	FilterHash chainhash.Hash

	// Height is the block height of the filter header in the main chain.
	Height uint32
}

FilterHeader represents a filter header (basic or extended). The filter header itself is coupled with the block height and hash of the filter's block.

type HeaderType

type HeaderType uint8

HeaderType is an enum-like type which defines the various header types that are stored within the index.

const (
	// Block is the header type that represents regular Bitcoin block
	// headers.
	Block HeaderType = iota

	// RegularFilter is a header type that represents the basic filter
	// header type for the filter header chain.
	RegularFilter
)

type NeutrinoDBStore

type NeutrinoDBStore struct {
	Db walletdb.DB
	// contains filtered or unexported fields
}

func NewNeutrinoDBStore

func NewNeutrinoDBStore(db walletdb.DB, netParams *chaincfg.Params, verify bool) (*NeutrinoDBStore, er.R)

NewNeutrinoDBStore creates a new instance of the NeutrinoDBStore based on a target file path, an open database instance, and finally a set of parameters for the target chain. These parameters are required as if this is the initial start up of the NeutrinoDBStore, then the initial genesis header will need to be inserted.

func (*NeutrinoDBStore) BlockChainTip

func (h *NeutrinoDBStore) BlockChainTip() (*wire.BlockHeader, uint32, er.R)

ChainTip returns the best known block header and height for the blockHeaderStore.

NOTE: Part of the BlockHeaderStore interface.

func (*NeutrinoDBStore) BlockChainTip1

func (h *NeutrinoDBStore) BlockChainTip1(tx walletdb.ReadTx) (*wire.BlockHeader, uint32, er.R)

func (*NeutrinoDBStore) CheckConnectivity

func (h *NeutrinoDBStore) CheckConnectivity(tx walletdb.ReadTx) er.R

CheckConnectivity cycles through all of the block headers on disk, from last to first, and makes sure they all connect to each other. Additionally, at each block header, we also ensure that the index entry for that height and hash also match up properly.

func (*NeutrinoDBStore) FetchBlockHeader

func (h *NeutrinoDBStore) FetchBlockHeader(hash *chainhash.Hash) (*wire.BlockHeader, uint32, er.R)

FetchHeader attempts to retrieve a block header determined by the passed block height.

NOTE: Part of the BlockHeaderStore interface.

func (*NeutrinoDBStore) FetchBlockHeader1

func (h *NeutrinoDBStore) FetchBlockHeader1(tx walletdb.ReadTx, hash *chainhash.Hash) (
	*wire.BlockHeader, uint32, er.R,
)

func (*NeutrinoDBStore) FetchBlockHeaderAncestors

func (h *NeutrinoDBStore) FetchBlockHeaderAncestors(
	numHeaders uint32,
	stopHash *chainhash.Hash,
) ([]wire.BlockHeader, uint32, er.R)

FetchHeaderAncestors fetches the numHeaders block headers that are the ancestors of the target stop hash. A total of numHeaders+1 headers will be returned, as we'll walk back numHeaders distance to collect each header, then return the final header specified by the stop hash. We'll also return the starting height of the header range as well so callers can compute the height of each header without knowing the height of the stop hash.

NOTE: Part of the BlockHeaderStore interface.

func (*NeutrinoDBStore) FetchBlockHeaderByHeight

func (h *NeutrinoDBStore) FetchBlockHeaderByHeight(height uint32) (*wire.BlockHeader, er.R)

FetchHeaderByHeight attempts to retrieve a target block header based on a block height.

NOTE: Part of the BlockHeaderStore interface.

func (*NeutrinoDBStore) FetchBlockHeaderByHeight1

func (h *NeutrinoDBStore) FetchBlockHeaderByHeight1(
	tx walletdb.ReadTx,
	height uint32,
) (*wire.BlockHeader, er.R)

func (*NeutrinoDBStore) FetchFilterHeader

func (f *NeutrinoDBStore) FetchFilterHeader(hash *chainhash.Hash) (*chainhash.Hash, er.R)

FetchHeader returns the filter header that corresponds to the passed block height.

func (*NeutrinoDBStore) FetchFilterHeader1

func (f *NeutrinoDBStore) FetchFilterHeader1(tx walletdb.ReadTx, hash *chainhash.Hash) (*chainhash.Hash, er.R)

func (*NeutrinoDBStore) FetchFilterHeaderAncestors

func (f *NeutrinoDBStore) FetchFilterHeaderAncestors(
	numHeaders uint32,
	stopHash *chainhash.Hash,
) ([]chainhash.Hash, uint32, er.R)

FetchHeaderAncestors fetches the numHeaders filter headers that are the ancestors of the target stop block hash. A total of numHeaders+1 headers will be returned, as we'll walk back numHeaders distance to collect each header, then return the final header specified by the stop hash. We'll also return the starting height of the header range as well so callers can compute the height of each header without knowing the height of the stop hash.

func (*NeutrinoDBStore) FetchFilterHeaderByHeight

func (f *NeutrinoDBStore) FetchFilterHeaderByHeight(height uint32) (*chainhash.Hash, er.R)

FetchHeaderByHeight returns the filter header for a particular block height.

func (*NeutrinoDBStore) FilterChainTip

func (f *NeutrinoDBStore) FilterChainTip() (*chainhash.Hash, uint32, er.R)

ChainTip returns the latest filter header and height known to the FilterHeaderStore.

func (*NeutrinoDBStore) FilterChainTip1

func (h *NeutrinoDBStore) FilterChainTip1(tx walletdb.ReadTx) (*chainhash.Hash, uint32, er.R)

func (*NeutrinoDBStore) HeightFromHash

func (h *NeutrinoDBStore) HeightFromHash(hash *chainhash.Hash) (uint32, er.R)

HeightFromHash returns the height of a particular block header given its hash.

NOTE: Part of the BlockHeaderStore interface.

func (*NeutrinoDBStore) HeightFromHash1

func (h *NeutrinoDBStore) HeightFromHash1(tx walletdb.ReadTx, hash *chainhash.Hash) (uint32, er.R)

func (*NeutrinoDBStore) LatestBlockLocator

func (h *NeutrinoDBStore) LatestBlockLocator() (blockchain.BlockLocator, er.R)

LatestBlockLocator returns the latest block locator object based on the tip of the current main chain from the PoV of the database and flat files.

NOTE: Part of the BlockHeaderStore interface.

func (*NeutrinoDBStore) RollbackLastBlock

func (h *NeutrinoDBStore) RollbackLastBlock(tx walletdb.ReadWriteTx) (*RollbackHeader, er.R)

func (*NeutrinoDBStore) WriteBlockHeaders

func (h *NeutrinoDBStore) WriteBlockHeaders(tx walletdb.ReadWriteTx, hdrs ...BlockHeader) er.R

WriteHeaders writes a set of headers to disk.

NOTE: Part of the BlockHeaderStore interface.

func (*NeutrinoDBStore) WriteFilterHeaders

func (f *NeutrinoDBStore) WriteFilterHeaders(tx walletdb.ReadWriteTx, hdrs ...FilterHeader) er.R

WriteHeaders writes a batch of filter headers to persistent storage. The headers themselves are appended to the flat file, and then the index updated to reflect the new entires.

type RollbackHeader

type RollbackHeader struct {
	BlockHeader  *waddrmgr.BlockStamp
	FilterHeader *chainhash.Hash
}

Jump to

Keyboard shortcuts

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