Documentation ¶
Index ¶
- Constants
- Variables
- func ListSnapshots(logger raft.Logger, snapDir string) []uint64
- func NewNode(opts ...order.Option) (order.Order, error)
- type BatchTimer
- type GetTxReq
- type MemoryStorage
- type MempoolConfig
- type Node
- func (n *Node) Commit() chan *pb.CommitEvent
- func (n *Node) DelNode(uint64) error
- func (n *Node) GetPendingNonceByAccount(account string) uint64
- func (n *Node) GetPendingTxByHash(hash *types.Hash) pb.Transaction
- func (n *Node) Prepare(tx pb.Transaction) error
- func (n *Node) Quorum() uint64
- func (n *Node) Ready() error
- func (n *Node) ReportState(height uint64, blockHash *types.Hash, txHashList []*types.Hash)
- func (n *Node) Restart() error
- func (n *Node) Start() error
- func (n *Node) Step(msg []byte) error
- func (n *Node) Stop()
- func (n *Node) SubscribeTxEvent(events chan<- pb.Transactions) event.Subscription
- type RAFT
- type RAFTConfig
- type RaftStorage
- type SyncerConfig
- type TimedGenBlock
Constants ¶
const ( DefaultBatchTick = 500 * time.Millisecond DefaultSnapshotCount = 1000 DefaultCheckInterval = 3 * time.Minute DefaultCheckAlive = 13 * time.Minute )
Variables ¶
var MaxSnapshotFiles = 5
MaxSnapshotFiles defines max number of etcd/raft snapshot files to retain on filesystem. Snapshot files are read from newest to oldest, until first intact file is found. The more snapshot files we keep around, the more we mitigate the impact of a corrupted snapshots. This is exported for testing purpose. This MUST be greater equal than 1.
Functions ¶
func ListSnapshots ¶
ListSnapshots returns a list of RaftIndex of snapshots stored on disk. If a file is corrupted, rename the file.
Types ¶
type BatchTimer ¶ added in v1.4.0
type BatchTimer struct {
// contains filtered or unexported fields
}
func NewTimer ¶ added in v1.4.0
func NewTimer(d time.Duration, logger logrus.FieldLogger) *BatchTimer
NewTimer news a timer with default timeout.
func (*BatchTimer) BatchTimeoutEvent ¶ added in v1.4.0
func (timer *BatchTimer) BatchTimeoutEvent() chan bool
func (*BatchTimer) IsBatchTimerActive ¶ added in v1.4.0
func (timer *BatchTimer) IsBatchTimerActive() bool
func (*BatchTimer) StartBatchTimer ¶ added in v1.4.0
func (timer *BatchTimer) StartBatchTimer()
StartBatchTimer starts the batch timer and reset the batchTimerActive to true. TODO (YH): add restartTimer???
func (*BatchTimer) StopBatchTimer ¶ added in v1.4.0
func (timer *BatchTimer) StopBatchTimer()
StopBatchTimer stops the batch timer and reset the batchTimerActive to false.
type MemoryStorage ¶
type MemoryStorage interface { raft.Storage Append(entries []raftpb.Entry) error SetHardState(st raftpb.HardState) error CreateSnapshot(i uint64, cs *raftpb.ConfState, data []byte) (raftpb.Snapshot, error) Compact(compactIndex uint64) error ApplySnapshot(snap raftpb.Snapshot) error }
MemoryStorage is currently backed by etcd/raft.MemoryStorage. This interface is defined to expose dependencies of fsm so that it may be swapped in the future. TODO(jay) Add other necessary methods to this interface once we need them in implementation, e.g. ApplySnapshot.
type MempoolConfig ¶ added in v1.0.1
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) Commit ¶
func (n *Node) Commit() chan *pb.CommitEvent
func (*Node) GetPendingNonceByAccount ¶ added in v1.0.1
func (*Node) GetPendingTxByHash ¶ added in v1.9.0
func (n *Node) GetPendingTxByHash(hash *types.Hash) pb.Transaction
func (*Node) Prepare ¶
func (n *Node) Prepare(tx pb.Transaction) error
Prepare Add the transaction into txpool and broadcast it to other nodes
func (*Node) ReportState ¶
func (*Node) SubscribeTxEvent ¶ added in v1.8.0
func (n *Node) SubscribeTxEvent(events chan<- pb.Transactions) event.Subscription
SubscribeTxEvent subscribes tx event
type RAFT ¶
type RAFT struct { BatchTimeout time.Duration `mapstructure:"batch_timeout"` CheckInterval time.Duration `mapstructure:"check_interval"` CheckAlive time.Duration `mapstructure:"check_alive"` TickTimeout time.Duration `mapstructure:"tick_timeout"` ElectionTick int `mapstructure:"election_tick"` HeartbeatTick int `mapstructure:"heartbeat_tick"` MaxSizePerMsg uint64 `mapstructure:"max_size_per_msg"` MaxInflightMsgs int `mapstructure:"max_inflight_msgs"` CheckQuorum bool `mapstructure:"check_quorum"` PreVote bool `mapstructure:"pre_vote"` DisableProposalForwarding bool `mapstructure:"disable_proposal_forwarding"` MempoolConfig MempoolConfig `mapstructure:"mempool"` SyncerConfig SyncerConfig `mapstructure:"syncer"` }
type RAFTConfig ¶
type RAFTConfig struct { RAFT RAFT TimedGenBlock TimedGenBlock `mapstructure:"timed_gen_block"` }
type RaftStorage ¶
type RaftStorage struct { SnapshotCatchUpEntries uint64 // contains filtered or unexported fields }
RaftStorage encapsulates storages needed for etcd/raft data, i.e. memory, wal
func CreateStorage ¶
func CreateStorage( lg raft.Logger, walDir string, snapDir string, dbDir string, ram MemoryStorage, ) (*RaftStorage, storage.Storage, error)
CreateStorage attempts to create a storage to persist etcd/raft data. If data presents in specified disk, they are loaded to reconstruct storage state.
func (*RaftStorage) Store ¶
func (rs *RaftStorage) Store(entries []raftpb.Entry, hardstate raftpb.HardState, snapshot raftpb.Snapshot) error
Store persists etcd/raft data
func (*RaftStorage) TakeSnapshot ¶
TakeSnapshot takes a snapshot at index i from MemoryStorage, and persists it to wal and disk.