mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 18:31:41 +00:00
22 lines
408 B
Go
22 lines
408 B
Go
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)
|
||
|
|
}
|