aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/watch-cat.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/watch-cat.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/watch-cat.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/watch-cat.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/watch-cat.go
index d08bff9e9..f2e197ebe 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/watch-cat.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/syncer/watch-cat.go
@@ -37,6 +37,7 @@ type WatchCat struct {
timeout time.Duration
configReader configReader
feed chan types.Position
+ lastPosition types.Position
polling time.Duration
ctx context.Context
cancel context.CancelFunc
@@ -69,6 +70,7 @@ func (wc *WatchCat) Feed(position types.Position) {
// Start the WatchCat.
func (wc *WatchCat) Start() {
wc.Stop()
+ wc.lastPosition = types.Position{}
wc.ctx, wc.cancel = context.WithCancel(context.Background())
go func() {
var lastPos types.Position
@@ -124,6 +126,7 @@ func (wc *WatchCat) Start() {
wc.logger.Error("Failed to get recovery votes", "height", lastPos.Height, "error", err)
} else if votes > threshold {
wc.logger.Info("Threshold for recovery reached!")
+ wc.lastPosition = lastPos
break ResetLoop
}
select {
@@ -146,3 +149,8 @@ func (wc *WatchCat) Stop() {
func (wc *WatchCat) Meow() <-chan struct{} {
return wc.ctx.Done()
}
+
+// LastPosition returns the last position for recovery.
+func (wc *WatchCat) LastPosition() types.Position {
+ return wc.lastPosition
+}