Files
sonr/internal/ctx/ctx_sonr.go
T

22 lines
408 B
Go
Raw Normal View History

package ctx
import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type SonrContext struct {
sdk.Context
}
func GetSonrCTX(ctx sdk.Context) *SonrContext {
return &SonrContext{ctx}
}
func (s *SonrContext) GetBlockExpiration(duration time.Duration) int64 {
blockTime := s.BlockTime()
avgBlockTime := float64(blockTime.Sub(blockTime).Seconds())
return int64(duration.Seconds() / avgBlockTime)
}