consensus

package
v0.0.0-...-1bea25e Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidVotingResult = errors.Error("invalid voting result")
)

Variables

This section is empty.

Functions

func NewConsensus

func NewConsensus(ledger ledger.Ledger, addr *address.Address) *consensus

func RegisterConsensusServer

func RegisterConsensusServer(s *grpc.Server, srv ConsensusServer)

Types

type AcceptRequest

type AcceptRequest struct {
	SendTx               *ledger.Transaction `protobuf:"bytes,1,opt,name=sendTx,proto3" json:"sendTx,omitempty"`
	ReceiveTx            *ledger.Transaction `protobuf:"bytes,2,opt,name=receiveTx,proto3" json:"receiveTx,omitempty"`
	Votes                []*Vote             `protobuf:"bytes,3,rep,name=votes,proto3" json:"votes,omitempty"`
	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
	XXX_unrecognized     []byte              `json:"-"`
	XXX_sizecache        int32               `json:"-"`
}

func (*AcceptRequest) Descriptor

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

func (*AcceptRequest) GetReceiveTx

func (m *AcceptRequest) GetReceiveTx() *ledger.Transaction

func (*AcceptRequest) GetSendTx

func (m *AcceptRequest) GetSendTx() *ledger.Transaction

func (*AcceptRequest) GetVotes

func (m *AcceptRequest) GetVotes() []*Vote

func (*AcceptRequest) ProtoMessage

func (*AcceptRequest) ProtoMessage()

func (*AcceptRequest) Reset

func (m *AcceptRequest) Reset()

func (*AcceptRequest) String

func (m *AcceptRequest) String() string

func (*AcceptRequest) XXX_DiscardUnknown

func (m *AcceptRequest) XXX_DiscardUnknown()

func (*AcceptRequest) XXX_Marshal

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

func (*AcceptRequest) XXX_Merge

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

func (*AcceptRequest) XXX_Size

func (m *AcceptRequest) XXX_Size() int

func (*AcceptRequest) XXX_Unmarshal

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

type AcceptResult

type AcceptResult struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*AcceptResult) Descriptor

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

func (*AcceptResult) ProtoMessage

func (*AcceptResult) ProtoMessage()

func (*AcceptResult) Reset

func (m *AcceptResult) Reset()

func (*AcceptResult) String

func (m *AcceptResult) String() string

func (*AcceptResult) XXX_DiscardUnknown

func (m *AcceptResult) XXX_DiscardUnknown()

func (*AcceptResult) XXX_Marshal

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

func (*AcceptResult) XXX_Merge

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

func (*AcceptResult) XXX_Size

func (m *AcceptResult) XXX_Size() int

func (*AcceptResult) XXX_Unmarshal

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

type Consensus

type Consensus interface {
	Vote(*VoteRequest) (*VoteResult, error)
	Accept(*AcceptRequest) (*AcceptResult, error)
}

type ConsensusClient

type ConsensusClient interface {
	Vote(ctx context.Context, in *VoteRequest, opts ...grpc.CallOption) (*VoteResult, error)
	Accept(ctx context.Context, in *AcceptRequest, opts ...grpc.CallOption) (*AcceptResult, error)
}

ConsensusClient is the client API for Consensus service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewConsensusClient

func NewConsensusClient(cc *grpc.ClientConn) ConsensusClient

type ConsensusServer

type ConsensusServer interface {
	Vote(context.Context, *VoteRequest) (*VoteResult, error)
	Accept(context.Context, *AcceptRequest) (*AcceptResult, error)
}

ConsensusServer is the server API for Consensus service.

type Vote

type Vote struct {
	Ok                   bool     `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"`
	Reason               string   `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"`
	PubKey               []byte   `protobuf:"bytes,3,opt,name=pubKey,proto3" json:"pubKey,omitempty"`
	Signature            []byte   `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Vote) Descriptor

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

func (*Vote) GetOk

func (m *Vote) GetOk() bool

func (*Vote) GetPubKey

func (m *Vote) GetPubKey() []byte

func (*Vote) GetReason

func (m *Vote) GetReason() string

func (*Vote) GetSignature

func (m *Vote) GetSignature() []byte

func (*Vote) Hash

func (m *Vote) Hash() []byte

func (*Vote) ProtoMessage

func (*Vote) ProtoMessage()

func (*Vote) Reset

func (m *Vote) Reset()

func (*Vote) Sign

func (m *Vote) Sign(privateKey *ecdsa.PrivateKey) error

func (*Vote) String

func (m *Vote) String() string

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

type VoteRequest

type VoteRequest struct {
	SendTx               *ledger.Transaction `protobuf:"bytes,1,opt,name=sendTx,proto3" json:"sendTx,omitempty"`
	ReceiveTx            *ledger.Transaction `protobuf:"bytes,2,opt,name=receiveTx,proto3" json:"receiveTx,omitempty"`
	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
	XXX_unrecognized     []byte              `json:"-"`
	XXX_sizecache        int32               `json:"-"`
}

func (*VoteRequest) Descriptor

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

func (*VoteRequest) GetReceiveTx

func (m *VoteRequest) GetReceiveTx() *ledger.Transaction

func (*VoteRequest) GetSendTx

func (m *VoteRequest) GetSendTx() *ledger.Transaction

func (*VoteRequest) ProtoMessage

func (*VoteRequest) ProtoMessage()

func (*VoteRequest) Reset

func (m *VoteRequest) Reset()

func (*VoteRequest) String

func (m *VoteRequest) String() string

func (*VoteRequest) XXX_DiscardUnknown

func (m *VoteRequest) XXX_DiscardUnknown()

func (*VoteRequest) XXX_Marshal

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

func (*VoteRequest) XXX_Merge

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

func (*VoteRequest) XXX_Size

func (m *VoteRequest) XXX_Size() int

func (*VoteRequest) XXX_Unmarshal

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

type VoteResult

type VoteResult struct {
	Vote                 *Vote    `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*VoteResult) Descriptor

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

func (*VoteResult) GetVote

func (m *VoteResult) GetVote() *Vote

func (*VoteResult) ProtoMessage

func (*VoteResult) ProtoMessage()

func (*VoteResult) Reset

func (m *VoteResult) Reset()

func (*VoteResult) String

func (m *VoteResult) String() string

func (*VoteResult) XXX_DiscardUnknown

func (m *VoteResult) XXX_DiscardUnknown()

func (*VoteResult) XXX_Marshal

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

func (*VoteResult) XXX_Merge

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

func (*VoteResult) XXX_Size

func (m *VoteResult) XXX_Size() int

func (*VoteResult) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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