Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-core-go/data/block"
"github.com/multiversx/mx-chain-go/errors"
logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/errors"
)

const (
Expand Down Expand Up @@ -268,16 +268,20 @@ func GetHeaderTimestamps(
if check.IfNil(header) {
return 0, 0, ErrNilHeaderHandler
}
if check.IfNil(enableEpochsHandler) {
return 0, 0, errors.ErrNilEnableEpochsHandler
}

headerTimestamp := header.GetTimeStamp()
return PrepareTimestampBasedOnHeaderData(headerTimestamp, header.GetEpoch(), enableEpochsHandler)
}

// PrepareTimestampBasedOnHeaderData will prepare timestamp based on the provided data
func PrepareTimestampBasedOnHeaderData(headerTimestamp uint64, headerEpoch uint32, enableEpochsHandler EnableEpochsHandler) (uint64, uint64, error) {
if check.IfNil(enableEpochsHandler) {
return 0, 0, errors.ErrNilEnableEpochsHandler
}
timestampSec := headerTimestamp
timestampMs := headerTimestamp

if !enableEpochsHandler.IsFlagEnabledInEpoch(SupernovaFlag, header.GetEpoch()) {
if !enableEpochsHandler.IsFlagEnabledInEpoch(SupernovaFlag, headerEpoch) {
timestampMs = ConvertTimeStampSecToMs(headerTimestamp)
return timestampSec, timestampMs, nil
}
Expand Down
10 changes: 9 additions & 1 deletion consensus/spos/bls/v2/subroundStartRound.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,21 @@ func (sr *subroundStartRound) indexRoundIfNeeded(pubKeys []string) {

round := sr.RoundHandler().Index()

headerTimestamp := sr.GetUnixTimestampForHeader(epoch)
timestampSec, timestampMs, err := common.PrepareTimestampBasedOnHeaderData(headerTimestamp, epoch, sr.EnableEpochsHandler())
if err != nil {
log.Debug("subroundStartRound.indexRoundIfNeeded cannot prepare timestamp", "error", err.Error(), "epoch", epoch, "round", round)
return
}

roundInfo := &outportcore.RoundInfo{
Round: uint64(round),
SignersIndexes: make([]uint64, 0),
BlockWasProposed: false,
ShardId: shardId,
Epoch: epoch,
Timestamp: sr.GetUnixTimestampForHeader(epoch),
Timestamp: timestampSec,
TimestampMs: timestampMs,
}
roundsInfo := &outportcore.RoundsInfo{
ShardID: shardId,
Expand Down
Loading