Documentation
¶
Overview ¶
Copyright (C) 2018 go-cloudcard authors
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func FindProposer(now int64, miners []byteutils.Hash) (proposer byteutils.Hash, err error)
- func TraverseTerm(trie *trie.Trie) ([]byteutils.Hash, error)
- type Group
- type InternalMessage
- type MessageLogs
- type MessageType
- type PBFT
- type Paxos
- func (paxos *Paxos) Clear()
- func (paxos *Paxos) HandleMessage()
- func (paxos *Paxos) NotifyNoBlockArrive()
- func (paxos *Paxos) NotifyNotEnoughWitness()
- func (paxos *Paxos) NotifyRecvConsensusBlock()
- func (paxos *Paxos) Propose(proposalId uint64) (*corepb.Propose, error)
- func (paxos *Paxos) ProposeID(proposer string)
- func (paxos *Paxos) Run()
- func (paxos *Paxos) SendMessage()
- func (paxos *Paxos) SignPropose(pbPropose *corepb.Propose) error
- func (paxos *Paxos) Stop()
- type PbftState
- type PrePrepareMessage
- type Psec
- func (psec *Psec) AutoVote(addr *core.Address, amount *big.Int)
- func (psec *Psec) CancelVote(addr *core.Address, amount *big.Int) error
- func (psec *Psec) Coinbase() *core.Address
- func (psec *Psec) DisableMining()
- func (psec *Psec) EnableMining()
- func (psec *Psec) HandleFork() error
- func (psec *Psec) IsEnable() bool
- func (psec *Psec) IsStandby() bool
- func (psec *Psec) IsSuspend() bool
- func (psec *Psec) IsValidStandbyNode(addr string) bool
- func (psec *Psec) NewState(root *corepb.ConsensusRoot, db cdb.Storage, needChangeLog bool) (state.ConsensusState, error)
- func (psec *Psec) Paxos() core.Paxos
- func (psec *Psec) ResumeMining()
- func (psec *Psec) SetCoinbase(addr *core.Address)
- func (psec *Psec) SetTermId(id uint64)
- func (psec *Psec) Setup(cloudcard core.cloudcard) error
- func (psec *Psec) StandbyCount() int
- func (psec *Psec) StandbyPeers() map[string]string
- func (psec *Psec) Start()
- func (psec *Psec) StartMining()
- func (psec *Psec) StartStandBy()
- func (psec *Psec) Stop()
- func (psec *Psec) SuspendMining()
- func (psec *Psec) TermId() uint64
- func (psec *Psec) UpdateFixedBlock()
- func (psec *Psec) VerifyBlock(*core.Block) error
- func (psec *Psec) Vote(addr *core.Address, amount *big.Int) error
- type PsecState
- func (ps *PsecState) Copy() (state.ConsensusState, error)
- func (ps *PsecState) GenesisConsensusState(chain *core.BlockChain) (state.ConsensusState, error)
- func (ps *PsecState) NextConsensusState(elapsedSecond int64, worldState state.WorldState) (state.ConsensusState, error)
- func (ps *PsecState) Proposer() byteutils.Hash
- func (ps *PsecState) Replay(done state.ConsensusState) error
- func (ps *PsecState) RootHash() *corepb.ConsensusRoot
- func (ps *PsecState) String() string
- func (ps *PsecState) Term() ([]byteutils.Hash, error)
- func (ps *PsecState) TermRoot() byteutils.Hash
- func (ps *PsecState) Timestamp() int64
- type RequestMessage
- type ResponseMessage
- type SortableVoters
- type Stage
- type State
- func (state *State) Commit(commitMsg *InternalMessage) (*ResponseMessage, *RequestMessage, error)
- func (state *State) PrePrepare(prePrepareMsg *PrePrepareMessage) (*InternalMessage, error)
- func (state *State) Prepare(prepareMsg *InternalMessage) (*InternalMessage, error)
- func (state *State) Start(reqMsg *RequestMessage) (*PrePrepareMessage, error)
- type Term
Constants ¶
const ( STANDBYNUM = 5 NoBlockArrive = iota NotEnoughWitness RecvConsensusBlock )
const ( MsgPreprepare = iota + 100 MsgPrepare MsgCommit )
const ( StagePreprepared = iota + 200 StagePrepared StageCommitted )
const (
MaxMiningDuration = int64(10 * 365 * 24 * 60 * 60)
)
Variables ¶
var ( StandbyNodesMapIsEmptyError = errors.New("standby nodes map is empty") StandbyNodeNotFoundError = errors.New("the standby node not found") StandbyNodeSignError = errors.New("the standby node sign failed") PBFTSignMessageError = errors.New("PBFT sign msg error") )
var ( ErrInvalidBlockWitness = errors.New("invalid block witness") ErrAppendNewBlockFailed = errors.New("failed to append new block to real chain") ErrCannotMintWhenDisable = errors.New("cannot mint block now, waiting for enable it again") ErrCannotMintWhenPending = errors.New("cannot mint block now, waiting for cancel suspended again") ErrWaitingBlockInLastSlot = errors.New("cannot mint block now, waiting for last block") ErrGenerateNextConsensusState = errors.New("failed to generate next consensus state") ErrInvalidBlockProposer = errors.New("invalid block proposer") ErrCloneWitnessTrie = errors.New("failed to clone witness trie") ErrNotBlockMintTime = errors.New("now is not time to mint block") ErrFoundNilProposer = errors.New("found a nil proposer") ErrInvalidWitnesses = errors.New("the size of initial witness in genesis block is invalid, should be equal ") ErrBlockMintedInNextSlot = errors.New("cannot mint block now, there is a block minted in current slot") ErrGetTerm = errors.New("failed to get term with current genesis and term") ErrInvalidProtoToTerm = errors.New("protobuf message cannot be converted into Term") ErrVerifyPreprepareMsgError = errors.New("verify preprepare msg sign error") ErrSeqIdIsTooLow = errors.New("msg seq id is too low") ErrWrongMiner = errors.New("wrong miner") )
Functions ¶
func FindProposer ¶
Types ¶
type InternalMessage ¶
type InternalMessage struct { MsgType MessageType ViewId int64 SeqId int64 Digest string NodeId string }
InternalMessage
type MessageLogs ¶
type MessageLogs struct { ReqMsg *RequestMessage PrepareMsgs map[string]*InternalMessage CommitMsgs map[string]*InternalMessage }
MessageLogs
type MessageType ¶
type MessageType int
const ( MsgTypePrepare MessageType = 2000 + iota MsgTypeCommit )
type PBFT ¶
type PBFT struct {
// contains filtered or unexported fields
}
Pbft
func (*PBFT) SignPreprepareMsg ¶
func (pbft *PBFT) SignPreprepareMsg(msg *corepb.PreprepareMsg) error
type Paxos ¶
type Paxos struct {
// contains filtered or unexported fields
}
func (*Paxos) HandleMessage ¶
func (paxos *Paxos) HandleMessage()
func (*Paxos) NotifyNoBlockArrive ¶
func (paxos *Paxos) NotifyNoBlockArrive()
func (*Paxos) NotifyNotEnoughWitness ¶
func (paxos *Paxos) NotifyNotEnoughWitness()
func (*Paxos) NotifyRecvConsensusBlock ¶
func (paxos *Paxos) NotifyRecvConsensusBlock()
func (*Paxos) SendMessage ¶
func (paxos *Paxos) SendMessage()
type PrePrepareMessage ¶
type PrePrepareMessage struct { ViewId int64 SeqId int64 Digest string ReqMsg *RequestMessage }
PrePrepareMessage
type Psec ¶
type Psec struct {
// contains filtered or unexported fields
}
Psec
func (*Psec) CancelVote ¶
CancelVote
func (*Psec) DisableMining ¶
func (psec *Psec) DisableMining()
func (*Psec) EnableMining ¶
func (psec *Psec) EnableMining()
func (*Psec) HandleFork ¶
func (*Psec) IsValidStandbyNode ¶
func (*Psec) NewState ¶
func (psec *Psec) NewState(root *corepb.ConsensusRoot, db cdb.Storage, needChangeLog bool) (state.ConsensusState, error)
NewState creates a new psec state.
func (*Psec) ResumeMining ¶
func (psec *Psec) ResumeMining()
func (*Psec) SetCoinbase ¶
func (*Psec) StandbyCount ¶
func (*Psec) StandbyPeers ¶
func (*Psec) StartMining ¶
func (psec *Psec) StartMining()
func (*Psec) StartStandBy ¶
func (psec *Psec) StartStandBy()
func (*Psec) SuspendMining ¶
func (psec *Psec) SuspendMining()
func (*Psec) UpdateFixedBlock ¶
func (psec *Psec) UpdateFixedBlock()
type PsecState ¶
type PsecState struct {
// contains filtered or unexported fields
}
TermState
func (*PsecState) GenesisConsensusState ¶
func (ps *PsecState) GenesisConsensusState(chain *core.BlockChain) (state.ConsensusState, error)
func (*PsecState) NextConsensusState ¶
func (ps *PsecState) NextConsensusState(elapsedSecond int64, worldState state.WorldState) (state.ConsensusState, error)
func (*PsecState) RootHash ¶
func (ps *PsecState) RootHash() *corepb.ConsensusRoot
type RequestMessage ¶
RequestMessage
type ResponseMessage ¶
ResponseMessage
type SortableVoters ¶
func (SortableVoters) Data ¶
func (sv SortableVoters) Data() []*core.Voter
func (SortableVoters) Len ¶
func (sv SortableVoters) Len() int
func (SortableVoters) Less ¶
func (sv SortableVoters) Less(i, j int) bool
func (SortableVoters) Swap ¶
func (sv SortableVoters) Swap(i, j int)
type State ¶
type State struct { ViewId int64 MsgLogs *MessageLogs LastSeqId int64 CurrentStage Stage }
PbftState
func (*State) Commit ¶
func (state *State) Commit(commitMsg *InternalMessage) (*ResponseMessage, *RequestMessage, error)
Commit
func (*State) PrePrepare ¶
func (state *State) PrePrepare(prePrepareMsg *PrePrepareMessage) (*InternalMessage, error)
PrePrepare
func (*State) Prepare ¶
func (state *State) Prepare(prepareMsg *InternalMessage) (*InternalMessage, error)
Prepare
func (*State) Start ¶
func (state *State) Start(reqMsg *RequestMessage) (*PrePrepareMessage, error)
Start
type Term ¶
type Term struct {
// contains filtered or unexported fields
}