tortoise

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Namespace = "spacemesh"
	Subsystem = "consensus"
)
View Source
const (
	Window          = 25
	LocalThreshold  = 0.8 //ThetaL
	GlobalThreshold = 0.6 //ThetaG
	Genesis         = 0
)

Variables

View Source
var (
	//Opinion
	Support     = vec{1, 0}
	Against     = vec{0, 1}
	Abstain     = vec{0, 0}
	ZeroPattern = votingPattern{}
)

Functions

func Max

Types

type Algorithm

type Algorithm struct {
	Tortoise
	sync.Mutex
}

func NewAlgorithm

func NewAlgorithm(layerSize int, mdb *mesh.MeshDB, hdist int, lg log.Log) *Algorithm

func NewRecoveredAlgorithm

func NewRecoveredAlgorithm(mdb *mesh.MeshDB, lg log.Log) *Algorithm

func (*Algorithm) HandleIncomingLayer

func (alg *Algorithm) HandleIncomingLayer(ll *types.Layer) (types.LayerID, types.LayerID)

func (*Algorithm) HandleLateBlock

func (alg *Algorithm) HandleLateBlock(b *types.Block) (types.LayerID, types.LayerID)

func (*Algorithm) PersistTortoise added in v0.1.2

func (alg *Algorithm) PersistTortoise() error

type BlockIDLayerTuple

type BlockIDLayerTuple struct {
	types.BlockID
	types.LayerID
}

func (BlockIDLayerTuple) Id

func (blt BlockIDLayerTuple) Id() types.BlockID

func (BlockIDLayerTuple) Layer

func (blt BlockIDLayerTuple) Layer() types.LayerID

type Mesh

type Mesh interface {
	GetBlock(id types.BlockID) (*types.Block, error)
	LayerBlockIds(id types.LayerID) ([]types.BlockID, error)
	ForBlockInView(view map[types.BlockID]struct{}, layer types.LayerID, foo func(block *types.Block) (bool, error)) error
	SaveContextualValidity(id types.BlockID, valid bool) error
	Persist(key []byte, v interface{}) error
	Retrieve(key []byte, v interface{}) (interface{}, error)
}

type NinjaTortoise

type NinjaTortoise struct {
	log.Log
	Mesh //block cache
	// contains filtered or unexported fields
}

todo memory optimizations

func NewNinjaTortoise

func NewNinjaTortoise(layerSize int, blocks Mesh, hdist int, log log.Log) *NinjaTortoise

func (*NinjaTortoise) LatestComplete

func (ni *NinjaTortoise) LatestComplete() types.LayerID

func (*NinjaTortoise) PersistTortoise

func (ni *NinjaTortoise) PersistTortoise() error

func (*NinjaTortoise) RecoverTortoise

func (ni *NinjaTortoise) RecoverTortoise() (interface{}, error)

type PatternId

type PatternId uint32 //this hash dose not include the layer id

type Tortoise

type Tortoise interface {
	PersistTortoise() error
	LatestComplete() types.LayerID
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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