core

package
v1.8.3-rc.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: GPL-3.0 Imports: 20 Imported by: 6

Documentation

Overview

Package core implements the core functionality of Istanbul consensus engine. The package defines `core` struct which stores all current consensus status such as validator set and round status. It also has accompanying methods to handle and broadcast messages between nodes.

In Istanbul consensus, there are 3 phases including Preprepare, Prepare and Commit. Each phase has its own message and by handling these messages the consensus can be made.

When a consensus is made for a given block, core communicates with the Istanbul backend to proceed.

Source Files

Core package is composed of following files

  • `backlog.go`: Implements core methods handling future messages. The future message is a message which has future timestamp or in a different phase
  • `commit.go`: Implements core methods which send, receive, handle, verify and accept commit messages
  • `core.go`: Defines core struct and its methods related to timer setup, start new round and round state update
  • `errors.go`: Defines consensus message related errors
  • `events.go`: Defines backlog event and timeout event
  • `final_committed.go`: Start a new round when a final committed proposal is stored
  • `handler.go`: Implements core.Engine.Start and Stop. Provides event and message hendlers
  • `message_set.go`: Defines messageSet struct which has a validator set and messages from other nodes
  • `prepare.go`: Implements core methods which send, receive, handle, verify and accept prepare phase messages
  • `preprepare.go`: Implements core methods which send, handle and accept preprepare messages
  • `request.go`: Implements core methods which handle, check, store and process preprepare messages
  • `roundchange.go`: Implement core methods receiving and handling roundchange messages
  • `roundstate.go`: Defines roundState struct which has messages of each phase for a round
  • `types.go`: Defines Engine interface and message, State type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(val interface{}) ([]byte, error)

func PrepareCommittedSeal

func PrepareCommittedSeal(hash common.Hash) []byte

PrepareCommittedSeal returns a committed seal for the given hash

Types

type Engine

type Engine interface {
	Start() error
	Stop() error
}

func New

func New(backend istanbul.Backend, config *istanbul.Config) Engine

New creates an Istanbul consensus core

type State

type State uint64
const (
	StateAcceptRequest State = iota
	StatePreprepared
	StatePrepared
	StateCommitted
)

func (State) Cmp

func (s State) Cmp(y State) int

Cmp compares s and y and returns:

-1 if s is the previous state of y
 0 if s and y are the same state
+1 if s is the next state of y

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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