Documentation ¶
Index ¶
- Constants
- Variables
- func GetConstructor(cfg *config.Config, hub *component.ComponentHub, cdb consensus.ChainDB, ...) consensus.Constructor
- func GetName() string
- func MaxUint64(x, y uint64) uint64
- type BlockFactory
- func (bf *BlockFactory) BlockFactory() consensus.BlockFactory
- func (bf *BlockFactory) ConsensusInfo() *types.ConsensusInfo
- func (bf *BlockFactory) GetType() consensus.ConsensusType
- func (bf *BlockFactory) Info() string
- func (bf *BlockFactory) InitCluster(cfg *config.Config) error
- func (bf *BlockFactory) IsBlockValid(block *types.Block, bestBlock *types.Block) error
- func (bf *BlockFactory) IsTransactionValid(tx *types.Tx) bool
- func (bf *BlockFactory) JobQueue() chan<- interface{}
- func (bf *BlockFactory) NeedReorganization(rootNo types.BlockNo) bool
- func (bf *BlockFactory) QueueJob(now time.Time, jq chan<- interface{})
- func (bf *BlockFactory) QuitChan() chan interface{}
- func (bf *BlockFactory) Save(tx db.Transaction) error
- func (bf *BlockFactory) Start()
- func (bf *BlockFactory) Ticker() *time.Ticker
- func (bf *BlockFactory) Update(block *types.Block)
- func (bf *BlockFactory) VerifySign(block *types.Block) error
- func (bf *BlockFactory) VerifyTimestamp(*types.Block) bool
- type Cluster
- type LeaderStatus
- type RaftInfo
- type RaftLogger
- func (l *RaftLogger) Debug(args ...interface{})
- func (l *RaftLogger) Debugf(format string, args ...interface{})
- func (l *RaftLogger) Error(args ...interface{})
- func (l *RaftLogger) Errorf(format string, args ...interface{})
- func (l RaftLogger) Fatal(args ...interface{})
- func (l *RaftLogger) Fatalf(format string, args ...interface{})
- func (l *RaftLogger) Info(args ...interface{})
- func (l *RaftLogger) Infof(format string, args ...interface{})
- func (l *RaftLogger) Panic(args ...interface{})
- func (l *RaftLogger) Panicf(format string, args ...interface{})
- func (l *RaftLogger) Warning(args ...interface{})
- func (l *RaftLogger) Warningf(format string, args ...interface{})
Constants ¶
const ( DefaultMarginChainDiff = 1 DefaultTickMS = time.Millisecond * 30 )
Variables ¶
var ( RaftTick = DefaultTickMS RaftSkipEmptyBlock = false )
var ( ErrInvalidRaftID = errors.New("invalid raft raftID") ErrDupRaftUrl = errors.New("duplicated raft bp urls") ErrRaftEmptyTLSFile = errors.New("cert or key file name is empty") ErrNotHttpsURL = errors.New("url scheme is not https") ErrURLInvalidScheme = errors.New("url has invalid scheme") ErrURLInvalidPort = errors.New("url must have host:port style") ErrInvalidRaftBPID = errors.New("raft bp raftID is not ordered. raftID must start with 1 and be sorted") ErrDupBP = errors.New("raft bp description is duplicated") ErrInvalidRaftPeerID = errors.New("peerID of current raft bp is not equals to p2p configure") )
var (
ErrBFQuit = errors.New("block factory quit")
)
Functions ¶
func GetConstructor ¶
func GetConstructor(cfg *config.Config, hub *component.ComponentHub, cdb consensus.ChainDB, sdb *state.ChainStateDB) consensus.Constructor
GetConstructor build and returns consensus.Constructor from New function.
Types ¶
type BlockFactory ¶
type BlockFactory struct { *component.ComponentHub consensus.ChainDB ID string // contains filtered or unexported fields }
BlockFactory implments a raft block factory which generate block each cfg.Consensus.BlockInterval if this node is leader of raft
This can be used for testing purpose.
func New ¶
func New(cfg *config.Config, hub *component.ComponentHub, cdb consensus.ChainDB, sdb *state.ChainStateDB) (*BlockFactory, error)
New returns a BlockFactory.
func (*BlockFactory) BlockFactory ¶
func (bf *BlockFactory) BlockFactory() consensus.BlockFactory
BlockFactory returns r itself.
func (*BlockFactory) ConsensusInfo ¶
func (bf *BlockFactory) ConsensusInfo() *types.ConsensusInfo
func (*BlockFactory) GetType ¶
func (bf *BlockFactory) GetType() consensus.ConsensusType
func (*BlockFactory) InitCluster ¶
func (bf *BlockFactory) InitCluster(cfg *config.Config) error
func (*BlockFactory) IsBlockValid ¶
IsBlockValid checks the consensus level validity of a block.
func (*BlockFactory) IsTransactionValid ¶
func (bf *BlockFactory) IsTransactionValid(tx *types.Tx) bool
IsTransactionValid checks the onsensus level validity of a transaction
func (*BlockFactory) JobQueue ¶
func (bf *BlockFactory) JobQueue() chan<- interface{}
JobQueue returns the queue for block production triggering.
func (*BlockFactory) NeedReorganization ¶
func (bf *BlockFactory) NeedReorganization(rootNo types.BlockNo) bool
NeedReorganization has nothing to do.
func (*BlockFactory) QueueJob ¶
func (bf *BlockFactory) QueueJob(now time.Time, jq chan<- interface{})
QueueJob send a block triggering information to jq.
func (*BlockFactory) QuitChan ¶
func (bf *BlockFactory) QuitChan() chan interface{}
QuitChan returns the channel from which consensus-related goroutines check when shutdown is initiated.
func (*BlockFactory) Save ¶
func (bf *BlockFactory) Save(tx db.Transaction) error
Save has nothging to do.
func (*BlockFactory) Start ¶
func (bf *BlockFactory) Start()
Start run a raft block factory service.
func (*BlockFactory) Ticker ¶
func (bf *BlockFactory) Ticker() *time.Ticker
Ticker returns a time.Ticker for the main consensus loop.
func (*BlockFactory) Update ¶
func (bf *BlockFactory) Update(block *types.Block)
Update has nothging to do.
func (*BlockFactory) VerifySign ¶
func (bf *BlockFactory) VerifySign(block *types.Block) error
VerifySign checks the consensus level validity of a block.
func (*BlockFactory) VerifyTimestamp ¶
func (bf *BlockFactory) VerifyTimestamp(*types.Block) bool
VerifyTimestamp checks the validity of the block timestamp.
type Cluster ¶
type Cluster struct { component.ICompSyncRequester sync.Mutex ID uint64 Size uint16 Member map[uint64]*blockProducer Index map[peer.ID]uint64 // peer ID to raft ID mapping BPUrls []string //for raft server // contains filtered or unexported fields }
raft cluster membership copy from dpos/bp TODO refactoring Cluster represents a cluster of block producers.
func NewCluster ¶
func NewCluster(bf *BlockFactory, raftID uint64, size uint16) *Cluster
type LeaderStatus ¶
type LeaderStatus struct {
// contains filtered or unexported fields
}
type RaftInfo ¶
type RaftInfo struct { Leader string Total string RaftId string Status *json.RawMessage }
type RaftLogger ¶
type RaftLogger struct {
// contains filtered or unexported fields
}
Logger is a logging unit. It controls the flow of messages to a given (swappable) backend.
func NewRaftLogger ¶
func NewRaftLogger(logger *log.Logger) *RaftLogger
func (*RaftLogger) Debug ¶
func (l *RaftLogger) Debug(args ...interface{})
func (*RaftLogger) Debugf ¶
func (l *RaftLogger) Debugf(format string, args ...interface{})
func (*RaftLogger) Error ¶
func (l *RaftLogger) Error(args ...interface{})
func (*RaftLogger) Errorf ¶
func (l *RaftLogger) Errorf(format string, args ...interface{})
func (RaftLogger) Fatal ¶
func (l RaftLogger) Fatal(args ...interface{})
func (*RaftLogger) Fatalf ¶
func (l *RaftLogger) Fatalf(format string, args ...interface{})
func (*RaftLogger) Info ¶
func (l *RaftLogger) Info(args ...interface{})
func (*RaftLogger) Infof ¶
func (l *RaftLogger) Infof(format string, args ...interface{})
func (*RaftLogger) Panic ¶
func (l *RaftLogger) Panic(args ...interface{})
func (*RaftLogger) Panicf ¶
func (l *RaftLogger) Panicf(format string, args ...interface{})
func (*RaftLogger) Warning ¶
func (l *RaftLogger) Warning(args ...interface{})
func (*RaftLogger) Warningf ¶
func (l *RaftLogger) Warningf(format string, args ...interface{})