> `once_flag` is a helper (as the name might suggest) to execute a callable only once. Thus, the scope of the flag does never need to extend beyond where the callable is called. Typically this is function scope.
>
> Move all the flags to function scope to
>
> simplify code review
> avoid mistakes where similarly named flags are accidentally exchanged
> avoid polluting the global scope
>
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19111 | core#19111]]
Depends on D9260