chains

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParentNotFound = fmt.Errorf("parent not found")
	ErrRefNotFound    = fmt.Errorf("reference block not found")
)

Functions

This section is empty.

Types

type Block

type Block struct {
	ID        proto.BlockID
	Parent    proto.BlockID
	Height    uint32
	Generator proto.WavesAddress
	Score     *big.Int
	Timestamp uint64
}

type Fork

type Fork struct {
	Longest         bool               `json:"longest"`           // Indicates that the fork is the longest.
	HeadBlock       proto.BlockID      `json:"head_block"`        // The last block of the fork.
	HeadTimestamp   time.Time          `json:"head_timestamp"`    // The timestamp of the last block of the fork.
	HeadGenerator   proto.WavesAddress `json:"head_generator"`    // The generator of the last block of the fork.
	HeadHeight      uint32             `json:"head_height"`       // The height of the last block of the fork.
	Score           *big.Int           `json:"score"`             // The score of the fork.
	PeersCount      int                `json:"peers_count"`       // The number of peers that seen the fork.
	Peers           []netip.Addr       `json:"peers"`             // Peers that seen on the fork.
	LastCommonBlock proto.BlockID      `json:"last_common_block"` // The last common block with the longest fork.
	Length          int                `json:"length"`            // The number of blocks since the last common block.
}
type Head struct {
	ID      uint64
	BlockID proto.BlockID
}

func (*Head) String

func (h *Head) String() string

type HistoryProvider

type HistoryProvider interface {
	Leasher
	LCB(addr netip.Addr) (proto.BlockID, error)
	HasBlock(id proto.BlockID) (bool, error)
	LastIDs(id proto.BlockID, count int) ([]proto.BlockID, error)
	PutBlock(block *proto.Block, addr netip.Addr) error
}

type Leash

type Leash struct {
	Addr    netip.Addr
	BlockID proto.BlockID
}

type Leasher

type Leasher interface {
	Leash(addr netip.Addr) (proto.BlockID, error)
	MoveLeash(id proto.BlockID, addr netip.Addr) error
}

type Linkage

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

func NewLinkage

func NewLinkage(path string, scheme proto.Scheme, genesis proto.Block) (*Linkage, error)

func (*Linkage) ActiveHeads

func (l *Linkage) ActiveHeads() ([]Head, error)

ActiveHeads returns list of heads pointed by peers.

func (*Linkage) Block

func (l *Linkage) Block(id proto.BlockID) (Block, error)

func (*Linkage) Close

func (l *Linkage) Close()

func (*Linkage) Fork

func (l *Linkage) Fork(peer netip.Addr) (Fork, error)

func (*Linkage) Forks

func (l *Linkage) Forks(peers []netip.Addr) ([]Fork, error)

func (*Linkage) HasBlock

func (l *Linkage) HasBlock(id proto.BlockID) (bool, error)

func (*Linkage) HasLeash

func (l *Linkage) HasLeash(addr netip.Addr) (bool, error)

func (*Linkage) Heads

func (l *Linkage) Heads() ([]Head, error)

Heads returns list of all chains heads.

func (*Linkage) LCB added in v0.3.2

func (l *Linkage) LCB(peer netip.Addr) (proto.BlockID, error)

LCB returns the last common block with the longest chain. For the unleashed peer the genesis block ID is returned.

func (*Linkage) LastIDs

func (l *Linkage) LastIDs(id proto.BlockID, count int) ([]proto.BlockID, error)

func (*Linkage) Leash

func (l *Linkage) Leash(addr netip.Addr) (proto.BlockID, error)

Leash return the block ID the peer is leashed to. For an unleashed peer the genesis block ID is returned.

func (*Linkage) LeashScore

func (l *Linkage) LeashScore(addr netip.Addr) (*proto.Score, error)

LeashScore returns the score of the peer's leash. For an unleashed peer the score of genesis block is returned. Error indicates a general storage failure.

func (*Linkage) Leashes

func (l *Linkage) Leashes() ([]Leash, error)

func (*Linkage) LogInitialStats

func (l *Linkage) LogInitialStats()

func (*Linkage) MoveLeash

func (l *Linkage) MoveLeash(id proto.BlockID, addr netip.Addr) error

func (*Linkage) PutBlock

func (l *Linkage) PutBlock(block *proto.Block, addr netip.Addr) error

func (*Linkage) PutMicroBlock

func (l *Linkage) PutMicroBlock(inv *proto.MicroBlockInv, addr netip.Addr) error

func (*Linkage) Stats

func (l *Linkage) Stats() (Stats, error)

type Stats

type Stats struct {
	Short int
	Long  int
}

Jump to

Keyboard shortcuts

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