Documentation
¶
Overview ¶
Package consensus provides the main BFT consensus algorithm.
Index ¶
- Constants
- Variables
- type BBCEngine
- type Endorsement
- func (*Endorsement) Descriptor() ([]byte, []int)
- func (m *Endorsement) GetConditions() []string
- func (m *Endorsement) GetEmitter() string
- func (m *Endorsement) GetSignature() []byte
- func (m *Endorsement) GetUuid() string
- func (e Endorsement) Hash() ([]byte, error)
- func (*Endorsement) ProtoMessage()
- func (m *Endorsement) Reset()
- func (m *Endorsement) String() string
- func (m *Endorsement) XXX_DiscardUnknown()
- func (m *Endorsement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Endorsement) XXX_Merge(src proto.Message)
- func (m *Endorsement) XXX_Size() int
- func (m *Endorsement) XXX_Unmarshal(b []byte) error
- type Engine
- type MessageAcceptor
- type Network
- type Operation
- func (o *Operation) CheckConflict(o2 *Operation) error
- func (*Operation) Descriptor() ([]byte, []int)
- func (o *Operation) Exec(v *operations.Value) error
- func (m *Operation) GetData() []byte
- func (m *Operation) GetKey() string
- func (m *Operation) GetMetadata() []byte
- func (m *Operation) GetOp() Operation_Op
- func (*Operation) ProtoMessage()
- func (m *Operation) Reset()
- func (m *Operation) String() string
- func (m *Operation) XXX_DiscardUnknown()
- func (m *Operation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Operation) XXX_Merge(src proto.Message)
- func (m *Operation) XXX_Size() int
- func (m *Operation) XXX_Unmarshal(b []byte) error
- type Operation_Op
- type ParallelType
- type Proof
- func (*Proof) Descriptor() ([]byte, []int)
- func (m *Proof) GetContent() isProof_Content
- func (m *Proof) GetEndorsement() *Endorsement
- func (m *Proof) GetQuery() *Query
- func (*Proof) ProtoMessage()
- func (m *Proof) Reset()
- func (m *Proof) String() string
- func (m *Proof) XXX_DiscardUnknown()
- func (m *Proof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Proof) XXX_Merge(src proto.Message)
- func (*Proof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- func (m *Proof) XXX_Size() int
- func (m *Proof) XXX_Unmarshal(b []byte) error
- type Proof_Endorsement
- type Proof_Query
- type Query
- func (q *Query) CheckConflict(q2 *Query) error
- func (q *Query) DeadlineTime() time.Time
- func (*Query) Descriptor() ([]byte, []int)
- func (q *Query) Expired() bool
- func (q *Query) ExpiredSince(d time.Duration) bool
- func (m *Query) GetDeadline() *timestamp.Timestamp
- func (m *Query) GetEmitter() string
- func (m *Query) GetOperations() []*Operation
- func (m *Query) GetPolicy() string
- func (m *Query) GetRequirements() map[string]*Version
- func (m *Query) GetSignature() []byte
- func (q *Query) GetTimeout() time.Duration
- func (m *Query) GetUuid() string
- func (q Query) Hash() ([]byte, error)
- func (*Query) ProtoMessage()
- func (m *Query) Reset()
- func (q *Query) SetTimeout(t time.Duration)
- func (m *Query) String() string
- func (m *Query) XXX_DiscardUnknown()
- func (m *Query) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Query) XXX_Merge(src proto.Message)
- func (m *Query) XXX_Size() int
- func (m *Query) XXX_Unmarshal(b []byte) error
- type RecoveryHandler
- type RecoveryManager
- type RecoveryRequest
- func (*RecoveryRequest) Descriptor() ([]byte, []int)
- func (m *RecoveryRequest) GetKey() string
- func (*RecoveryRequest) ProtoMessage()
- func (m *RecoveryRequest) Reset()
- func (m *RecoveryRequest) String() string
- func (m *RecoveryRequest) XXX_DiscardUnknown()
- func (m *RecoveryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *RecoveryRequest) XXX_Merge(src proto.Message)
- func (m *RecoveryRequest) XXX_Size() int
- func (m *RecoveryRequest) XXX_Unmarshal(b []byte) error
- type RecoveryResponse
- func (*RecoveryResponse) Descriptor() ([]byte, []int)
- func (m *RecoveryResponse) GetData() []byte
- func (m *RecoveryResponse) GetKey() string
- func (m *RecoveryResponse) GetVersion() *Version
- func (*RecoveryResponse) ProtoMessage()
- func (m *RecoveryResponse) Reset()
- func (m *RecoveryResponse) String() string
- func (m *RecoveryResponse) XXX_DiscardUnknown()
- func (m *RecoveryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *RecoveryResponse) XXX_Merge(src proto.Message)
- func (m *RecoveryResponse) XXX_Size() int
- func (m *RecoveryResponse) XXX_Unmarshal(b []byte) error
- type StartCheckpoint
- func (*StartCheckpoint) Descriptor() ([]byte, []int)
- func (m *StartCheckpoint) GetQueries() []string
- func (*StartCheckpoint) ProtoMessage()
- func (m *StartCheckpoint) Reset()
- func (m *StartCheckpoint) String() string
- func (m *StartCheckpoint) XXX_DiscardUnknown()
- func (m *StartCheckpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *StartCheckpoint) XXX_Merge(src proto.Message)
- func (m *StartCheckpoint) XXX_Size() int
- func (m *StartCheckpoint) XXX_Unmarshal(b []byte) error
- type Store
- type Version
- func (*Version) Descriptor() ([]byte, []int)
- func (m *Version) GetHash() []byte
- func (v *Version) MarshalBinary() (data []byte, err error)
- func (v *Version) Matches(v2 *Version) error
- func (*Version) ProtoMessage()
- func (m *Version) Reset()
- func (m *Version) String() string
- func (v *Version) UnmarshalBinary(data []byte) error
- func (m *Version) XXX_DiscardUnknown()
- func (m *Version) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Version) XXX_Merge(src proto.Message)
- func (m *Version) XXX_Size() int
- func (m *Version) XXX_Unmarshal(b []byte) error
Constants ¶
const VersionBytes = sha512.Size
VersionBytes is the space used by the version when marshalled.
Variables ¶
var ErrVersionMismatch = errors.New("the stored version does not match with required version")
ErrVersionMismatch is returned when two versions are not matching.
var NoVersion = &Version{}
NoVersion is the default version that should be returned when no version is available in one store for a specific key.
var Operation_Op_name = map[int32]string{
0: "SET",
1: "CONCAT",
10: "ADD",
11: "MUL",
20: "SADD",
21: "SREM",
}
var Operation_Op_value = map[string]int32{
"SET": 0,
"CONCAT": 1,
"ADD": 10,
"MUL": 11,
"SADD": 20,
"SREM": 21,
}
var ParallelMatrix = map[Operation_Op]map[Operation_Op]ParallelType{ Operation_SET: {Operation_SET: ParallelTypeDISALLOWDIFFERENT}, Operation_ADD: {Operation_ADD: ParallelTypeDEFAULT}, Operation_MUL: {Operation_MUL: ParallelTypeDEFAULT}, Operation_SADD: { Operation_SADD: ParallelTypeDEFAULT, Operation_SREM: ParallelTypeDISALLOWEQUAL, }, Operation_SREM: { Operation_SREM: ParallelTypeDEFAULT, Operation_SADD: ParallelTypeDISALLOWEQUAL, }, }
ParallelMatrix is used to know which operation can be run in parallel on a specific object.
Functions ¶
This section is empty.
Types ¶
type BBCEngine ¶
type BBCEngine interface {
Execute(context.Context, string, bool, []*Proof) (bool, []*Proof, error)
}
BBCEngine is the interface for binary Byzantine consensus engine.
type Endorsement ¶
type Endorsement struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"`
Emitter string `protobuf:"bytes,2,opt,name=emitter,proto3" json:"emitter,omitempty"`
Conditions []string `protobuf:"bytes,3,rep,name=conditions,proto3" json:"conditions,omitempty"`
Signature []byte `protobuf:"bytes,16,opt,name=signature,proto3" json:"signature,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*Endorsement) Descriptor ¶
func (*Endorsement) Descriptor() ([]byte, []int)
func (*Endorsement) GetConditions ¶
func (m *Endorsement) GetConditions() []string
func (*Endorsement) GetEmitter ¶
func (m *Endorsement) GetEmitter() string
func (*Endorsement) GetSignature ¶
func (m *Endorsement) GetSignature() []byte
func (*Endorsement) GetUuid ¶
func (m *Endorsement) GetUuid() string
func (Endorsement) Hash ¶
func (e Endorsement) Hash() ([]byte, error)
Hash returns a fixed-size hash of the (unsigned) version of the endorsement. Passed by value because of internal modifications.
func (*Endorsement) ProtoMessage ¶
func (*Endorsement) ProtoMessage()
func (*Endorsement) Reset ¶
func (m *Endorsement) Reset()
func (*Endorsement) String ¶
func (m *Endorsement) String() string
func (*Endorsement) XXX_DiscardUnknown ¶
func (m *Endorsement) XXX_DiscardUnknown()
func (*Endorsement) XXX_Marshal ¶
func (m *Endorsement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Endorsement) XXX_Merge ¶
func (dst *Endorsement) XXX_Merge(src proto.Message)
func (*Endorsement) XXX_Size ¶
func (m *Endorsement) XXX_Size() int
func (*Endorsement) XXX_Unmarshal ¶
func (m *Endorsement) XXX_Unmarshal(b []byte) error
type Engine ¶
type Engine struct {
Store
Network
BBCEngine
*keyring.KeyRing
ActivityProbe chan bool // will receive data when some activity requires persistence
// contains filtered or unexported fields
}
Engine is the main consensus engine that can process queries and endorsements
func (*Engine) Recover ¶
Recover allows to ask the engine to recover one key from other peers. This might be useful after being disconnected from the network.
This is an asynchronous process.
type MessageAcceptor ¶
MessageAcceptor is a filter that can be used to filter incoming proto messages.
type Network ¶
type Network interface {
io.Closer
Broadcast(m proto.Message) error
Accept(ctx context.Context, acceptor MessageAcceptor) <-chan proto.Message
}
Network is the interface network adapters must implement.
type Operation ¶
type Operation struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Op Operation_Op `protobuf:"varint,2,opt,name=op,proto3,enum=consensus.Operation_Op" json:"op,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
Metadata []byte `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*Operation) CheckConflict ¶
CheckConflict returns an error if two operations cannot be executed in parallel.
func (*Operation) Descriptor ¶
func (*Operation) Exec ¶
func (o *Operation) Exec(v *operations.Value) error
Exec returns the result of the given operation against stored data.
func (*Operation) GetMetadata ¶
func (*Operation) GetOp ¶
func (m *Operation) GetOp() Operation_Op
func (*Operation) ProtoMessage ¶
func (*Operation) ProtoMessage()
func (*Operation) XXX_DiscardUnknown ¶
func (m *Operation) XXX_DiscardUnknown()
func (*Operation) XXX_Marshal ¶
func (*Operation) XXX_Unmarshal ¶
type Operation_Op ¶
type Operation_Op int32
const ( // Operations on every values Operation_SET Operation_Op = 0 Operation_CONCAT Operation_Op = 1 // Operations on numeric values Operation_ADD Operation_Op = 10 Operation_MUL Operation_Op = 11 // Operations on set values Operation_SADD Operation_Op = 20 Operation_SREM Operation_Op = 21 )
func (Operation_Op) EnumDescriptor ¶
func (Operation_Op) EnumDescriptor() ([]byte, []int)
func (Operation_Op) String ¶
func (x Operation_Op) String() string
type ParallelType ¶
type ParallelType int16
ParallelType specifies the various options available when specifying a parallelizable operation.
const ( ParallelTypeDEFAULT ParallelType = 0x01 << iota ParallelTypeDISALLOWDIFFERENT ParallelTypeDISALLOWEQUAL )
Definition for ParallelType. Each flag may be combined using bitwise operators.
type Proof ¶
type Proof struct {
// Types that are valid to be assigned to Content:
// *Proof_Query
// *Proof_Endorsement
Content isProof_Content `protobuf_oneof:"content"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*Proof) Descriptor ¶
func (*Proof) GetContent ¶
func (m *Proof) GetContent() isProof_Content
func (*Proof) GetEndorsement ¶
func (m *Proof) GetEndorsement() *Endorsement
func (*Proof) ProtoMessage ¶
func (*Proof) ProtoMessage()
func (*Proof) XXX_DiscardUnknown ¶
func (m *Proof) XXX_DiscardUnknown()
func (*Proof) XXX_Marshal ¶
func (*Proof) XXX_OneofFuncs ¶
func (*Proof) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})
XXX_OneofFuncs is for the internal use of the proto package.
func (*Proof) XXX_Unmarshal ¶
type Proof_Endorsement ¶
type Proof_Endorsement struct {
Endorsement *Endorsement `protobuf:"bytes,2,opt,name=endorsement,proto3,oneof"`
}
type Proof_Query ¶
type Proof_Query struct {
Query *Query `protobuf:"bytes,1,opt,name=query,proto3,oneof"`
}
type Query ¶
type Query struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"`
Policy string `protobuf:"bytes,2,opt,name=policy,proto3" json:"policy,omitempty"`
Emitter string `protobuf:"bytes,3,opt,name=emitter,proto3" json:"emitter,omitempty"`
Deadline *timestamp.Timestamp `protobuf:"bytes,4,opt,name=deadline,proto3" json:"deadline,omitempty"`
Requirements map[string]*Version `` /* 165-byte string literal not displayed */
Operations []*Operation `protobuf:"bytes,6,rep,name=operations,proto3" json:"operations,omitempty"`
Signature []byte `protobuf:"bytes,16,opt,name=signature,proto3" json:"signature,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*Query) CheckConflict ¶
CheckConflict returns an error if two queries are conflicting.
func (*Query) DeadlineTime ¶
DeadlineTime returns the query deadline in native time instead of ptype.
func (*Query) Descriptor ¶
func (*Query) ExpiredSince ¶
ExpiredSince returns true if a query deadline have been reached for at least d duration.
func (*Query) GetDeadline ¶
func (*Query) GetEmitter ¶
func (*Query) GetOperations ¶
func (*Query) GetRequirements ¶
func (*Query) GetSignature ¶
func (*Query) GetTimeout ¶
GetTimeout returns the duration that is remaining for the application of this query. This may be negative.
func (Query) Hash ¶
Hash returns a fixed-size hash of the (unsigned) version of the query. Passed by value because of internal modifications.
func (*Query) ProtoMessage ¶
func (*Query) ProtoMessage()
func (*Query) SetTimeout ¶
SetTimeout updates the deadline of the query according to current time.
func (*Query) XXX_DiscardUnknown ¶
func (m *Query) XXX_DiscardUnknown()
func (*Query) XXX_Marshal ¶
func (*Query) XXX_Unmarshal ¶
type RecoveryHandler ¶
type RecoveryHandler func(*RecoveryRequest) (*RecoveryResponse, error)
RecoveryHandler is a callback used by the RecoveryManager.
type RecoveryManager ¶
type RecoveryManager interface {
RequestRecovery(ctx context.Context, key string) (*RecoveryResponse, error)
AcceptRecovery(ctx context.Context, handler RecoveryHandler)
}
RecoveryManager is a interface that can optionally be proposed by Networks for key recovery support (after a crash or network partition).
type RecoveryRequest ¶
type RecoveryRequest struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*RecoveryRequest) Descriptor ¶
func (*RecoveryRequest) Descriptor() ([]byte, []int)
func (*RecoveryRequest) GetKey ¶
func (m *RecoveryRequest) GetKey() string
func (*RecoveryRequest) ProtoMessage ¶
func (*RecoveryRequest) ProtoMessage()
func (*RecoveryRequest) Reset ¶
func (m *RecoveryRequest) Reset()
func (*RecoveryRequest) String ¶
func (m *RecoveryRequest) String() string
func (*RecoveryRequest) XXX_DiscardUnknown ¶
func (m *RecoveryRequest) XXX_DiscardUnknown()
func (*RecoveryRequest) XXX_Marshal ¶
func (m *RecoveryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RecoveryRequest) XXX_Merge ¶
func (dst *RecoveryRequest) XXX_Merge(src proto.Message)
func (*RecoveryRequest) XXX_Size ¶
func (m *RecoveryRequest) XXX_Size() int
func (*RecoveryRequest) XXX_Unmarshal ¶
func (m *RecoveryRequest) XXX_Unmarshal(b []byte) error
type RecoveryResponse ¶
type RecoveryResponse struct {
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Version *Version `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*RecoveryResponse) Descriptor ¶
func (*RecoveryResponse) Descriptor() ([]byte, []int)
func (*RecoveryResponse) GetData ¶
func (m *RecoveryResponse) GetData() []byte
func (*RecoveryResponse) GetKey ¶
func (m *RecoveryResponse) GetKey() string
func (*RecoveryResponse) GetVersion ¶
func (m *RecoveryResponse) GetVersion() *Version
func (*RecoveryResponse) ProtoMessage ¶
func (*RecoveryResponse) ProtoMessage()
func (*RecoveryResponse) Reset ¶
func (m *RecoveryResponse) Reset()
func (*RecoveryResponse) String ¶
func (m *RecoveryResponse) String() string
func (*RecoveryResponse) XXX_DiscardUnknown ¶
func (m *RecoveryResponse) XXX_DiscardUnknown()
func (*RecoveryResponse) XXX_Marshal ¶
func (m *RecoveryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RecoveryResponse) XXX_Merge ¶
func (dst *RecoveryResponse) XXX_Merge(src proto.Message)
func (*RecoveryResponse) XXX_Size ¶
func (m *RecoveryResponse) XXX_Size() int
func (*RecoveryResponse) XXX_Unmarshal ¶
func (m *RecoveryResponse) XXX_Unmarshal(b []byte) error
type StartCheckpoint ¶
type StartCheckpoint struct {
Queries []string `protobuf:"bytes,1,rep,name=queries,proto3" json:"queries,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*StartCheckpoint) Descriptor ¶
func (*StartCheckpoint) Descriptor() ([]byte, []int)
func (*StartCheckpoint) GetQueries ¶
func (m *StartCheckpoint) GetQueries() []string
func (*StartCheckpoint) ProtoMessage ¶
func (*StartCheckpoint) ProtoMessage()
func (*StartCheckpoint) Reset ¶
func (m *StartCheckpoint) Reset()
func (*StartCheckpoint) String ¶
func (m *StartCheckpoint) String() string
func (*StartCheckpoint) XXX_DiscardUnknown ¶
func (m *StartCheckpoint) XXX_DiscardUnknown()
func (*StartCheckpoint) XXX_Marshal ¶
func (m *StartCheckpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*StartCheckpoint) XXX_Merge ¶
func (dst *StartCheckpoint) XXX_Merge(src proto.Message)
func (*StartCheckpoint) XXX_Size ¶
func (m *StartCheckpoint) XXX_Size() int
func (*StartCheckpoint) XXX_Unmarshal ¶
func (m *StartCheckpoint) XXX_Unmarshal(b []byte) error
type Store ¶
type Store interface {
sync.Locker
io.Closer
// Get returns the value and the version stored currently for the specified key.
Get(key string) (value []byte, version *Version, err error)
// Set sets the value and the version that must be stored for the specified key.
Set(key string, value []byte, version *Version) error
// SetBatch executes the given "Set" operations in a atomic way.
SetBatch(keys []string, values [][]byte, versions []*Version) error
// List returns the map of keys with their values.
List() (map[string]*Version, error)
}
Store is the interface storage drivers must implement.
type Version ¶
type Version struct {
Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func NewVersion ¶
NewVersion returns a new version from some data.
func (*Version) Descriptor ¶
func (*Version) MarshalBinary ¶
MarshalBinary converts the version to a VersionBytes-sized bytes slice.
func (*Version) ProtoMessage ¶
func (*Version) ProtoMessage()
func (*Version) UnmarshalBinary ¶
UnmarshalBinary converts the input to a version.
func (*Version) XXX_DiscardUnknown ¶
func (m *Version) XXX_DiscardUnknown()
func (*Version) XXX_Marshal ¶
func (*Version) XXX_Unmarshal ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bbc implements a very simple Byzantine Broadcast Consensus algorithm.
|
Package bbc implements a very simple Byzantine Broadcast Consensus algorithm. |
|
Package encoding contains database types and (un)marshalling methods.
|
Package encoding contains database types and (un)marshalling methods. |
|
Package operations contains database operations logic internals.
|
Package operations contains database operations logic internals. |