pulse

package
v0.9.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package Pulse contains Pulse storage.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when value was not found.
	ErrNotFound = errors.New("pulse not found")
	// ErrBadPulse is returned when appended Pulse is less than the latest.
	ErrBadPulse = errors.New("pulse should be greater than the latest")
)
View Source
var (
	ErrInvalidLengthPulse = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPulse   = fmt.Errorf("proto: integer overflow")
)

Functions

func FromProto

func FromProto(p *PulseProto) *insolar.Pulse

Types

type Accessor

type Accessor interface {
	ForPulseNumber(context.Context, insolar.PulseNumber) (insolar.Pulse, error)
	Latest(ctx context.Context) (insolar.Pulse, error)
}

Accessor provides methods for accessing pulses.

type AccessorMock

type AccessorMock struct {
	ForPulseNumberMock mAccessorMockForPulseNumber

	LatestMock mAccessorMockLatest
	// contains filtered or unexported fields
}

AccessorMock implements Accessor

func NewAccessorMock

func NewAccessorMock(t minimock.Tester) *AccessorMock

NewAccessorMock returns a mock for Accessor

func (*AccessorMock) ForPulseNumber

func (mmForPulseNumber *AccessorMock) ForPulseNumber(ctx context.Context, p1 insolar.PulseNumber) (p2 insolar.Pulse, err error)

ForPulseNumber implements Accessor

func (*AccessorMock) ForPulseNumberAfterCounter

func (mmForPulseNumber *AccessorMock) ForPulseNumberAfterCounter() uint64

ForPulseNumberAfterCounter returns a count of finished AccessorMock.ForPulseNumber invocations

func (*AccessorMock) ForPulseNumberBeforeCounter

func (mmForPulseNumber *AccessorMock) ForPulseNumberBeforeCounter() uint64

ForPulseNumberBeforeCounter returns a count of AccessorMock.ForPulseNumber invocations

func (*AccessorMock) Latest

func (mmLatest *AccessorMock) Latest(ctx context.Context) (p1 insolar.Pulse, err error)

Latest implements Accessor

func (*AccessorMock) LatestAfterCounter

func (mmLatest *AccessorMock) LatestAfterCounter() uint64

LatestAfterCounter returns a count of finished AccessorMock.Latest invocations

func (*AccessorMock) LatestBeforeCounter

func (mmLatest *AccessorMock) LatestBeforeCounter() uint64

LatestBeforeCounter returns a count of AccessorMock.Latest invocations

func (*AccessorMock) MinimockFinish

func (m *AccessorMock) MinimockFinish()

MinimockFinish checks that all mocked methods have been called the expected number of times

func (*AccessorMock) MinimockForPulseNumberDone

func (m *AccessorMock) MinimockForPulseNumberDone() bool

MinimockForPulseNumberDone returns true if the count of the ForPulseNumber invocations corresponds the number of defined expectations

func (*AccessorMock) MinimockForPulseNumberInspect

func (m *AccessorMock) MinimockForPulseNumberInspect()

MinimockForPulseNumberInspect logs each unmet expectation

func (*AccessorMock) MinimockLatestDone

func (m *AccessorMock) MinimockLatestDone() bool

MinimockLatestDone returns true if the count of the Latest invocations corresponds the number of defined expectations

func (*AccessorMock) MinimockLatestInspect

func (m *AccessorMock) MinimockLatestInspect()

MinimockLatestInspect logs each unmet expectation

func (*AccessorMock) MinimockWait

func (m *AccessorMock) MinimockWait(timeout mm_time.Duration)

MinimockWait waits for all mocked methods to be called the expected number of times

type AccessorMockForPulseNumberExpectation

type AccessorMockForPulseNumberExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

AccessorMockForPulseNumberExpectation specifies expectation struct of the Accessor.ForPulseNumber

func (*AccessorMockForPulseNumberExpectation) Then

Then sets up Accessor.ForPulseNumber return parameters for the expectation previously defined by the When method

type AccessorMockForPulseNumberParams

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

AccessorMockForPulseNumberParams contains parameters of the Accessor.ForPulseNumber

type AccessorMockForPulseNumberResults

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

AccessorMockForPulseNumberResults contains results of the Accessor.ForPulseNumber

type AccessorMockLatestExpectation

type AccessorMockLatestExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

AccessorMockLatestExpectation specifies expectation struct of the Accessor.Latest

func (*AccessorMockLatestExpectation) Then

Then sets up Accessor.Latest return parameters for the expectation previously defined by the When method

type AccessorMockLatestParams

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

AccessorMockLatestParams contains parameters of the Accessor.Latest

type AccessorMockLatestResults

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

AccessorMockLatestResults contains results of the Accessor.Latest

type Appender

type Appender interface {
	Append(ctx context.Context, pulse insolar.Pulse) error
}

Appender provides method for appending pulses to storage.

type AppenderMock

type AppenderMock struct {
	AppendMock mAppenderMockAppend
	// contains filtered or unexported fields
}

AppenderMock implements Appender

func NewAppenderMock

func NewAppenderMock(t minimock.Tester) *AppenderMock

NewAppenderMock returns a mock for Appender

func (*AppenderMock) Append

func (mmAppend *AppenderMock) Append(ctx context.Context, pulse insolar.Pulse) (err error)

Append implements Appender

func (*AppenderMock) AppendAfterCounter

func (mmAppend *AppenderMock) AppendAfterCounter() uint64

AppendAfterCounter returns a count of finished AppenderMock.Append invocations

func (*AppenderMock) AppendBeforeCounter

func (mmAppend *AppenderMock) AppendBeforeCounter() uint64

AppendBeforeCounter returns a count of AppenderMock.Append invocations

func (*AppenderMock) MinimockAppendDone

func (m *AppenderMock) MinimockAppendDone() bool

MinimockAppendDone returns true if the count of the Append invocations corresponds the number of defined expectations

func (*AppenderMock) MinimockAppendInspect

func (m *AppenderMock) MinimockAppendInspect()

MinimockAppendInspect logs each unmet expectation

func (*AppenderMock) MinimockFinish

func (m *AppenderMock) MinimockFinish()

MinimockFinish checks that all mocked methods have been called the expected number of times

func (*AppenderMock) MinimockWait

func (m *AppenderMock) MinimockWait(timeout mm_time.Duration)

MinimockWait waits for all mocked methods to be called the expected number of times

type AppenderMockAppendExpectation

type AppenderMockAppendExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

AppenderMockAppendExpectation specifies expectation struct of the Appender.Append

func (*AppenderMockAppendExpectation) Then

Then sets up Appender.Append return parameters for the expectation previously defined by the When method

type AppenderMockAppendParams

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

AppenderMockAppendParams contains parameters of the Appender.Append

type AppenderMockAppendResults

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

AppenderMockAppendResults contains results of the Appender.Append

type Calculator

type Calculator interface {
	Forwards(ctx context.Context, pn insolar.PulseNumber, steps int) (insolar.Pulse, error)
	Backwards(ctx context.Context, pn insolar.PulseNumber, steps int) (insolar.Pulse, error)
}

Calculator performs calculations for pulses.

type CalculatorMock

type CalculatorMock struct {
	BackwardsMock mCalculatorMockBackwards

	ForwardsMock mCalculatorMockForwards
	// contains filtered or unexported fields
}

CalculatorMock implements Calculator

func NewCalculatorMock

func NewCalculatorMock(t minimock.Tester) *CalculatorMock

NewCalculatorMock returns a mock for Calculator

func (*CalculatorMock) Backwards

func (mmBackwards *CalculatorMock) Backwards(ctx context.Context, pn insolar.PulseNumber, steps int) (p1 insolar.Pulse, err error)

Backwards implements Calculator

func (*CalculatorMock) BackwardsAfterCounter

func (mmBackwards *CalculatorMock) BackwardsAfterCounter() uint64

BackwardsAfterCounter returns a count of finished CalculatorMock.Backwards invocations

func (*CalculatorMock) BackwardsBeforeCounter

func (mmBackwards *CalculatorMock) BackwardsBeforeCounter() uint64

BackwardsBeforeCounter returns a count of CalculatorMock.Backwards invocations

func (*CalculatorMock) Forwards

func (mmForwards *CalculatorMock) Forwards(ctx context.Context, pn insolar.PulseNumber, steps int) (p1 insolar.Pulse, err error)

Forwards implements Calculator

func (*CalculatorMock) ForwardsAfterCounter

func (mmForwards *CalculatorMock) ForwardsAfterCounter() uint64

ForwardsAfterCounter returns a count of finished CalculatorMock.Forwards invocations

func (*CalculatorMock) ForwardsBeforeCounter

func (mmForwards *CalculatorMock) ForwardsBeforeCounter() uint64

ForwardsBeforeCounter returns a count of CalculatorMock.Forwards invocations

func (*CalculatorMock) MinimockBackwardsDone

func (m *CalculatorMock) MinimockBackwardsDone() bool

MinimockBackwardsDone returns true if the count of the Backwards invocations corresponds the number of defined expectations

func (*CalculatorMock) MinimockBackwardsInspect

func (m *CalculatorMock) MinimockBackwardsInspect()

MinimockBackwardsInspect logs each unmet expectation

func (*CalculatorMock) MinimockFinish

func (m *CalculatorMock) MinimockFinish()

MinimockFinish checks that all mocked methods have been called the expected number of times

func (*CalculatorMock) MinimockForwardsDone

func (m *CalculatorMock) MinimockForwardsDone() bool

MinimockForwardsDone returns true if the count of the Forwards invocations corresponds the number of defined expectations

func (*CalculatorMock) MinimockForwardsInspect

func (m *CalculatorMock) MinimockForwardsInspect()

MinimockForwardsInspect logs each unmet expectation

func (*CalculatorMock) MinimockWait

func (m *CalculatorMock) MinimockWait(timeout mm_time.Duration)

MinimockWait waits for all mocked methods to be called the expected number of times

type CalculatorMockBackwardsExpectation

type CalculatorMockBackwardsExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

CalculatorMockBackwardsExpectation specifies expectation struct of the Calculator.Backwards

func (*CalculatorMockBackwardsExpectation) Then

Then sets up Calculator.Backwards return parameters for the expectation previously defined by the When method

type CalculatorMockBackwardsParams

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

CalculatorMockBackwardsParams contains parameters of the Calculator.Backwards

type CalculatorMockBackwardsResults

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

CalculatorMockBackwardsResults contains results of the Calculator.Backwards

type CalculatorMockForwardsExpectation

type CalculatorMockForwardsExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

CalculatorMockForwardsExpectation specifies expectation struct of the Calculator.Forwards

func (*CalculatorMockForwardsExpectation) Then

Then sets up Calculator.Forwards return parameters for the expectation previously defined by the When method

type CalculatorMockForwardsParams

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

CalculatorMockForwardsParams contains parameters of the Calculator.Forwards

type CalculatorMockForwardsResults

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

CalculatorMockForwardsResults contains results of the Calculator.Forwards

type DB

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

DB is a DB storage implementation. It saves pulses to disk and does not allow removal.

func NewDB

func NewDB(db store.DB) *DB

NewDB creates new DB storage instance.

func (*DB) Append

func (s *DB) Append(ctx context.Context, pulse insolar.Pulse) error

Append appends provided pulse to current storage. Pulse number should be greater than currently saved for preserving pulse consistency. If a provided pulse does not meet the requirements, ErrBadPulse will be returned.

func (*DB) Backwards

func (s *DB) Backwards(ctx context.Context, pn insolar.PulseNumber, steps int) (insolar.Pulse, error)

Backwards calculates steps pulses backwards from provided pulse. If calculated pulse does not exist, ErrNotFound will be returned.

func (*DB) ForPulseNumber

func (s *DB) ForPulseNumber(ctx context.Context, pn insolar.PulseNumber) (pulse insolar.Pulse, err error)

ForPulseNumber returns pulse for provided a pulse number. If not found, ErrNotFound will be returned.

func (*DB) Forwards

func (s *DB) Forwards(ctx context.Context, pn insolar.PulseNumber, steps int) (insolar.Pulse, error)

Forwards calculates steps pulses forwards from provided pulse. If calculated pulse does not exist, ErrNotFound will be returned.

func (*DB) Latest

func (s *DB) Latest(ctx context.Context) (pulse insolar.Pulse, err error)

Latest returns a latest pulse saved in DB. If not found, ErrNotFound will be returned.

func (*DB) TruncateHead

func (s *DB) TruncateHead(ctx context.Context, from insolar.PulseNumber) error

TruncateHead remove all records after lastPulse

type PulseProto

type PulseProto struct {
	PulseNumber      github_com_insolar_insolar_insolar.PulseNumber `protobuf:"varint,1,opt,name=PulseNumber,proto3,customtype=github.com/insolar/insolar/insolar.PulseNumber" json:"PulseNumber"`
	PrevPulseNumber  github_com_insolar_insolar_insolar.PulseNumber `` /* 132-byte string literal not displayed */
	NextPulseNumber  github_com_insolar_insolar_insolar.PulseNumber `` /* 132-byte string literal not displayed */
	PulseTimestamp   int64                                          `protobuf:"varint,4,opt,name=PulseTimestamp,proto3" json:"PulseTimestamp,omitempty"`
	EpochPulseNumber int32                                          `protobuf:"varint,5,opt,name=EpochPulseNumber,proto3" json:"EpochPulseNumber,omitempty"`
	OriginID         []byte                                         `protobuf:"bytes,6,opt,name=OriginID,proto3" json:"OriginID,omitempty"`
	Entropy          github_com_insolar_insolar_insolar.Entropy     `protobuf:"bytes,7,opt,name=Entropy,proto3,customtype=github.com/insolar/insolar/insolar.Entropy" json:"Entropy"`
	Signs            []*PulseSenderConfirmationProto                `protobuf:"bytes,8,rep,name=Signs,proto3" json:"Signs,omitempty"`
}

func ToProto

func ToProto(p *insolar.Pulse) *PulseProto

func (*PulseProto) Descriptor

func (*PulseProto) Descriptor() ([]byte, []int)

func (*PulseProto) Equal

func (this *PulseProto) Equal(that interface{}) bool

func (*PulseProto) GoString

func (this *PulseProto) GoString() string

func (*PulseProto) Marshal

func (m *PulseProto) Marshal() (dAtA []byte, err error)

func (*PulseProto) MarshalTo

func (m *PulseProto) MarshalTo(dAtA []byte) (int, error)

func (*PulseProto) ProtoMessage

func (*PulseProto) ProtoMessage()

func (*PulseProto) Reset

func (m *PulseProto) Reset()

func (*PulseProto) Size

func (m *PulseProto) Size() (n int)

func (*PulseProto) String

func (this *PulseProto) String() string

func (*PulseProto) Unmarshal

func (m *PulseProto) Unmarshal(dAtA []byte) error

func (*PulseProto) XXX_DiscardUnknown

func (m *PulseProto) XXX_DiscardUnknown()

func (*PulseProto) XXX_Marshal

func (m *PulseProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PulseProto) XXX_Merge

func (m *PulseProto) XXX_Merge(src proto.Message)

func (*PulseProto) XXX_Size

func (m *PulseProto) XXX_Size() int

func (*PulseProto) XXX_Unmarshal

func (m *PulseProto) XXX_Unmarshal(b []byte) error

type PulseSenderConfirmationProto

type PulseSenderConfirmationProto struct {
	PublicKey       string                                         `protobuf:"bytes,1,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"`
	PulseNumber     github_com_insolar_insolar_insolar.PulseNumber `protobuf:"varint,2,opt,name=PulseNumber,proto3,customtype=github.com/insolar/insolar/insolar.PulseNumber" json:"PulseNumber"`
	ChosenPublicKey string                                         `protobuf:"bytes,3,opt,name=ChosenPublicKey,proto3" json:"ChosenPublicKey,omitempty"`
	Entropy         github_com_insolar_insolar_insolar.Entropy     `protobuf:"bytes,4,opt,name=Entropy,proto3,customtype=github.com/insolar/insolar/insolar.Entropy" json:"Entropy"`
	Signature       []byte                                         `protobuf:"bytes,5,opt,name=Signature,proto3" json:"Signature,omitempty"`
}

func (*PulseSenderConfirmationProto) Descriptor

func (*PulseSenderConfirmationProto) Descriptor() ([]byte, []int)

func (*PulseSenderConfirmationProto) Equal

func (this *PulseSenderConfirmationProto) Equal(that interface{}) bool

func (*PulseSenderConfirmationProto) GoString

func (this *PulseSenderConfirmationProto) GoString() string

func (*PulseSenderConfirmationProto) Marshal

func (m *PulseSenderConfirmationProto) Marshal() (dAtA []byte, err error)

func (*PulseSenderConfirmationProto) MarshalTo

func (m *PulseSenderConfirmationProto) MarshalTo(dAtA []byte) (int, error)

func (*PulseSenderConfirmationProto) ProtoMessage

func (*PulseSenderConfirmationProto) ProtoMessage()

func (*PulseSenderConfirmationProto) Reset

func (m *PulseSenderConfirmationProto) Reset()

func (*PulseSenderConfirmationProto) Size

func (m *PulseSenderConfirmationProto) Size() (n int)

func (*PulseSenderConfirmationProto) String

func (this *PulseSenderConfirmationProto) String() string

func (*PulseSenderConfirmationProto) Unmarshal

func (m *PulseSenderConfirmationProto) Unmarshal(dAtA []byte) error

func (*PulseSenderConfirmationProto) XXX_DiscardUnknown

func (m *PulseSenderConfirmationProto) XXX_DiscardUnknown()

func (*PulseSenderConfirmationProto) XXX_Marshal

func (m *PulseSenderConfirmationProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PulseSenderConfirmationProto) XXX_Merge

func (m *PulseSenderConfirmationProto) XXX_Merge(src proto.Message)

func (*PulseSenderConfirmationProto) XXX_Size

func (m *PulseSenderConfirmationProto) XXX_Size() int

func (*PulseSenderConfirmationProto) XXX_Unmarshal

func (m *PulseSenderConfirmationProto) XXX_Unmarshal(b []byte) error

type Shifter

type Shifter interface {
	Shift(ctx context.Context, pn insolar.PulseNumber) (err error)
}

Shifter provides method for removing pulses from storage.

type ShifterMock

type ShifterMock struct {
	ShiftMock mShifterMockShift
	// contains filtered or unexported fields
}

ShifterMock implements Shifter

func NewShifterMock

func NewShifterMock(t minimock.Tester) *ShifterMock

NewShifterMock returns a mock for Shifter

func (*ShifterMock) MinimockFinish

func (m *ShifterMock) MinimockFinish()

MinimockFinish checks that all mocked methods have been called the expected number of times

func (*ShifterMock) MinimockShiftDone

func (m *ShifterMock) MinimockShiftDone() bool

MinimockShiftDone returns true if the count of the Shift invocations corresponds the number of defined expectations

func (*ShifterMock) MinimockShiftInspect

func (m *ShifterMock) MinimockShiftInspect()

MinimockShiftInspect logs each unmet expectation

func (*ShifterMock) MinimockWait

func (m *ShifterMock) MinimockWait(timeout mm_time.Duration)

MinimockWait waits for all mocked methods to be called the expected number of times

func (*ShifterMock) Shift

func (mmShift *ShifterMock) Shift(ctx context.Context, pn insolar.PulseNumber) (err error)

Shift implements Shifter

func (*ShifterMock) ShiftAfterCounter

func (mmShift *ShifterMock) ShiftAfterCounter() uint64

ShiftAfterCounter returns a count of finished ShifterMock.Shift invocations

func (*ShifterMock) ShiftBeforeCounter

func (mmShift *ShifterMock) ShiftBeforeCounter() uint64

ShiftBeforeCounter returns a count of ShifterMock.Shift invocations

type ShifterMockShiftExpectation

type ShifterMockShiftExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

ShifterMockShiftExpectation specifies expectation struct of the Shifter.Shift

func (*ShifterMockShiftExpectation) Then

Then sets up Shifter.Shift return parameters for the expectation previously defined by the When method

type ShifterMockShiftParams

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

ShifterMockShiftParams contains parameters of the Shifter.Shift

type ShifterMockShiftResults

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

ShifterMockShiftResults contains results of the Shifter.Shift

type StartPulse

type StartPulse interface {
	SetStartPulse(context.Context, insolar.Pulse)
	PulseNumber() (insolar.PulseNumber, error)
}

func NewStartPulse

func NewStartPulse() StartPulse

type StorageMem

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

StorageMem is a memory storage implementation. It saves pulses to memory and allows removal.

func NewStorageMem

func NewStorageMem() *StorageMem

NewStorageMem creates new memory storage instance.

func (*StorageMem) Append

func (s *StorageMem) Append(ctx context.Context, pulse insolar.Pulse) error

Append appends provided a pulse to current storage. Pulse number should be greater than currently saved for preserving pulse consistency. If provided Pulse does not meet the requirements, ErrBadPulse will be returned.

func (*StorageMem) Backwards

func (s *StorageMem) Backwards(ctx context.Context, pn insolar.PulseNumber, steps int) (pulse insolar.Pulse, err error)

Backwards calculates steps pulses backwards from provided pulse. If calculated pulse does not exist, ErrNotFound will be returned.

func (*StorageMem) ForPulseNumber

func (s *StorageMem) ForPulseNumber(ctx context.Context, pn insolar.PulseNumber) (pulse insolar.Pulse, err error)

ForPulseNumber returns pulse for provided Pulse number. If not found, ErrNotFound will be returned.

func (*StorageMem) Forwards

func (s *StorageMem) Forwards(ctx context.Context, pn insolar.PulseNumber, steps int) (pulse insolar.Pulse, err error)

Forwards calculates steps pulses forwards from provided Pulse. If calculated pulse does not exist, ErrNotFound will be returned.

func (*StorageMem) Latest

func (s *StorageMem) Latest(ctx context.Context) (pulse insolar.Pulse, err error)

Latest returns a latest pulse saved in memory. If not found, ErrNotFound will be returned.

func (*StorageMem) Shift

func (s *StorageMem) Shift(ctx context.Context, pn insolar.PulseNumber) (err error)

Shift removes oldest pulse from storage. If the storage is empty, an error will be returned.

Jump to

Keyboard shortcuts

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