Skip to content

Commit a51bd4a

Browse files
authored
Record last block timestamp (#1532)
1 parent c7fb906 commit a51bd4a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

action/protocol/poll/staking_committee.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
type stakingCommittee struct {
2828
hu config.HeightUpgrade
29+
getTipBlockTime GetTipBlockTime
2930
getEpochHeight GetEpochHeight
3031
getEpochNum GetEpochNum
3132
electionCommittee committee.Committee
@@ -67,6 +68,7 @@ func NewStakingCommittee(
6768
electionCommittee: ec,
6869
governanceStaking: gs,
6970
nativeStaking: ns,
71+
getTipBlockTime: getTipBlockTime,
7072
getEpochHeight: getEpochHeight,
7173
getEpochNum: getEpochNum,
7274
rp: rp,
@@ -152,9 +154,13 @@ func (sc *stakingCommittee) persistNativeBuckets(ctx context.Context, receipt *a
152154
return nil
153155
}
154156
log.L().Info("Store native buckets to election db", zap.Int("size", len(sc.currentNativeBuckets)))
157+
ts, err := sc.getTipBlockTime()
158+
if err != nil {
159+
return err
160+
}
155161
if err := sc.electionCommittee.PutNativePollByEpoch(
156162
sc.rp.GetEpochNum(raCtx.BlockHeight)+1, // The native buckets recorded in this epoch will be used in next one
157-
raCtx.BlockTimeStamp,
163+
ts, // The timestamp of last block is used to represent the current buckets timestamp
158164
sc.currentNativeBuckets,
159165
); err != nil {
160166
return err

0 commit comments

Comments
 (0)