@@ -46,6 +46,7 @@ public class BlockChainMetricManager {
4646 @ Setter
4747 private String failProcessBlockReason = "" ;
4848 private final Set <String > lastActiveWitnesses = ConcurrentHashMap .newKeySet ();
49+ private long lastNextMaintenanceTime = 0 ;
4950
5051 public BlockChainInfo getBlockChainInfo () {
5152 BlockChainInfo blockChainInfo = new BlockChainInfo ();
@@ -179,11 +180,19 @@ public void applyBlock(BlockCapsule block) {
179180 }
180181
181182 // SR set change detection
182- Set <String > currentWitnesses = chainBaseManager .getWitnessScheduleStore ().getActiveWitnesses ()
183- .stream ()
184- .map (w -> Hex .toHexString (w .toByteArray ()))
185- .collect (Collectors .toSet ());
186- recordSrSetChange (currentWitnesses );
183+ long nextMaintenanceTime = dbManager .getDynamicPropertiesStore ().getNextMaintenanceTime ();
184+ if (lastNextMaintenanceTime == 0 ) {
185+ lastNextMaintenanceTime = nextMaintenanceTime ;
186+ lastActiveWitnesses .addAll (chainBaseManager .getWitnessScheduleStore ().getActiveWitnesses ()
187+ .stream ().map (w -> Hex .toHexString (w .toByteArray ())).collect (Collectors .toSet ()));
188+ } else if (nextMaintenanceTime != lastNextMaintenanceTime ) {
189+ Set <String > currentWitnesses = chainBaseManager .getWitnessScheduleStore ().getActiveWitnesses ()
190+ .stream ()
191+ .map (w -> Hex .toHexString (w .toByteArray ()))
192+ .collect (Collectors .toSet ());
193+ recordSrSetChange (currentWitnesses );
194+ lastNextMaintenanceTime = nextMaintenanceTime ;
195+ }
187196 }
188197
189198 private void recordSrSetChange (Set <String > currentWitnesses ) {
0 commit comments