@@ -16,6 +16,8 @@ import (
1616
1717 "github.com/ethereum/go-ethereum/common"
1818 "github.com/ethereum/go-ethereum/core/types"
19+ "resenje.org/singleflight"
20+
1921 "github.com/ethersphere/bee/v2/pkg/crypto"
2022 "github.com/ethersphere/bee/v2/pkg/log"
2123 "github.com/ethersphere/bee/v2/pkg/postage"
@@ -28,7 +30,6 @@ import (
2830 "github.com/ethersphere/bee/v2/pkg/storer"
2931 "github.com/ethersphere/bee/v2/pkg/swarm"
3032 "github.com/ethersphere/bee/v2/pkg/transaction"
31- "resenje.org/singleflight"
3233)
3334
3435const loggerName = "storageincentives"
@@ -64,7 +65,7 @@ type Agent struct {
6465 batchExpirer postagecontract.PostageBatchExpirer
6566 redistributionStatuser staking.RedistributionStatuser
6667 store storer.Reserve
67- fullSyncedFunc func () bool
68+ reserveSyncedFunc func (depth uint8 ) bool
6869 overlay swarm.Address
6970 quit chan struct {}
7071 wg sync.WaitGroup
@@ -82,7 +83,7 @@ func New(overlay swarm.Address,
8283 batchExpirer postagecontract.PostageBatchExpirer ,
8384 redistributionStatuser staking.RedistributionStatuser ,
8485 store storer.Reserve ,
85- fullSyncedFunc func () bool ,
86+ reserveSyncedFunc func (depth uint8 ) bool ,
8687 blockTime time.Duration ,
8788 blocksPerRound ,
8889 blocksPerPhase uint64 ,
@@ -101,7 +102,7 @@ func New(overlay swarm.Address,
101102 contract : contract ,
102103 batchExpirer : batchExpirer ,
103104 store : store ,
104- fullSyncedFunc : fullSyncedFunc ,
105+ reserveSyncedFunc : reserveSyncedFunc ,
105106 blocksPerRound : blocksPerRound ,
106107 quit : make (chan struct {}),
107108 redistributionStatuser : redistributionStatuser ,
@@ -221,7 +222,7 @@ func (a *Agent) start(blockTime time.Duration, blocksPerRound, blocksPerPhase ui
221222 a .logger .Info ("entered new phase" , "phase" , currentPhase .String (), "round" , round , "block" , block )
222223
223224 a .state .SetCurrentEvent (currentPhase , round )
224- a .state .SetFullySynced (a .fullSyncedFunc ( ))
225+ a .state .SetFullySynced (a .reserveSyncedFunc ( a . store . StorageRadius () ))
225226 a .state .SetHealthy (a .health .IsHealthy ())
226227 safe .Go (a .logger , "storageincentives-purge-stale-round-data" , func () {
227228 a .state .purgeStaleRoundData ()
@@ -416,8 +417,8 @@ func (a *Agent) handleSample(ctx context.Context, round uint64) (bool, error) {
416417 a .metrics .NeighborhoodSelected .Inc ()
417418 a .logger .Info ("neighbourhood chosen" , "round" , round )
418419
419- if ! a .state . IsFullySynced ( ) {
420- a .logger .Info ("skipping round because node is not fully synced" )
420+ if ! a .reserveSyncedFunc ( committedDepth ) {
421+ a .logger .Info ("skipping round because reserve is not synced" , "depth" , committedDepth , "round" , round )
421422 return false , nil
422423 }
423424
0 commit comments