quorum

package
v0.0.0-...-e03aae4 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package quorum is a generated GoMock package.

Package quorum is a generated GoMock package.

Index

Constants

View Source
const (
	ProtocolVersionStr = "1.0.0"  // The same, as a string
	ProtocolName       = "quorum" // Nickname of the protocol in geth

	DefaultPrepareMinersTimeout = 10 * time.Second
	DefaultPingFrequency        = 10 * time.Second
	DefaultQuorumMaxPing        = 1200 * time.Millisecond
	DefaultHandshakeTimeout     = 3000 * time.Millisecond
)

quorum constants

Variables

View Source
var (
	ErrOnWriteMessage = errors.New("error during message writing")
	ErrHookValidate   = errors.New("error during hook validation")
	ErrHookApply      = errors.New("error during hook applying")
)
View Source
var (
	ErrOnGettingDistribution = errors.New("error during getCurrentDistribution contract call")
	ErrGettingSnapshot       = errors.New("error during snapshot nodes getting")
)
View Source
var DefaultConfig = Config{
	PrepareMinersTimeout: DefaultPrepareMinersTimeout,
	PingFrequency:        DefaultPingFrequency,
	QuorumMaxPing:        DefaultQuorumMaxPing,
	HandshakeTimeout:     DefaultHandshakeTimeout,
	Test:                 false,
}

DefaultConfig represents (shocker!) the default configuration.

View Source
var Spec = &protocols.Spec{
	Name:       "qrm",
	Version:    1,
	MaxMsgSize: 10 * 1024 * 1024,
	Messages: []interface{}{
		VoteMinerAddMsg{},
		VoteMinerDelMsg{},
		NodeCandidateListMsg{},
		MinersMsg{},
	},
}

Spec (QuorumSpec) is the spec of the quorum protocol ...

Functions

func SpecString

func SpecString(spec *protocols.Spec) string

Types

type API

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

API provides the quorum RPC service

func NewAPI

func NewAPI(q *Quorum) *API

NewAPI create a new RPC quorum service.

func (*API) AllNodes

func (api *API) AllNodes(_ context.Context) map[string]string

AllNodes returns all nodes known by quorum protocol (static & trusted nodes)

func (*API) MinerListAtRecentEpoch

func (api *API) MinerListAtRecentEpoch(_ context.Context) []common.Address

MinerListAtRecentEpoch returns miner list at recent epoch

func (*API) PeerList

func (api *API) PeerList(_ context.Context) *PeerListDTO

PeerList returns list of all connected peers

func (*API) PingList

func (api *API) PingList(_ context.Context) map[string]string

PingList returns peer list of quorum protocol (with satisfying ping duration)

func (*API) Snapshot

func (api *API) Snapshot(_ context.Context, epoch uint64) *snapshot.SnapDTO

func (*API) SnapshotSystem

func (api *API) SnapshotSystem(_ context.Context) *snapshot.SystemDTO

func (*API) SnapshotSystemEpochs

func (api *API) SnapshotSystemEpochs(_ context.Context) []uint64

func (*API) SnapshotSystemRecentEpoch

func (api *API) SnapshotSystemRecentEpoch(_ context.Context) uint64

func (*API) Version

func (api *API) Version(_ context.Context) string

Version returns the quorum sub-protocol version.

type Config

type Config struct {
	PrepareMinersTimeout time.Duration
	PingFrequency        time.Duration
	QuorumMaxPing        time.Duration
	HandshakeTimeout     time.Duration

	Test bool
}

Config represents the configuration state of a quorum service.

func (*Config) PingProtocolTimeout

func (c *Config) PingProtocolTimeout() time.Duration

type ContractService

type ContractService interface {
	GetCurrentDistribution(ctx context.Context) (distribution map[common.Address]uint64, err error)
}

type ContractServiceWith

type ContractServiceWith func(ctx context.Context) (distribution map[common.Address]uint64, err error)

func (ContractServiceWith) GetCurrentDistribution

func (c ContractServiceWith) GetCurrentDistribution(ctx context.Context) (distribution map[common.Address]uint64,
	err error)

type Handlers

type Handlers interface {
	HandleVoteMinerAddMsg(peer *Peer)
	HandleVoteMinerDelMsg(peer *Peer)
	HandleNodeCandidateListMsg(msg *NodeCandidateListMsg, peer *Peer)
	HandleMinersMsg(msg *MinersMsg, peer *Peer)
}

type MinersMsg

type MinersMsg struct {
	Epoch  *big.Int
	Hash   common.Hash
	Miners []common.Address
}

func NewMinersMsg

func NewMinersMsg(epoch uint64, miners []common.Address, hash common.Hash) *MinersMsg

type MockContractService

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

MockContractService is a mock of ContractService interface.

func NewMockContractService

func NewMockContractService(ctrl *gomock.Controller) *MockContractService

NewMockContractService creates a new mock instance.

func (*MockContractService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockContractService) GetCurrentDistribution

func (m *MockContractService) GetCurrentDistribution(ctx context.Context) (map[common.Address]uint64, error)

GetCurrentDistribution mocks base method.

type MockContractServiceMockRecorder

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

MockContractServiceMockRecorder is the mock recorder for MockContractService.

func (*MockContractServiceMockRecorder) GetCurrentDistribution

func (mr *MockContractServiceMockRecorder) GetCurrentDistribution(ctx interface{}) *gomock.Call

GetCurrentDistribution indicates an expected call of GetCurrentDistribution.

type MockHandlers

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

MockHandlers is a mock of Handlers interface.

func NewMockHandlers

func NewMockHandlers(ctrl *gomock.Controller) *MockHandlers

NewMockHandlers creates a new mock instance.

func (*MockHandlers) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockHandlers) HandleMinersMsg

func (m *MockHandlers) HandleMinersMsg(msg *MinersMsg, peer *Peer)

HandleMinersMsg mocks base method.

func (*MockHandlers) HandleNodeCandidateListMsg

func (m *MockHandlers) HandleNodeCandidateListMsg(msg *NodeCandidateListMsg, peer *Peer)

HandleNodeCandidateListMsg mocks base method.

func (*MockHandlers) HandleVoteMinerAddMsg

func (m *MockHandlers) HandleVoteMinerAddMsg(peer *Peer)

HandleVoteMinerAddMsg mocks base method.

func (*MockHandlers) HandleVoteMinerDelMsg

func (m *MockHandlers) HandleVoteMinerDelMsg(peer *Peer)

HandleVoteMinerDelMsg mocks base method.

type MockHandlersMockRecorder

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

MockHandlersMockRecorder is the mock recorder for MockHandlers.

func (*MockHandlersMockRecorder) HandleMinersMsg

func (mr *MockHandlersMockRecorder) HandleMinersMsg(msg, peer interface{}) *gomock.Call

HandleMinersMsg indicates an expected call of HandleMinersMsg.

func (*MockHandlersMockRecorder) HandleNodeCandidateListMsg

func (mr *MockHandlersMockRecorder) HandleNodeCandidateListMsg(msg, peer interface{}) *gomock.Call

HandleNodeCandidateListMsg indicates an expected call of HandleNodeCandidateListMsg.

func (*MockHandlersMockRecorder) HandleVoteMinerAddMsg

func (mr *MockHandlersMockRecorder) HandleVoteMinerAddMsg(peer interface{}) *gomock.Call

HandleVoteMinerAddMsg indicates an expected call of HandleVoteMinerAddMsg.

func (*MockHandlersMockRecorder) HandleVoteMinerDelMsg

func (mr *MockHandlersMockRecorder) HandleVoteMinerDelMsg(peer interface{}) *gomock.Call

HandleVoteMinerDelMsg indicates an expected call of HandleVoteMinerDelMsg.

type MockHook

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

MockHook is a mock of Hook interface.

func NewMockHook

func NewMockHook(ctrl *gomock.Controller) *MockHook

NewMockHook creates a new mock instance.

func (*MockHook) Apply

func (m *MockHook) Apply(peer *protocols.Peer, costToLocalNode int64, size uint32) error

Apply mocks base method.

func (*MockHook) EXPECT

func (m *MockHook) EXPECT() *MockHookMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockHook) Validate

func (m *MockHook) Validate(peer *protocols.Peer, size uint32, msg interface{}, payer protocols.Payer) (int64, error)

Validate mocks base method.

type MockHookMockRecorder

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

MockHookMockRecorder is the mock recorder for MockHook.

func (*MockHookMockRecorder) Apply

func (mr *MockHookMockRecorder) Apply(peer, costToLocalNode, size interface{}) *gomock.Call

Apply indicates an expected call of Apply.

func (*MockHookMockRecorder) Validate

func (mr *MockHookMockRecorder) Validate(peer, size, msg, payer interface{}) *gomock.Call

Validate indicates an expected call of Validate.

type MockMsgPauser

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

MockMsgPauser is a mock of MsgPauser interface.

func NewMockMsgPauser

func NewMockMsgPauser(ctrl *gomock.Controller) *MockMsgPauser

NewMockMsgPauser creates a new mock instance.

func (*MockMsgPauser) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMsgPauser) Pause

func (m *MockMsgPauser) Pause()

Pause mocks base method.

func (*MockMsgPauser) Resume

func (m *MockMsgPauser) Resume()

Resume mocks base method.

func (*MockMsgPauser) Wait

func (m *MockMsgPauser) Wait()

Wait mocks base method.

type MockMsgPauserMockRecorder

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

MockMsgPauserMockRecorder is the mock recorder for MockMsgPauser.

func (*MockMsgPauserMockRecorder) Pause

func (mr *MockMsgPauserMockRecorder) Pause() *gomock.Call

Pause indicates an expected call of Pause.

func (*MockMsgPauserMockRecorder) Resume

func (mr *MockMsgPauserMockRecorder) Resume() *gomock.Call

Resume indicates an expected call of Resume.

func (*MockMsgPauserMockRecorder) Wait

Wait indicates an expected call of Wait.

type MockP2PServer

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

MockP2PServer is a mock of P2PServer interface.

func NewMockP2PServer

func NewMockP2PServer(ctrl *gomock.Controller) *MockP2PServer

NewMockP2PServer creates a new mock instance.

func (*MockP2PServer) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockP2PServer) Self

func (m *MockP2PServer) Self() *enode.Node

Self mocks base method.

type MockP2PServerMockRecorder

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

MockP2PServerMockRecorder is the mock recorder for MockP2PServer.

func (*MockP2PServerMockRecorder) Self

Self indicates an expected call of Self.

type MockPeerListService

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

MockPeerListService is a mock of PeerListService interface.

func NewMockPeerListService

func NewMockPeerListService(ctrl *gomock.Controller) *MockPeerListService

NewMockPeerListService creates a new mock instance.

func (*MockPeerListService) AddPeer

func (m *MockPeerListService) AddPeer(p *Peer)

AddPeer mocks base method.

func (*MockPeerListService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPeerListService) GetSnapshotNodes

func (m *MockPeerListService) GetSnapshotNodes() ([]*snapshot.Node, error)

GetSnapshotNodes mocks base method.

func (*MockPeerListService) MarkSelfIsMinerCandidate

func (m *MockPeerListService) MarkSelfIsMinerCandidate(in bool)

MarkSelfIsMinerCandidate mocks base method.

func (*MockPeerListService) Peers

func (m *MockPeerListService) Peers() []*Peer

Peers mocks base method.

func (*MockPeerListService) PingList

func (m *MockPeerListService) PingList() []enode.ID

PingList mocks base method.

func (*MockPeerListService) PingListLen

func (m *MockPeerListService) PingListLen() int

PingListLen mocks base method.

func (*MockPeerListService) PingListPeers

func (m *MockPeerListService) PingListPeers() []*Peer

PingListPeers mocks base method.

func (*MockPeerListService) RemovePeer

func (m *MockPeerListService) RemovePeer(peerID enode.ID)

RemovePeer mocks base method.

func (*MockPeerListService) SelfIsMinerCandidate

func (m *MockPeerListService) SelfIsMinerCandidate() bool

SelfIsMinerCandidate mocks base method.

func (*MockPeerListService) ToDTO

func (m *MockPeerListService) ToDTO() *PeerListDTO

ToDTO mocks base method.

type MockPeerListServiceMockRecorder

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

MockPeerListServiceMockRecorder is the mock recorder for MockPeerListService.

func (*MockPeerListServiceMockRecorder) AddPeer

func (mr *MockPeerListServiceMockRecorder) AddPeer(p interface{}) *gomock.Call

AddPeer indicates an expected call of AddPeer.

func (*MockPeerListServiceMockRecorder) GetSnapshotNodes

func (mr *MockPeerListServiceMockRecorder) GetSnapshotNodes() *gomock.Call

GetSnapshotNodes indicates an expected call of GetSnapshotNodes.

func (*MockPeerListServiceMockRecorder) MarkSelfIsMinerCandidate

func (mr *MockPeerListServiceMockRecorder) MarkSelfIsMinerCandidate(in interface{}) *gomock.Call

MarkSelfIsMinerCandidate indicates an expected call of MarkSelfIsMinerCandidate.

func (*MockPeerListServiceMockRecorder) Peers

Peers indicates an expected call of Peers.

func (*MockPeerListServiceMockRecorder) PingList

PingList indicates an expected call of PingList.

func (*MockPeerListServiceMockRecorder) PingListLen

func (mr *MockPeerListServiceMockRecorder) PingListLen() *gomock.Call

PingListLen indicates an expected call of PingListLen.

func (*MockPeerListServiceMockRecorder) PingListPeers

func (mr *MockPeerListServiceMockRecorder) PingListPeers() *gomock.Call

PingListPeers indicates an expected call of PingListPeers.

func (*MockPeerListServiceMockRecorder) RemovePeer

func (mr *MockPeerListServiceMockRecorder) RemovePeer(peerID interface{}) *gomock.Call

RemovePeer indicates an expected call of RemovePeer.

func (*MockPeerListServiceMockRecorder) SelfIsMinerCandidate

func (mr *MockPeerListServiceMockRecorder) SelfIsMinerCandidate() *gomock.Call

SelfIsMinerCandidate indicates an expected call of SelfIsMinerCandidate.

func (*MockPeerListServiceMockRecorder) ToDTO

ToDTO indicates an expected call of ToDTO.

type MockPingPeerService

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

MockPingPeerService is a mock of PingPeerService interface.

func NewMockPingPeerService

func NewMockPingPeerService(ctrl *gomock.Controller) *MockPingPeerService

NewMockPingPeerService creates a new mock instance.

func (*MockPingPeerService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPingPeerService) PingPong

func (m *MockPingPeerService) PingPong(timeout time.Duration) (time.Duration, error)

PingPong mocks base method.

func (*MockPingPeerService) String

func (m *MockPingPeerService) String() string

String mocks base method.

type MockPingPeerServiceMockRecorder

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

MockPingPeerServiceMockRecorder is the mock recorder for MockPingPeerService.

func (*MockPingPeerServiceMockRecorder) PingPong

func (mr *MockPingPeerServiceMockRecorder) PingPong(timeout interface{}) *gomock.Call

PingPong indicates an expected call of PingPong.

func (*MockPingPeerServiceMockRecorder) String

String indicates an expected call of String.

type MockSnapshotService

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

MockSnapshotService is a mock of SnapshotService interface.

func NewMockSnapshotService

func NewMockSnapshotService(ctrl *gomock.Controller) *MockSnapshotService

NewMockSnapshotService creates a new mock instance.

func (*MockSnapshotService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSnapshotService) Epochs

func (m *MockSnapshotService) Epochs() []uint64

Epochs mocks base method.

func (*MockSnapshotService) GetSnapshot

func (m *MockSnapshotService) GetSnapshot(epoch uint64) *snapshot.Snapshot

GetSnapshot mocks base method.

func (*MockSnapshotService) MinerListAtEpoch

func (m *MockSnapshotService) MinerListAtEpoch(epoch uint64) []common.Address

MinerListAtEpoch mocks base method.

func (*MockSnapshotService) PrepareSnapshot

func (m *MockSnapshotService) PrepareSnapshot(epoch uint64) (*snapshot.Snapshot, error)

PrepareSnapshot mocks base method.

func (*MockSnapshotService) RecentEpoch

func (m *MockSnapshotService) RecentEpoch() uint64

RecentEpoch mocks base method.

func (*MockSnapshotService) ToDTO

ToDTO mocks base method.

type MockSnapshotServiceMockRecorder

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

MockSnapshotServiceMockRecorder is the mock recorder for MockSnapshotService.

func (*MockSnapshotServiceMockRecorder) Epochs

Epochs indicates an expected call of Epochs.

func (*MockSnapshotServiceMockRecorder) GetSnapshot

func (mr *MockSnapshotServiceMockRecorder) GetSnapshot(epoch interface{}) *gomock.Call

GetSnapshot indicates an expected call of GetSnapshot.

func (*MockSnapshotServiceMockRecorder) MinerListAtEpoch

func (mr *MockSnapshotServiceMockRecorder) MinerListAtEpoch(epoch interface{}) *gomock.Call

MinerListAtEpoch indicates an expected call of MinerListAtEpoch.

func (*MockSnapshotServiceMockRecorder) PrepareSnapshot

func (mr *MockSnapshotServiceMockRecorder) PrepareSnapshot(epoch interface{}) *gomock.Call

PrepareSnapshot indicates an expected call of PrepareSnapshot.

func (*MockSnapshotServiceMockRecorder) RecentEpoch

func (mr *MockSnapshotServiceMockRecorder) RecentEpoch() *gomock.Call

RecentEpoch indicates an expected call of RecentEpoch.

func (*MockSnapshotServiceMockRecorder) ToDTO

ToDTO indicates an expected call of ToDTO.

type NodeCandidateListMsg

type NodeCandidateListMsg struct {
	List  []*NodeCandidateMsg
	Epoch *big.Int
}

func NewNodeCandidateListMsg

func NewNodeCandidateListMsg(nodes map[common.Address]bool, epoch uint64) *NodeCandidateListMsg

func (*NodeCandidateListMsg) ToMap

func (m *NodeCandidateListMsg) ToMap() map[common.Address]bool

type NodeCandidateMsg

type NodeCandidateMsg struct {
	Address          common.Address
	IsMinerCandidate bool
}

func NewNodeCandidateMsg

func NewNodeCandidateMsg(address common.Address, isMinerCandidate bool) *NodeCandidateMsg

type P2PServer

type P2PServer interface {
	Self() *enode.Node
}

type Peer

type Peer struct {
	*protocols.Peer                 // represents the connection for online peer
	PingPeer        PingPeerService // represents the connection for online ping peer
	// contains filtered or unexported fields
}

Peer is a representation of quorum service peer

func NewPeer

func NewPeer(p *protocols.Peer, pingPeer PingPeerService, quorum Handlers) *Peer

NewPeer creates peer with given quorum protocol peer

func (*Peer) Address

func (p *Peer) Address() common.Address

func (*Peer) Close

func (p *Peer) Close() error

func (*Peer) Closed

func (p *Peer) Closed() bool

func (*Peer) GetState

func (p *Peer) GetState() *peerState

func (*Peer) HandleMsg

func (p *Peer) HandleMsg(_ context.Context, msg interface{}) error

HandleMsg is the message handler that delegates incoming messages

func (Peer) InPingList

func (p Peer) InPingList() bool

InPingList returns if this peerState in our ping list

func (Peer) IsMinerCandidate

func (p Peer) IsMinerCandidate() bool

IsMinerCandidate returns if this peer wants to mine AT THE MOMENT (not depending to epoch)

func (Peer) IsQuorumCandidate

func (p Peer) IsQuorumCandidate() bool

IsQuorumCandidate returns if this peerState is our quorum candidate now

func (Peer) MarkIsMinerCandidate

func (p Peer) MarkIsMinerCandidate(res bool)

MarkIsMinerCandidate marks peer as miner candidate AT THE MOMENT

func (*Peer) SendMiners

func (p *Peer) SendMiners(ctx context.Context, msg *MinersMsg) error

func (*Peer) SendNodeCandidateList

func (p *Peer) SendNodeCandidateList(ctx context.Context, msg *NodeCandidateListMsg) error

SendNodeCandidateList sends MinerCandidateListMsg

func (*Peer) SendVoteMinerAddMsg

func (p *Peer) SendVoteMinerAddMsg(ctx context.Context) error

SendVoteMinerAddMsg sends VoteMinerAddMsg

func (*Peer) SendVoteMinerDelMsg

func (p *Peer) SendVoteMinerDelMsg(ctx context.Context) error

SendVoteMinerDelMsg sends NewVoteMinerDelMsg

func (*Peer) String

func (p *Peer) String() string

func (*Peer) ToDTO

func (p *Peer) ToDTO() *PeerDTO

type PeerDTO

type PeerDTO struct {
	ID    enode.ID
	Enode string
	*PeerStateDTO
}

type PeerList

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

PeerList is a representation of quorum service peers list with additional helper methods

func (*PeerList) AddPeer

func (pl *PeerList) AddPeer(p *Peer)

AddPeer adds the peer using quorum protocol peer if peer state found in recent peers - restore state from that map

func (*PeerList) GetPeer

func (pl *PeerList) GetPeer(peerID enode.ID) *Peer

GetPeer returns the peer with peerID

func (*PeerList) GetSnapshotNodes

func (pl *PeerList) GetSnapshotNodes() ([]*snapshot.Node, error)

GetSnapshotNodes methods creates a snapshot of current peers state and returns slice of snapshot.Node Result also contains data about self node. Self node remoteNodeCandidates are also feels in while getting snapshot nodes

func (*PeerList) Ids

func (pl *PeerList) Ids() []enode.ID

func (*PeerList) Len

func (pl *PeerList) Len() int

Len returns the number of elements in list

func (*PeerList) MarkSelfIsMinerCandidate

func (pl *PeerList) MarkSelfIsMinerCandidate(in bool)

MarkSelfIsMinerCandidate - marks self node is miner candidate AT THE MOMENT

func (*PeerList) Peers

func (pl *PeerList) Peers() []*Peer

func (*PeerList) PingList

func (pl *PeerList) PingList() []enode.ID

PingList returns the slice of enode.ID of ping list (doesn`t include self node)

func (*PeerList) PingListLen

func (pl *PeerList) PingListLen() (length int)

PingListLen returns the number of peers in ping list (doesn`t include self node)

func (*PeerList) PingListPeers

func (pl *PeerList) PingListPeers() []*Peer

PingListPeers returns the slice of peers of ping list (doesn`t include self node)

func (*PeerList) RemovePeer

func (pl *PeerList) RemovePeer(peerID enode.ID)

RemovePeer removes peer with peerID from the peer store actually deleting not happening. it just moves from peers map to recentPeers map

func (*PeerList) Self

func (pl *PeerList) Self() *enode.Node

func (*PeerList) SelfIsMinerCandidate

func (pl *PeerList) SelfIsMinerCandidate() bool

SelfIsMinerCandidate - returns if self node is miner candidate AT THE MOMENT (not depending do epoch)

func (*PeerList) ToDTO

func (pl *PeerList) ToDTO() *PeerListDTO

type PeerListDTO

type PeerListDTO struct {
	SelfID               enode.ID
	SelfEnode            string
	SelfIsMinerCandidate bool
	Peers                []*PeerDTO
	RecentPeers          map[enode.ID]*PeerStateDTO
}

type PeerListService

type PeerListService interface {
	PingListLen() (length int)
	PingListPeers() []*Peer
	PingList() []enode.ID
	ToDTO() *PeerListDTO
	AddPeer(p *Peer)
	RemovePeer(peerID enode.ID)
	Peers() []*Peer
	SelfIsMinerCandidate() bool
	MarkSelfIsMinerCandidate(in bool)
	GetSnapshotNodes() ([]*snapshot.Node, error)
}

type PeerStateDTO

type PeerStateDTO struct {
	LastPing         time.Duration
	LastPingStr      string
	InPingList       bool
	IsMinerCandidate bool
	PeerRate         int
}

type PingPeerService

type PingPeerService interface {
	PingPong(timeout time.Duration) (dur time.Duration, err error)
	String() string
}

type Quorum

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

func New

func New(_ *node.ServiceContext, cfg *Config) (q *Quorum, err error)

func (*Quorum) APIs

func (q *Quorum) APIs() []rpc.API

APIs is a meaningless implementation of node.Service.

func (*Quorum) CreateQuorumSnapshot

func (q *Quorum) CreateQuorumSnapshot(epoch uint64, logger log.Logger) (*snapshot.Snapshot, error)

CreateQuorumSnapshot creates a snapshot of the current state of peer list

func (*Quorum) Engine

func (q *Quorum) Engine() consensus.Engine

func (*Quorum) HandleMinersMsg

func (q *Quorum) HandleMinersMsg(msg *MinersMsg, peer *Peer)

HandleMinersMsg handles MinersMsg from peer

func (*Quorum) HandleNodeCandidateListMsg

func (q *Quorum) HandleNodeCandidateListMsg(msg *NodeCandidateListMsg, peer *Peer)

HandleNodeCandidateListMsg handles NodeCandidateListMsg from peer

func (*Quorum) HandleVoteMinerAddMsg

func (q *Quorum) HandleVoteMinerAddMsg(peer *Peer)

HandleVoteMinerAddMsg handles VoteMinerAddMsg from peer

func (*Quorum) HandleVoteMinerDelMsg

func (q *Quorum) HandleVoteMinerDelMsg(peer *Peer)

HandleVoteMinerDelMsg handles VoteMinerDelMsg from peer

func (*Quorum) MarkMinerCandidate

func (q *Quorum) MarkMinerCandidate(res bool)

MarkMinerCandidate when node enters in quorum, it marks self as miner candidate

func (*Quorum) MinerListAtEpoch

func (q *Quorum) MinerListAtEpoch(epoch uint64) []common.Address

func (*Quorum) MinerListAtRecentEpoch

func (q *Quorum) MinerListAtRecentEpoch() []common.Address

func (*Quorum) PrepareNodeListAtEpoch

func (q *Quorum) PrepareNodeListAtEpoch(epoch uint64)

func (*Quorum) Prepared

func (q *Quorum) Prepared() bool

func (*Quorum) Protocols

func (q *Quorum) Protocols() []p2p.Protocol

Protocols is a meaningless implementation of node.Service.

func (*Quorum) SelfIsMinerCandidate

func (q *Quorum) SelfIsMinerCandidate() bool

SelfIsMinerCandidate returns self miner candidate status

func (*Quorum) SetContractService

func (q *Quorum) SetContractService(c ContractService)

func (*Quorum) SetEngine

func (q *Quorum) SetEngine(engine *quorum.QuorumEngine)

func (*Quorum) Start

func (q *Quorum) Start(srvr *p2p.Server) error

func (*Quorum) Stop

func (q *Quorum) Stop() error

func (*Quorum) Stopped

func (q *Quorum) Stopped() bool

type SelfState

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

func NewSelfState

func NewSelfState() *SelfState

func (*SelfState) IsMinerCandidate

func (ss *SelfState) IsMinerCandidate() bool

IsMinerCandidate - returns if self node is miner candidate AT THE MOMENT (not depending do epoch)

func (*SelfState) MarkIsMinerCandidate

func (ss *SelfState) MarkIsMinerCandidate(in bool)

MarkIsMinerCandidate - marks self node is miner candidate AT THE MOMENT

type SnapshotService

type SnapshotService interface {
	GetSnapshot(epoch uint64) *snapshot.Snapshot
	ToDTO() *snapshot.SystemDTO
	Epochs() []uint64
	RecentEpoch() uint64
	MinerListAtEpoch(epoch uint64) []common.Address
	PrepareSnapshot(epoch uint64) (*snapshot.Snapshot, error)
}

type VoteMinerAddMsg

type VoteMinerAddMsg struct {
}

VoteMinerAddMsg is sent to ask remote peers to add self node to miner nodes

func NewVoteMinerAddMsg

func NewVoteMinerAddMsg() *VoteMinerAddMsg

type VoteMinerDelMsg

type VoteMinerDelMsg struct {
}

VoteMinerDelMsg is sent to ask remote peers to delete self node from miner nodes

func NewVoteMinerDelMsg

func NewVoteMinerDelMsg() *VoteMinerDelMsg

Directories

Path Synopsis
Package quorum is a generated GoMock package.
Package quorum is a generated GoMock package.
utils

Jump to

Keyboard shortcuts

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