Skip to content

Commit

Permalink
move code to submit file
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Nov 4, 2024
1 parent b8afa19 commit bab82bb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
27 changes: 0 additions & 27 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strconv"
"sync"
"sync/atomic"
"time"

"github.com/dymensionxyz/gerr-cosmos/gerrc"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -367,29 +366,3 @@ func (m *Manager) setDA(daconfig string, dalcKV store.KV, logger log.Logger) err
func (m *Manager) setFraudHandler(handler *FreezeHandler) {
m.FraudHandler = handler
}

// SetLastSettlementBlockTime saves the last block in SL timestamp
func (m *Manager) SetLastSettlementBlockTime(time time.Time) error {
_, err := m.Store.SaveLastSettlementBlockTime(uint64(time.UTC().UnixNano()), nil)
if err != nil {
return err
}
return nil
}

// GetLastSettlementBlockTime returns the last block in SL timestamp
func (m *Manager) GetLastSettlementBlockTime() (time.Time, error) {
lastSettlementBlockTime, err := m.Store.LoadLastSettlementBlockTime()
if err != nil {
return time.Time{}, err
}
return time.Unix(0, int64(lastSettlementBlockTime)), nil
}

func (m *Manager) GetSkewTime() (time.Duration, error) {
lastSettlementBlockTime, err := m.GetLastSettlementBlockTime()
if err != nil {
return time.Duration(0), err
}
return m.State.GetLastBlockTime().Sub(lastSettlementBlockTime), nil
}
27 changes: 27 additions & 0 deletions block/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,30 @@ func (m *Manager) UpdateLastSubmittedHeight(event pubsub.Message) {
}
}
}

// SetLastSettlementBlockTime saves the last block on SL timestamp
func (m *Manager) SetLastSettlementBlockTime(time time.Time) error {
_, err := m.Store.SaveLastSettlementBlockTime(uint64(time.UTC().UnixNano()), nil)
if err != nil {
return err
}
return nil
}

// GetLastSettlementBlockTime returns the last block on SL timestamp
func (m *Manager) GetLastSettlementBlockTime() (time.Time, error) {
lastSettlementBlockTime, err := m.Store.LoadLastSettlementBlockTime()
if err != nil {
return time.Time{}, err
}
return time.Unix(0, int64(lastSettlementBlockTime)), nil
}

// GetSkewTime returns the time between the last produced block and the last block submitted to SL
func (m *Manager) GetSkewTime() (time.Duration, error) {
lastSettlementBlockTime, err := m.GetLastSettlementBlockTime()
if err != nil {
return time.Duration(0), err
}
return m.State.GetLastBlockTime().Sub(lastSettlementBlockTime), nil
}

0 comments on commit bab82bb

Please sign in to comment.