akconsensus

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthAkconsensus = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowAkconsensus   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	//Msgch is the channel for sending a message.
	Msgch = make(chan Message, 100)
)

Functions

func Init

func Init(ctx context.Context, s *setting.Setting, b broadcaster)

Init initialize akconsensus.

func IsSynced

func IsSynced() bool

IsSynced returns true if all validated txs are confirmed.

func IsValid

func IsValid(s *setting.Setting, tr *tx.Transaction, typ tx.Type) error

IsValid returns true if all referring txs are accepted.

func NewProposal

func NewProposal(ctx context.Context, s *setting.Setting, hs ...tx.Hash) error

NewProposal propse a new confirmation for tx h.

func RegisterTxNotifier

func RegisterTxNotifier(n chan []tx.Hash)

RegisterTxNotifier registers a notifier for resolved txs.

func RetryConsensus

func RetryConsensus(ctx context.Context, s *setting.Setting) error

RetryConsensus retries to do consensus for pending txs(mainly due to double spend)

func SetSynced

func SetSynced(s bool)

SetSynced set synced=true for debug.

Types

type Message

type Message struct {
	Proposal   []Proposal         `protobuf:"bytes,1,rep,name=proposal,proto3" json:"proposal"`
	Validation []Validation       `protobuf:"bytes,2,rep,name=validation,proto3" json:"validation"`
	Vote       []Vote             `protobuf:"bytes,3,rep,name=vote,proto3" json:"vote"`
	Signature  *address.Signature `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty"`
}

func NewPopulatedMessage

func NewPopulatedMessage(r randyAkconsensus, easy bool) *Message

func ParseMessage

func ParseMessage(ctx context.Context, s *setting.Setting, buf []byte) (*Message, error)

ParseMessage parses Message and excute an agreement step if needed.

func (*Message) Descriptor

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

func (*Message) Equal

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

func (*Message) Marshal

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

func (*Message) MarshalTo

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

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) Size

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

func (*Message) String

func (m *Message) String() string

func (*Message) Unmarshal

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

func (*Message) XXX_DiscardUnknown

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal

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

func (*Message) XXX_Merge

func (dst *Message) XXX_Merge(src proto.Message)

func (*Message) XXX_Size

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal

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

type Proposal

type Proposal struct {
	Value          github_com_AidosKuneen_aknode_imesh.Status `protobuf:"varint,1,opt,name=value,proto3,casttype=github.com/AidosKuneen/aknode/imesh.Status" json:"value,omitempty"`
	Hash           github_com_AidosKuneen_aklib_tx.Hash       `protobuf:"bytes,2,opt,name=hash,proto3,casttype=github.com/AidosKuneen/aklib/tx.Hash" json:"hash,omitempty"`
	ValidatorsHash []byte                                     `protobuf:"bytes,3,opt,name=validators_hash,json=validatorsHash,proto3" json:"validators_hash,omitempty"`
}

Proposal ia for the first proposal of tx status(VoteValue).

func NewPopulatedProposal

func NewPopulatedProposal(r randyAkconsensus, easy bool) *Proposal

func (*Proposal) Descriptor

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

func (*Proposal) Equal

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

func (*Proposal) Marshal

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

func (*Proposal) MarshalTo

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

func (*Proposal) ProtoMessage

func (*Proposal) ProtoMessage()

func (*Proposal) Reset

func (m *Proposal) Reset()

func (*Proposal) Size

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

func (*Proposal) String

func (m *Proposal) String() string

func (*Proposal) Unmarshal

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

func (*Proposal) XXX_DiscardUnknown

func (m *Proposal) XXX_DiscardUnknown()

func (*Proposal) XXX_Marshal

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

func (*Proposal) XXX_Merge

func (dst *Proposal) XXX_Merge(src proto.Message)

func (*Proposal) XXX_Size

func (m *Proposal) XXX_Size() int

func (*Proposal) XXX_Unmarshal

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

type Validation

type Validation struct {
	Accepted []github_com_AidosKuneen_aklib_tx.Hash `protobuf:"bytes,1,rep,name=accepted,proto3,casttype=github.com/AidosKuneen/aklib/tx.Hash" json:"accepted,omitempty"`
	Rejected []github_com_AidosKuneen_aklib_tx.Hash `protobuf:"bytes,2,rep,name=rejected,proto3,casttype=github.com/AidosKuneen/aklib/tx.Hash" json:"rejected,omitempty"`
	ForSync  bool                                   `protobuf:"varint,3,opt,name=for_sync,json=forSync,proto3" json:"for_sync,omitempty"`
}

Validation is for infoming the validated tx hash.

func NewPopulatedValidation

func NewPopulatedValidation(r randyAkconsensus, easy bool) *Validation

func NewValidation

func NewValidation(s *setting.Setting, accepted, rejected []tx.Hash, forSync bool) (*Validation, error)

NewValidation return a new validation struct

func (*Validation) Descriptor

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

func (*Validation) Equal

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

func (*Validation) Marshal

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

func (*Validation) MarshalTo

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

func (*Validation) ProtoMessage

func (*Validation) ProtoMessage()

func (*Validation) Reset

func (m *Validation) Reset()

func (*Validation) Size

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

func (*Validation) String

func (m *Validation) String() string

func (*Validation) Unmarshal

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

func (*Validation) XXX_DiscardUnknown

func (m *Validation) XXX_DiscardUnknown()

func (*Validation) XXX_Marshal

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

func (*Validation) XXX_Merge

func (dst *Validation) XXX_Merge(src proto.Message)

func (*Validation) XXX_Size

func (m *Validation) XXX_Size() int

func (*Validation) XXX_Unmarshal

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

type ValidationT

type ValidationT struct {
	Validation
	// contains filtered or unexported fields
}

ValidationT is for infoming the validated tx hash with updated time.

type Vote

type Vote struct {
	MBARound       byte                                 `protobuf:"varint,1,opt,name=mbaround,proto3,casttype=byte" json:"mbaround,omitempty"`
	BBARound       byte                                 `protobuf:"varint,2,opt,name=bbaround,proto3,casttype=byte" json:"bbaround,omitempty"`
	BBAStep        byte                                 `protobuf:"varint,3,opt,name=bbastep,proto3,casttype=byte" json:"bbastep,omitempty"`
	Alert          bool                                 `protobuf:"varint,4,opt,name=alert,proto3" json:"alert,omitempty"`
	Halted         bool                                 `protobuf:"varint,5,opt,name=halted,proto3" json:"halted,omitempty"`
	ValidatorsHash []byte                               `protobuf:"bytes,6,opt,name=validators_hash,json=validatorsHash,proto3" json:"validators_hash,omitempty"`
	Hash           github_com_AidosKuneen_aklib_tx.Hash `protobuf:"bytes,7,opt,name=hash,proto3,casttype=github.com/AidosKuneen/aklib/tx.Hash" json:"hash,omitempty"`
	SigJ           *address.Signature                   `protobuf:"bytes,8,opt,name=sig_j,json=sigJ,proto3" json:"sig_j,omitempty"`
}

Vote is for voting alert flag.

func NewPopulatedVote

func NewPopulatedVote(r randyAkconsensus, easy bool) *Vote

func (*Vote) Descriptor

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

func (*Vote) Equal

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

func (*Vote) Marshal

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

func (*Vote) MarshalTo

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

func (*Vote) ProtoMessage

func (*Vote) ProtoMessage()

func (*Vote) Reset

func (m *Vote) Reset()

func (*Vote) Size

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

func (*Vote) String

func (m *Vote) String() string

func (*Vote) Unmarshal

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

func (*Vote) XXX_DiscardUnknown

func (m *Vote) XXX_DiscardUnknown()

func (*Vote) XXX_Marshal

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

func (*Vote) XXX_Merge

func (dst *Vote) XXX_Merge(src proto.Message)

func (*Vote) XXX_Size

func (m *Vote) XXX_Size() int

func (*Vote) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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