local

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect() (chain.Handle, error)

Connect performs initialization for communication with the local blockchain.

Types

type AddHeadersEvent

type AddHeadersEvent struct {
	AnchorHeader []byte
	Headers      []byte
}

AddHeadersEvent represents an invocation of the AddHeaders method.

type AddHeadersWithRetargetEvent

type AddHeadersWithRetargetEvent struct {
	OldPeriodStartHeader []byte
	OldPeriodEndHeader   []byte
	Headers              []byte
}

AddHeadersWithRetargetEvent represents an invocation of the AddHeadersWithRetarget method.

type Chain

type Chain struct {
	// contains filtered or unexported fields
}

Chain is a local implementation of the host chain interface.

func (*Chain) AddHeaders

func (c *Chain) AddHeaders(anchorHeader []byte, headers []byte) error

AddHeaders adds headers to storage after validating. The anchorHeader parameter is the header immediately preceding the new chain. Headers parameter should be a tightly-packed list of 80-byte Bitcoin headers.

func (*Chain) AddHeadersEvents

func (c *Chain) AddHeadersEvents() []*AddHeadersEvent

AddHeadersEvents returns all invocations of the AddHeaders method for testing purposes.

func (*Chain) AddHeadersWithRetarget

func (c *Chain) AddHeadersWithRetarget(
	oldPeriodStartHeader []byte,
	oldPeriodEndHeader []byte,
	headers []byte,
) error

AddHeadersWithRetarget adds headers to storage, performs additional validation of retarget. The oldPeriodStartHeader is the first header in the difficulty period being closed while oldPeriodEndHeader is the last. Headers parameter should be a tightly-packed list of 80-byte Bitcoin headers.

func (*Chain) AddHeadersWithRetargetEvents

func (c *Chain) AddHeadersWithRetargetEvents() []*AddHeadersWithRetargetEvent

AddHeadersWithRetargetEvents returns all invocations of the AddHeadersWithRetarget method for testing purposes.

func (*Chain) FindHeight

func (c *Chain) FindHeight(digest btc.Digest) (*big.Int, error)

FindHeight finds the height of a header by its digest.

func (*Chain) GetBestKnownDigest

func (c *Chain) GetBestKnownDigest() (btc.Digest, error)

GetBestKnownDigest returns the best known digest.

func (*Chain) IsAncestor

func (c *Chain) IsAncestor(
	ancestorDigest btc.Digest,
	descendantDigest btc.Digest,
	limit *big.Int,
) (bool, error)

IsAncestor checks if ancestorDigest is an ancestor of the descendantDigest. The limit parameter determines the number of blocks to check.

func (*Chain) MarkNewHeaviest

func (c *Chain) MarkNewHeaviest(
	ancestorDigest btc.Digest,
	currentBestHeader []byte,
	newBestHeader []byte,
	limit *big.Int,
) error

MarkNewHeaviest gives a new starting point for the relay. The ancestorDigest param is the digest of the most recent common ancestor. The currentBestHeader is a 80-byte header referenced by bestKnownDigest while the newBestHeader param should be the header to mark as new best. Limit parameter limits the amount of traversal of the chain.

func (*Chain) MarkNewHeaviestEvents

func (c *Chain) MarkNewHeaviestEvents() []*MarkNewHeaviestEvent

MarkNewHeaviestEvents returns all invocations of the MarkNewHeaviest method for testing purposes.

func (*Chain) MarkNewHeaviestPreflight

func (c *Chain) MarkNewHeaviestPreflight(
	ancestorDigest btc.Digest,
	currentBestHeader []byte,
	newBestHeader []byte,
	limit *big.Int,
) bool

MarkNewHeaviestPreflight performs a preflight call of the MarkNewHeaviest method to check whether its execution will succeed.

func (*Chain) SetBestKnownDigest

func (c *Chain) SetBestKnownDigest(bestKnownDigest btc.Digest)

SetBestKnownDigest sets the internal best known digest for testing purposes.

type MarkNewHeaviestEvent

type MarkNewHeaviestEvent struct {
	AncestorDigest    btc.Digest
	CurrentBestHeader []byte
	NewBestHeader     []byte
	Limit             *big.Int
}

MarkNewHeaviestEvent represents an invocation of the MarkNewHeaviest method.

Jump to

Keyboard shortcuts

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