consensus

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConsensus

func NewConsensus(genesisTime time.Time, ch ch) *committee

Types

type ByBalance

type ByBalance []*VoteDetails

func (ByBalance) Len

func (a ByBalance) Len() int

func (ByBalance) Less

func (a ByBalance) Less(i, j int) bool

func (ByBalance) Swap

func (a ByBalance) Swap(i, j int)

type Consensus

type Consensus interface {
	Verifier
	Subscriber
	Reader
	Life
}

type Event

type Event struct {
	Gid     types.Gid
	Address types.Address
	Stime   time.Time
	Etime   time.Time

	Timestamp      time.Time  // add to block
	SnapshotHash   types.Hash // add to block
	SnapshotHeight uint64     // add to block

	VoteTime time.Time // voteTime
}

type Life

type Life interface {
	Start()
	Init() error
	Stop()
}

type MockConsensus

type MockConsensus struct {
}

func (*MockConsensus) Subscribe

func (*MockConsensus) Subscribe(gid types.Gid, id string, addr *types.Address, fn func(Event))

func (*MockConsensus) SubscribeProducers added in v1.2.0

func (*MockConsensus) SubscribeProducers(gid types.Gid, id string, fn func(event ProducersEvent))

func (*MockConsensus) UnSubscribe

func (*MockConsensus) UnSubscribe(gid types.Gid, id string)

func (*MockConsensus) UnSubscribeProducers added in v1.2.0

func (*MockConsensus) UnSubscribeProducers(gid types.Gid, id string)

func (*MockConsensus) VerifyAccountProducer

func (*MockConsensus) VerifyAccountProducer(block *ledger.AccountBlock) (bool, error)

func (*MockConsensus) VerifySnapshotProducer

func (*MockConsensus) VerifySnapshotProducer(block *ledger.SnapshotBlock) (bool, error)

type ProducersEvent added in v1.2.0

type ProducersEvent struct {
	Addrs []types.Address
	Index uint64
	Gid   types.Gid
}

type Reader

type Reader interface {
	ReadByIndex(gid types.Gid, index uint64) ([]*Event, uint64, error)
	ReadByTime(gid types.Gid, t time.Time) ([]*Event, uint64, error)
	ReadVoteMapByTime(gid types.Gid, index uint64) ([]*VoteDetails, *ledger.HashHeight, error)
	ReadVoteMapForAPI(gid types.Gid, t time.Time) ([]*VoteDetails, *ledger.HashHeight, error)
	VoteTimeToIndex(gid types.Gid, t2 time.Time) (uint64, error)
	VoteIndexToTime(gid types.Gid, i uint64) (*time.Time, *time.Time, error)
}

type Subscriber

type Subscriber interface {
	Subscribe(gid types.Gid, id string, addr *types.Address, fn func(Event))
	UnSubscribe(gid types.Gid, id string)
	SubscribeProducers(gid types.Gid, id string, fn func(event ProducersEvent))
}

type Verifier

type Verifier interface {
	VerifyAccountProducer(block *ledger.AccountBlock) (bool, error)
	VerifySnapshotProducer(block *ledger.SnapshotBlock) (bool, error)
}

type VoteDetails

type VoteDetails struct {
	core.Vote
	CurrentAddr  types.Address
	RegisterList []types.Address
	Addr         map[types.Address]*big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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