Documentation ¶
Index ¶
- Constants
- Variables
- func BuildPrivateKey(privateKeyStr string) (priKey *ecdsa.PrivateKey, e error)
- func BuildPublicKey(publicKeyStr string) (pubKey *ecdsa.PublicKey, e error)
- func GenKeyPair() (privateKey string, publicKey string, e error)
- type BatchMsg
- type BatchMsgInterpreter
- type Coder
- type Committer
- type EcdsaKeyPair
- type Handler
- type HandlerManager
- type Logger
- func (log *Logger) Debug(args ...interface{})
- func (log *Logger) Debugf(format string, args ...interface{})
- func (log *Logger) Debugw(msg string, keysAndValues ...interface{})
- func (log *Logger) Error(args ...interface{})
- func (log *Logger) Errorf(format string, args ...interface{})
- func (log *Logger) Errorw(msg string, keysAndValues ...interface{})
- func (log *Logger) Fatal(args ...interface{})
- func (log *Logger) Fatalf(format string, args ...interface{})
- func (log *Logger) Fatalw(msg string, keysAndValues ...interface{})
- func (log *Logger) Info(args ...interface{})
- func (log *Logger) Infof(format string, args ...interface{})
- func (log *Logger) Infow(msg string, keysAndValues ...interface{})
- func (log *Logger) Warn(args ...interface{})
- func (log *Logger) Warnf(format string, args ...interface{})
- func (log *Logger) Warnw(msg string, keysAndValues ...interface{})
- type Msg
- type NetHandler
- type ParamsHandler
- type Proposal
- type Verifier
- func (v *Verifier) AddValidator(validatorPublicKey *ecdsa.PublicKey, nodeId string) error
- func (v *Verifier) Close()
- func (v *Verifier) DeleteValidator(nodeId string) error
- func (v *Verifier) Name() string
- func (v *Verifier) SignBatchMsg(batchMsg tbftengine.BatchMsg) (interface{}, error)
- func (v *Verifier) SignProposal(proposal *tbftengine.Proposal) (interface{}, error)
- func (v *Verifier) SignVote(vote *enginePb.Vote) ([]byte, error)
- func (v *Verifier) VerifyBatchMsg(batchMsg tbftengine.BatchMsg) (*tbftengine.VerifyResult, error)
- func (v *Verifier) VerifyProposal(proposal *tbftengine.Proposal) error
- func (v *Verifier) VerifyVote(voteProto *enginePb.Vote) error
- type WalHandler
Constants ¶
View Source
const ( BatchMsgInterpreterName = "batchMsgInterpreter" CommitterName = "committer" NetHandlerName = "netHandler" ParamsHandlerName = "paramsHandler" VerifierName = "verifier" WalHandlerName = "walHandler" ProposalHandlerName = "ProposalHandlerName" )
Variables ¶
View Source
var ( ErrInvalidMsg = errors.New("received invalid msg") ErrNotExistCode = errors.New("response code not found") ErrInvaildCode = errors.New("response code is not 200") )
View Source
var ( ErrErrorHandler = errors.New("the handler initialization error ") ErrNoExistHandler = errors.New("the handler does not exist") )
View Source
var (
Validators = []string{
"127.0.0.1:8081",
"127.0.0.1:8082",
"127.0.0.1:8083",
"127.0.0.1:8084",
}
)
Functions ¶
func BuildPrivateKey ¶
func BuildPrivateKey(privateKeyStr string) (priKey *ecdsa.PrivateKey, e error)
解析私钥
func BuildPublicKey ¶
解析公钥
Types ¶
type BatchMsg ¶
Block 共识内容
type BatchMsgInterpreter ¶
type BatchMsgInterpreter struct { Sequence chan uint64 // contains filtered or unexported fields }
func NewBatchMsgInterpreter ¶
func NewBatchMsgInterpreter(size int, nodeId string) *BatchMsgInterpreter
func (*BatchMsgInterpreter) Close ¶
func (b *BatchMsgInterpreter) Close()
func (*BatchMsgInterpreter) Name ¶
func (b *BatchMsgInterpreter) Name() string
func (*BatchMsgInterpreter) PrepareBatchMsg ¶
func (b *BatchMsgInterpreter) PrepareBatchMsg() <-chan *tbftengine.ProposalBatchMsg
PrepareBatchMsg TBFT引擎通过监听此chan, 获取一个BatchMsg进行共识
func (*BatchMsgInterpreter) SetSequence ¶
func (b *BatchMsgInterpreter) SetSequence(sequence uint64)
type Coder ¶
type Coder struct {
// contains filtered or unexported fields
}
type Committer ¶
type Committer struct { BlockHeight uint64 // contains filtered or unexported fields }
Committer 提交者(持久化)
func (*Committer) Commit ¶
Commit 提交batchMsg
func (*Committer) CommitDone ¶
CommitDone 完成batchMsg提交,通知共识开始下一个共识
type EcdsaKeyPair ¶
type EcdsaKeyPair struct { PrivateKey *ecdsa.PrivateKey PubKey *ecdsa.PublicKey }
func NewEcdsaKeyPair ¶
func NewEcdsaKeyPair(privateKeyStr, publicKeyStr string) *EcdsaKeyPair
func (*EcdsaKeyPair) Sign ¶
func (ekp *EcdsaKeyPair) Sign(content []byte) (signature []byte, e error)
签名
type HandlerManager ¶
type HandlerManager struct { HandlerMap map[string]Handler // contains filtered or unexported fields }
func NewHandlerManager ¶
func NewHandlerManager(logger *Logger, host *tbftengine.ConsensusEngine, hs ...Handler) *HandlerManager
func (*HandlerManager) StartrHandler ¶
func (hm *HandlerManager) StartrHandler() error
StartrHandler start all handlers in the handlerManager
func (*HandlerManager) StopHandler ¶
func (hm *HandlerManager) StopHandler()
StopHandler stop all the handlers in handlerManager
type Logger ¶
type Logger struct { }
type NetHandler ¶
type NetHandler struct {
// contains filtered or unexported fields
}
func NewNetHandler ¶
func NewNetHandler(logger *Logger, size int, nodeId string, host *tbftengine.ConsensusEngine) *NetHandler
func (*NetHandler) BroadCastNetMsg ¶
func (n *NetHandler) BroadCastNetMsg(payload []byte, to string) error
func (*NetHandler) Close ¶
func (n *NetHandler) Close()
func (*NetHandler) Name ¶
func (n *NetHandler) Name() string
func (*NetHandler) Post ¶
func (n *NetHandler) Post(url string, msg *Msg) (err error)
type ParamsHandler ¶
type ParamsHandler struct { }
func NewParamsHandler ¶
func NewParamsHandler() *ParamsHandler
func (*ParamsHandler) Close ¶
func (p *ParamsHandler) Close()
func (*ParamsHandler) GetNewParams ¶
func (p *ParamsHandler) GetNewParams() (validators []string, timeoutPropose time.Duration, timeoutProposeDelta time.Duration, tbftBlocksPerProposer uint64, err error)
GetNewParams 新的一次共识开始时调用,获取共识需要的参数
func (*ParamsHandler) Name ¶
func (p *ParamsHandler) Name() string
type Proposal ¶
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
func NewVerifier ¶
func (*Verifier) AddValidator ¶
func (*Verifier) SignBatchMsg ¶
func (v *Verifier) SignBatchMsg(batchMsg tbftengine.BatchMsg) (interface{}, error)
SignBatchMsg 对BatchMsg签名
func (*Verifier) SignProposal ¶
func (v *Verifier) SignProposal(proposal *tbftengine.Proposal) (interface{}, error)
SignProposal 对Proposal签名
func (*Verifier) SignVote ¶
SignVote 对vote签名
func (*Verifier) VerifyBatchMsg ¶
func (v *Verifier) VerifyBatchMsg(batchMsg tbftengine.BatchMsg) (*tbftengine.VerifyResult, error)
VerifyBatchMsg 验证BatchMsg
func (*Verifier) VerifyProposal ¶
func (v *Verifier) VerifyProposal(proposal *tbftengine.Proposal) error
VerifyProposal 验证Proposal
type WalHandler ¶
type WalHandler struct { }
WalHandler 实现读写共识消息的wal操作
func NewWalHandler ¶
func NewWalHandler() *WalHandler
func (*WalHandler) Close ¶
func (w *WalHandler) Close()
func (*WalHandler) Name ¶
func (w *WalHandler) Name() string
func (*WalHandler) ReadLast ¶
func (w *WalHandler) ReadLast() (*tbftengine.WalEntry, error)
ReadLast 读取一个最新的wal内容
func (*WalHandler) Write ¶
func (w *WalHandler) Write(walEntry *tbftengine.WalEntry) error
Click to show internal directories.
Click to hide internal directories.