chain

package
v0.0.7-alphanet Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToAddAccountBlockTransaction = errors.Errorf("failed to insert account-block-transaction")
	ErrPlasmaRatioIsWorse                 = errors.Errorf("plasma ratio is smaller for current block")
	ErrHashTieBreak                       = errors.Errorf("hash tie-break is worse for current block")

	// MaxAccountBlocksInMomentum takes into account batched account-blocks
	MaxAccountBlocksInMomentum = 100
)

Functions

func GotAllActiveSporksImplemented

func GotAllActiveSporksImplemented(store store.Momentum) (justNow *definition.Spork, unimplemented []*definition.Spork, err error)

Checks whatever or not all active sporks are implemented

func NewChain

func NewChain(chainManager db.Manager, genesis store.Genesis) *chain

func NewMomentumPool

func NewMomentumPool(chainManager db.Manager, genesis store.Genesis) *momentumPool

Types

type AccountPool

type AccountPool interface {
	// AddAccountBlockTransaction implements the whole logic required to manage an account-chain.
	// When inserting a new account-block-transaction, is possible to trigger rollbacks of other unconfirmed account-blocks.
	//
	// Note: A confirmed account-block will never be rollback.
	//
	// In case a fork is detected, there is a deterministic way to find the longest chain, as follows:
	//  - the account-block with the biggest TotalPlasma/BasePlasma is selected
	//  - the account-block with the smallest hash
	AddAccountBlockTransaction(insertLocker sync.Locker, transaction *nom.AccountBlockTransaction) error
	ForceAddAccountBlockTransaction(insertLocker sync.Locker, transaction *nom.AccountBlockTransaction) error

	GetPatch(address types.Address, identifier types.HashHeight) db.Patch
	GetAccountStore(address types.Address, identifier types.HashHeight) store.Account
	GetFrontierAccountStore(address types.Address) store.Account

	GetNewMomentumContent() []*nom.AccountBlock
	GetAllUncommittedAccountBlocks() []*nom.AccountBlock
	GetUncommittedAccountBlocksByAddress(address types.Address) []*nom.AccountBlock
}

func NewAccountPool

func NewAccountPool(stable Stable) AccountPool

type Chain

type Chain interface {
	Init() error
	Start() error
	Stop() error

	// AcquireInsert is used to limit insert operations in a global way inside the chain module.
	// The actual sync.Locker object returned is used for logging purposes and any method receiving such argument
	// does not enforce in any way the validity, only the fact that is non-nil.
	AcquireInsert(reason string) sync.Locker

	store.Genesis
	AccountPool
	MomentumPool
	MomentumEventManager
}

type MomentumEventListener

type MomentumEventListener interface {
	InsertMomentum(*nom.DetailedMomentum)
	DeleteMomentum(*nom.DetailedMomentum)
}

type MomentumEventManager

type MomentumEventManager interface {
	Register(MomentumEventListener)
	UnRegister(MomentumEventListener)
}

type MomentumPool

type MomentumPool interface {
	AddMomentumTransaction(insertLocker sync.Locker, transaction *nom.MomentumTransaction) error
	RollbackTo(insertLocker sync.Locker, identifier types.HashHeight) error

	GetFrontierMomentumStore() store.Momentum
	GetMomentumStore(identifier types.HashHeight) store.Momentum
}

type Stable

type Stable interface {
	GetStableAccountDB(address types.Address) db.DB
}

Directories

Path Synopsis
Package nom is a generated protocol buffer package.
Package nom is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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