phases

package
v0.7.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ConsensusAtPercents = 2.0 / 3.0

Variables

This section is empty.

Functions

This section is empty.

Types

type Communicator added in v0.6.3

type Communicator interface {
	// ExchangePhase1 used in first consensus step to exchange data between participants
	ExchangePhase1(
		ctx context.Context,
		participants []core.Node,
		packet *packets.Phase1Packet,
	) (map[core.RecordRef]*packets.Phase1Packet, map[core.RecordRef]string, error)
	// ExchangePhase2 used in second consensus step to exchange data between participants
	ExchangePhase2(ctx context.Context, participants []core.Node, packet *packets.Phase2Packet) (map[core.RecordRef]*packets.Phase2Packet, error)
	// ExchangePhase3 used in third consensus step to exchange data between participants
	ExchangePhase3(ctx context.Context, participants []core.Node, packet *packets.Phase3Packet) (map[core.RecordRef]*packets.Phase3Packet, error)
}

Communicator interface provides methods to exchange data between nodes

type CommunicatorMock added in v0.6.3

type CommunicatorMock struct {
	ExchangePhase1Func       func(p context.Context, p1 []core.Node, p2 *packets.Phase1Packet) (r map[core.RecordRef]*packets.Phase1Packet, r1 map[core.RecordRef]string, r2 error)
	ExchangePhase1Counter    uint64
	ExchangePhase1PreCounter uint64
	ExchangePhase1Mock       mCommunicatorMockExchangePhase1

	ExchangePhase2Func       func(p context.Context, p1 []core.Node, p2 *packets.Phase2Packet) (r map[core.RecordRef]*packets.Phase2Packet, r1 error)
	ExchangePhase2Counter    uint64
	ExchangePhase2PreCounter uint64
	ExchangePhase2Mock       mCommunicatorMockExchangePhase2

	ExchangePhase3Func       func(p context.Context, p1 []core.Node, p2 *packets.Phase3Packet) (r map[core.RecordRef]*packets.Phase3Packet, r1 error)
	ExchangePhase3Counter    uint64
	ExchangePhase3PreCounter uint64
	ExchangePhase3Mock       mCommunicatorMockExchangePhase3
	// contains filtered or unexported fields
}

CommunicatorMock implements github.com/insolar/insolar/consensus/phases.Communicator

func NewCommunicatorMock added in v0.6.3

func NewCommunicatorMock(t minimock.Tester) *CommunicatorMock

NewCommunicatorMock returns a mock for github.com/insolar/insolar/consensus/phases.Communicator

func (*CommunicatorMock) AllMocksCalled added in v0.6.3

func (m *CommunicatorMock) AllMocksCalled() bool

AllMocksCalled returns true if all mocked methods were called before the execution of AllMocksCalled, it can be used with assert/require, i.e. assert.True(mock.AllMocksCalled())

func (*CommunicatorMock) CheckMocksCalled added in v0.6.3

func (m *CommunicatorMock) CheckMocksCalled()

CheckMocksCalled checks that all mocked methods of the interface have been called at least once Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller

func (*CommunicatorMock) ExchangePhase1 added in v0.6.3

func (m *CommunicatorMock) ExchangePhase1(p context.Context, p1 []core.Node, p2 *packets.Phase1Packet) (r map[core.RecordRef]*packets.Phase1Packet, r1 map[core.RecordRef]string, r2 error)

ExchangePhase1 implements github.com/insolar/insolar/consensus/phases.Communicator interface

func (*CommunicatorMock) ExchangePhase1Finished added in v0.7.5

func (m *CommunicatorMock) ExchangePhase1Finished() bool

ExchangePhase1Finished returns true if mock invocations count is ok

func (*CommunicatorMock) ExchangePhase1MinimockCounter added in v0.6.3

func (m *CommunicatorMock) ExchangePhase1MinimockCounter() uint64

ExchangePhase1MinimockCounter returns a count of CommunicatorMock.ExchangePhase1Func invocations

func (*CommunicatorMock) ExchangePhase1MinimockPreCounter added in v0.6.3

func (m *CommunicatorMock) ExchangePhase1MinimockPreCounter() uint64

ExchangePhase1MinimockPreCounter returns the value of CommunicatorMock.ExchangePhase1 invocations

func (*CommunicatorMock) ExchangePhase2 added in v0.6.3

func (m *CommunicatorMock) ExchangePhase2(p context.Context, p1 []core.Node, p2 *packets.Phase2Packet) (r map[core.RecordRef]*packets.Phase2Packet, r1 error)

ExchangePhase2 implements github.com/insolar/insolar/consensus/phases.Communicator interface

func (*CommunicatorMock) ExchangePhase2Finished added in v0.7.5

func (m *CommunicatorMock) ExchangePhase2Finished() bool

ExchangePhase2Finished returns true if mock invocations count is ok

func (*CommunicatorMock) ExchangePhase2MinimockCounter added in v0.6.3

func (m *CommunicatorMock) ExchangePhase2MinimockCounter() uint64

ExchangePhase2MinimockCounter returns a count of CommunicatorMock.ExchangePhase2Func invocations

func (*CommunicatorMock) ExchangePhase2MinimockPreCounter added in v0.6.3

func (m *CommunicatorMock) ExchangePhase2MinimockPreCounter() uint64

ExchangePhase2MinimockPreCounter returns the value of CommunicatorMock.ExchangePhase2 invocations

func (*CommunicatorMock) ExchangePhase3 added in v0.6.3

func (m *CommunicatorMock) ExchangePhase3(p context.Context, p1 []core.Node, p2 *packets.Phase3Packet) (r map[core.RecordRef]*packets.Phase3Packet, r1 error)

ExchangePhase3 implements github.com/insolar/insolar/consensus/phases.Communicator interface

func (*CommunicatorMock) ExchangePhase3Finished added in v0.7.5

func (m *CommunicatorMock) ExchangePhase3Finished() bool

ExchangePhase3Finished returns true if mock invocations count is ok

func (*CommunicatorMock) ExchangePhase3MinimockCounter added in v0.6.3

func (m *CommunicatorMock) ExchangePhase3MinimockCounter() uint64

ExchangePhase3MinimockCounter returns a count of CommunicatorMock.ExchangePhase3Func invocations

func (*CommunicatorMock) ExchangePhase3MinimockPreCounter added in v0.6.3

func (m *CommunicatorMock) ExchangePhase3MinimockPreCounter() uint64

ExchangePhase3MinimockPreCounter returns the value of CommunicatorMock.ExchangePhase3 invocations

func (*CommunicatorMock) Finish added in v0.6.3

func (m *CommunicatorMock) Finish()

Finish checks that all mocked methods of the interface have been called at least once Deprecated: please use MinimockFinish or use Finish method of minimock.Controller

func (*CommunicatorMock) MinimockFinish added in v0.6.3

func (m *CommunicatorMock) MinimockFinish()

MinimockFinish checks that all mocked methods of the interface have been called at least once

func (*CommunicatorMock) MinimockWait added in v0.6.3

func (m *CommunicatorMock) MinimockWait(timeout time.Duration)

MinimockWait waits for all mocked methods to be called at least once this method is called by minimock.Controller

func (*CommunicatorMock) ValidateCallCounters added in v0.6.3

func (m *CommunicatorMock) ValidateCallCounters()

ValidateCallCounters checks that all mocked methods of the interface have been called at least once Deprecated: please use MinimockFinish method or use Finish method of minimock.Controller

func (*CommunicatorMock) Wait added in v0.6.3

func (m *CommunicatorMock) Wait(timeout time.Duration)

Wait waits for all mocked methods to be called at least once Deprecated: please use MinimockWait or use Wait method of minimock.Controller

type CommunicatorMockExchangePhase1Expectation added in v0.7.5

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

func (*CommunicatorMockExchangePhase1Expectation) Return added in v0.7.5

type CommunicatorMockExchangePhase1Input added in v0.7.5

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

type CommunicatorMockExchangePhase1Result added in v0.7.5

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

type CommunicatorMockExchangePhase2Expectation added in v0.7.5

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

func (*CommunicatorMockExchangePhase2Expectation) Return added in v0.7.5

type CommunicatorMockExchangePhase2Input added in v0.7.5

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

type CommunicatorMockExchangePhase2Result added in v0.7.5

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

type CommunicatorMockExchangePhase3Expectation added in v0.7.5

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

func (*CommunicatorMockExchangePhase3Expectation) Return added in v0.7.5

type CommunicatorMockExchangePhase3Input added in v0.7.5

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

type CommunicatorMockExchangePhase3Result added in v0.7.5

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

type FirstPhase

type FirstPhase struct {
	NodeNetwork  core.NodeNetwork         `inject:""`
	Calculator   merkle.Calculator        `inject:""`
	Communicator Communicator             `inject:""`
	Cryptography core.CryptographyService `inject:""`
	NodeKeeper   network.NodeKeeper       `inject:""`
	State        *FirstPhaseState
	UnsyncList   network.UnsyncList
}

FirstPhase is a first phase.

func (*FirstPhase) Execute added in v0.6.3

func (fp *FirstPhase) Execute(ctx context.Context, pulse *core.Pulse) (*FirstPhaseState, error)

Execute do first phase

type FirstPhaseState added in v0.6.3

type FirstPhaseState struct {
	PulseEntry *merkle.PulseEntry

	PulseHash  merkle.OriginHash
	PulseProof *merkle.PulseProof

	ValidProofs map[core.Node]*merkle.PulseProof
	FaultProofs map[core.RecordRef]*merkle.PulseProof

	UnsyncList network.UnsyncList
}

type NaiveCommunicator added in v0.6.3

type NaiveCommunicator struct {
	ConsensusNetwork network.ConsensusNetwork `inject:""`
	PulseHandler     network.PulseHandler     `inject:""`
	Cryptography     core.CryptographyService `inject:""`
	NodeNetwork      core.NodeNetwork         `inject:""`
	// contains filtered or unexported fields
}

NaiveCommunicator is simple Communicator implementation which communicates with each participants

func NewNaiveCommunicator added in v0.6.3

func NewNaiveCommunicator() *NaiveCommunicator

NewNaiveCommunicator constructor creates new NaiveCommunicator

func (*NaiveCommunicator) ExchangePhase1 added in v0.6.3

func (nc *NaiveCommunicator) ExchangePhase1(
	ctx context.Context,
	participants []core.Node,
	packet *packets.Phase1Packet,
) (map[core.RecordRef]*packets.Phase1Packet, map[core.RecordRef]string, error)

ExchangePhase1 used in first consensus phase to exchange data between participants

func (*NaiveCommunicator) ExchangePhase2 added in v0.6.3

func (nc *NaiveCommunicator) ExchangePhase2(ctx context.Context, participants []core.Node, packet *packets.Phase2Packet) (map[core.RecordRef]*packets.Phase2Packet, error)

ExchangePhase2 used in second consensus phase to exchange data between participants

func (*NaiveCommunicator) ExchangePhase3 added in v0.6.3

func (nc *NaiveCommunicator) ExchangePhase3(ctx context.Context, participants []core.Node, packet *packets.Phase3Packet) (map[core.RecordRef]*packets.Phase3Packet, error)

ExchangePhase3 used in third consensus step to exchange data between participants

func (*NaiveCommunicator) Start added in v0.6.3

func (nc *NaiveCommunicator) Start(ctx context.Context) error

Start method implements Starter interface

type PhaseManager

type PhaseManager interface {
	OnPulse(ctx context.Context, pulse *core.Pulse) error
}

func NewPhaseManager

func NewPhaseManager() PhaseManager

NewPhaseManager creates and returns a new phase manager.

type Phases added in v0.6.3

type Phases struct {
	FirstPhase  *FirstPhase  //`inject:""`
	SecondPhase *SecondPhase //`inject:""`
	ThirdPhase  *ThirdPhase  //`inject:""`

	PulseManager core.PulseManager  `inject:""`
	NodeKeeper   network.NodeKeeper `inject:""`
}

func (*Phases) OnPulse added in v0.6.3

func (pm *Phases) OnPulse(ctx context.Context, pulse *core.Pulse) error

Start starts calculate args on phases.

type SecondPhase

type SecondPhase struct {
	NodeKeeper   network.NodeKeeper       `inject:""`
	Calculator   merkle.Calculator        `inject:""`
	Communicator Communicator             `inject:""`
	Cryptography core.CryptographyService `inject:""`
}

SecondPhase is a second phase.

func (*SecondPhase) Execute added in v0.6.3

func (sp *SecondPhase) Execute(ctx context.Context, state *FirstPhaseState) (*SecondPhaseState, error)

type SecondPhaseState added in v0.6.3

type SecondPhaseState struct {
	*FirstPhaseState

	GlobuleEntry *merkle.GlobuleEntry

	GlobuleHash  merkle.OriginHash
	GlobuleProof *merkle.GlobuleProof

	GlobuleProofSet map[core.Node]*merkle.GlobuleProof

	NodeListCount uint16
	NodeListHash  []byte

	DBitSet packets.BitSet
}

type ThirdPhase added in v0.6.3

type ThirdPhase struct {
	Cryptography core.CryptographyService `inject:""`
	NodeNetwork  core.NodeNetwork         `inject:""`
	Communicator Communicator             `inject:""`
	NodeKeeper   network.NodeKeeper       `inject:""`
	// contains filtered or unexported fields
}

func (*ThirdPhase) Execute added in v0.6.3

func (tp *ThirdPhase) Execute(ctx context.Context, state *SecondPhaseState) error

type ThirdPhasePulseState added in v0.6.3

type ThirdPhasePulseState struct {
}

type ThirdPhaseReferendumState added in v0.6.3

type ThirdPhaseReferendumState struct {
}

Jump to

Keyboard shortcuts

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