scp

package module
v0.0.0-...-c6706d5 Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: MIT Imports: 3 Imported by: 2

README

Go implementation of Stellar Consensus Protocol

This is definitely not production ready, but you can give it a try.

Deviations from whitepaper:
  • Parallel nomination (no leader election)
  • Catch up injected into protocol

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Combiner

type Combiner interface {
	CombineValues(...Value) Value
}

type Config

type Config struct {
	NodeID       string
	CurrentSlot  uint64
	Validator    Validator
	Combiner     Combiner
	Ledger       Ledger
	SlotsLoader  SlotsLoader
	QuorumSlices []*QuorumSlice
}

type Consensus

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

func New

func New(cfg Config) *Consensus

func (*Consensus) InputMessage

func (c *Consensus) InputMessage(m *Message)

func (*Consensus) OutputMessage

func (c *Consensus) OutputMessage() *Message

func (*Consensus) Propose

func (c *Consensus) Propose(v Value)

func (*Consensus) Run

func (c *Consensus) Run()

type Ledger

type Ledger interface {
	PersistSlot(Slot)
}

type Message

type Message struct {
	Type MessageType

	SlotIndex uint64
	NodeID    string

	Counter uint32
	Value
}

type MessageType

type MessageType int
const (
	VoteNominate MessageType = iota + 1
	AcceptNominate

	VotePrepare
	AcceptPrepare

	VoteCommit
	AcceptCommit
)

type QuorumSlice

type QuorumSlice struct {
	Threshold   uint32
	Validators  map[string]struct{}
	InnerSlices []*QuorumSlice
}

type Slot

type Slot struct {
	Index uint64
	Value
}

type SlotsLoader

type SlotsLoader interface {
	LoadSlots(from uint64, to Slot) []Slot
}

type Validator

type Validator interface {
	ValidateValue(Value) bool
}

type Value

type Value []byte

Jump to

Keyboard shortcuts

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