Page MenuHomePhabricator

[avalanche] initialize the avalanche processor only when avalanche is enabled
ClosedPublic

Authored by PiRK on Jun 7 2024, 07:40.

Details

Summary

And use the pointer to the processor in all the places that have access to it to determine whether avalanche is enabled.

Remove the responsibility for IsStakingRewardsActivated to check whether avalanche is activated. All the callsites for this function already check for the avalanche pointer or guarantee in some other way that the processor is initialized (use of EnsureAvalanche, places that have a reference to the processor instead of a pointer). This allows inlining the isAvalancheEnabled function in init.cpp

Depends on D16312

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Jun 7 2024, 07:40
Fabien requested changes to this revision.Jun 7 2024, 08:38
Fabien added a subscriber: Fabien.

One nit, otherwise LGTM

src/init.cpp
2527 ↗(On Diff #48178)

The function is not needed here as it's used in a single place, just inline the GetBoolArg call

This revision now requires changes to proceed.Jun 7 2024, 08:38

completely inline the GetBoolArg call

Fabien added inline comments.
src/init.cpp
1800 ↗(On Diff #48185)

You can store a flag here and reuse it below:
const bool fAvalanche = args.GetBoolArg("-avalanche", AVALANCHE_DEFAULT_ENABLED)

This revision is now accepted and ready to land.Jun 7 2024, 12:59

store and reuse a flag