Documentation ¶
Index ¶
- Constants
- Variables
- func ListSnapshots(logger raft.Logger, snapDir string) []uint64
- func NewNode(opts ...order.Option) (order.Order, error)
- type BatchTimer
- type MemoryStorage
- type MempoolConfig
- type Node
- func (n *Node) Commit() chan *pb.CommitEvent
- func (n *Node) DelNode(delID uint64) error
- func (n *Node) GetPendingNonceByAccount(account string) uint64
- 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) Start() error
- func (n *Node) Step(msg []byte) error
- func (n *Node) Stop()
- type RAFT
- type RAFTConfig
- type RaftStorage
- func (rs *RaftStorage) ApplySnapshot(snap raftpb.Snapshot)
- func (rs *RaftStorage) Close() error
- func (rs *RaftStorage) Snapshot() raftpb.Snapshot
- func (rs *RaftStorage) Store(entries []raftpb.Entry, hardstate raftpb.HardState, snapshot raftpb.Snapshot) error
- func (rs *RaftStorage) TakeSnapshot(i uint64, cs raftpb.ConfState, data []byte) error
- type SyncerConfig
Constants ¶
const ( DefaultBatchTick = 500 * time.Millisecond DefaultSnapshotCount = 1000 )
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()
TODO (YH): add restartTimer??? StartBatchTimer starts the batch timer and reset the batchTimerActive to true.
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) Prepare ¶
func (n *Node) Prepare(tx *pb.Transaction) error
Add the transaction into txpool and broadcast it to other nodes
func (*Node) ReportState ¶
type RAFT ¶
type RAFT struct { BatchTimeout time.Duration `mapstructure:"batch_timeout"` 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
}
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) ApplySnapshot ¶
func (rs *RaftStorage) ApplySnapshot(snap raftpb.Snapshot)
ApplySnapshot applies snapshot to local memory storage
func (*RaftStorage) Snapshot ¶
func (rs *RaftStorage) Snapshot() raftpb.Snapshot
Snapshot returns the latest snapshot stored in memory
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.