consensus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2017 License: LGPL-3.0 Imports: 1 Imported by: 0

README

consensus

Src of consensus algorithm, obviously.

Documentation

Index

Constants

View Source
const (
	NetMessageEvent = "event.netmessage"
	NewBlockEvent   = "event.newblock"
	CanMiningEvent  = "event.canmining"
)

EventType list

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseEvent

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

BaseEvent is a kind of event structure

func (*BaseEvent) Data

func (e *BaseEvent) Data() interface{}

Data of an event instance

func (*BaseEvent) EventType

func (e *BaseEvent) EventType() EventType

EventType of an event instance

type Consensus

type Consensus interface {
	Start()
	Stop()

	CanMining() bool
	SetCanMining(bool)

	TransitByKey(from, to string, data interface{})
	Transit(from, to State, data interface{})

	VerifyBlock(*core.Block) error
}

Consensus interface of consensus algorithm.

type Event

type Event interface {
	EventType() EventType
	Data() interface{}
}

Event in Consensus State-Machine

func NewBaseEvent

func NewBaseEvent(t EventType, data interface{}) Event

NewBaseEvent creates an event

type EventType

type EventType string

EventType of Events in Consensus State-Machine

type State

type State interface {
	Event(e Event) (bool, State)
	Enter(data interface{})
	Leave(data interface{})
}

State in Consensus State-Machine

type States

type States map[string]State

States contains all possible states in Consensus State-Machine

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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