headers

package
v0.0.0-...-34de315 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExist    = errors.New("header already exists")
	ErrNotExist = errors.New("header does not exist")
)

Errors exported by the package.

Functions

This section is empty.

Types

type Repo

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

Repo manages block headers and the best path through the tree of headers by using a topological sort of the headers to identify the path with the longest distance.

func NewRepo

func NewRepo(root *types.Header) *Repo

NewRepo creates a new simple header store. TODO: load the headers from disk on startup

func (*Repo) Add

func (hr *Repo) Add(header *types.Header) error

Add adds a new header to the graph.

func (*Repo) Get

func (hr *Repo) Get(hash types.Hash) (*types.Header, error)

Get returns the header with the given hash.

func (*Repo) Has

func (hr *Repo) Has(hash types.Hash) bool

Has checks if the given hash is already known.

func (*Repo) Path

func (hr *Repo) Path() ([]types.Hash, uint64)

Path returns the best path of the graph by total difficulty.

Jump to

Keyboard shortcuts

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