@@ -15,8 +15,6 @@ import (
1515 "github.com/hashicorp/raft"
1616 raftboltdb "github.com/hashicorp/raft-boltdb"
1717 "github.com/rs/zerolog"
18-
19- "github.com/evstack/ev-node/block"
2018)
2119
2220type clusterClient interface {
@@ -47,8 +45,8 @@ type Config struct {
4745// FSM implements raft.FSM for block state
4846type FSM struct {
4947 logger zerolog.Logger
50- state * block. RaftBlockState
51- applyCh chan <- block. RaftApplyMsg
48+ state * RaftBlockState
49+ applyCh chan <- RaftApplyMsg
5250}
5351
5452// NewNode creates a new raft node
@@ -63,7 +61,7 @@ func NewNode(cfg *Config, clusterClient clusterClient, logger zerolog.Logger) (*
6361
6462 fsm := & FSM {
6563 logger : logger .With ().Str ("component" , "raft-fsm" ).Logger (),
66- state : & block. RaftBlockState {},
64+ state : & RaftBlockState {},
6765 }
6866
6967 logStore , err := raftboltdb .NewBoltStore (filepath .Join (cfg .RaftDir , "raft-log.db" ))
@@ -165,7 +163,7 @@ func (n *Node) NodeID() string {
165163}
166164
167165// ProposeBlock proposes a block state to be replicated via raft
168- func (n * Node ) Broadcast (ctx context.Context , state * block. RaftBlockState ) error {
166+ func (n * Node ) Broadcast (ctx context.Context , state * RaftBlockState ) error {
169167 if ! n .IsLeader () {
170168 return fmt .Errorf ("not leader" )
171169 }
@@ -184,7 +182,7 @@ func (n *Node) Broadcast(ctx context.Context, state *block.RaftBlockState) error
184182}
185183
186184// GetState returns the current replicated state
187- func (n * Node ) GetState () * block. RaftBlockState {
185+ func (n * Node ) GetState () * RaftBlockState {
188186 return n .fsm .state
189187}
190188
@@ -231,13 +229,13 @@ func (n *Node) Shutdown() error {
231229}
232230
233231// SetApplyCallback sets a callback to be called when log entries are applied
234- func (n * Node ) SetApplyCallback (ch chan <- block. RaftApplyMsg ) {
232+ func (n * Node ) SetApplyCallback (ch chan <- RaftApplyMsg ) {
235233 n .fsm .applyCh = ch
236234}
237235
238236// Apply implements raft.FSM
239237func (f * FSM ) Apply (log * raft.Log ) interface {} {
240- var state block. RaftBlockState
238+ var state RaftBlockState
241239 if err := json .Unmarshal (log .Data , & state ); err != nil {
242240 f .logger .Error ().Err (err ).Msg ("unmarshal block state" )
243241 return err
@@ -248,7 +246,7 @@ func (f *FSM) Apply(log *raft.Log) interface{} {
248246
249247 if f .applyCh != nil {
250248 select {
251- case f .applyCh <- block. RaftApplyMsg {Index : log .Index , State : & state }:
249+ case f .applyCh <- RaftApplyMsg {Index : log .Index , State : & state }:
252250 default :
253251 f .logger .Warn ().Msg ("apply channel full, dropping message" )
254252 }
@@ -266,7 +264,7 @@ func (f *FSM) Snapshot() (raft.FSMSnapshot, error) {
266264func (f * FSM ) Restore (rc io.ReadCloser ) error {
267265 defer rc .Close ()
268266
269- var state block. RaftBlockState
267+ var state RaftBlockState
270268 if err := json .NewDecoder (rc ).Decode (& state ); err != nil {
271269 return fmt .Errorf ("decode snapshot: %w" , err )
272270 }
@@ -277,7 +275,7 @@ func (f *FSM) Restore(rc io.ReadCloser) error {
277275}
278276
279277type fsmSnapshot struct {
280- state * block. RaftBlockState
278+ state * RaftBlockState
281279}
282280
283281func (s * fsmSnapshot ) Persist (sink raft.SnapshotSink ) error {
0 commit comments