go-ethereum/eth/downloader
Martin HS 9045b79bc2
metrics, cmd/geth: change init-process of metrics (#30814)
This PR modifies how the metrics library handles `Enabled`: previously,
the package `init` decided whether to serve real metrics or just
dummy-types.

This has several drawbacks: 
- During pkg init, we need to determine whether metrics are enabled or
not. So we first hacked in a check if certain geth-specific
commandline-flags were enabled. Then we added a similar check for
geth-env-vars. Then we almost added a very elaborate check for
toml-config-file, plus toml parsing.

- Using "real" types and dummy types interchangeably means that
everything is hidden behind interfaces. This has a performance penalty,
and also it just adds a lot of code.

This PR removes the interface stuff, uses concrete types, and allows for
the setting of Enabled to happen later. It is still assumed that
`metrics.Enable()` is invoked early on.

The somewhat 'heavy' operations, such as ticking meters and exp-decay,
now checks the enable-flag to prevent resource leak.

The change may be large, but it's mostly pretty trivial, and from the
last time I gutted the metrics, I ensured that we have fairly good test
coverage.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-12-10 13:27:29 +01:00
..
api.go eth/downloader, eth/tracer: fix typos in comments (#29707) 2024-05-29 14:43:07 +02:00
beacondevsync.go cmd, eth: switch the dev synctarget to hash from block (#28209) 2023-09-29 22:11:15 +03:00
beaconsync.go eth/downloader: move SyncMode to package eth/ethconfig (#30847) 2024-12-03 09:30:26 +01:00
downloader.go eth/downloader: move SyncMode to package eth/ethconfig (#30847) 2024-12-03 09:30:26 +01:00
downloader_test.go eth/protocols/eth: remove Requests in block body (#30562) 2024-10-10 10:47:40 +02:00
events.go cmd,eth: 16400 Add an option to stop geth once in sync. WIP for light mode (#17321) 2019-01-30 08:40:36 +01:00
fetchers.go eth/downloader: purge pre-merge sync code (#29281) 2024-04-30 15:46:53 +02:00
fetchers_concurrent.go eth/downloader: purge pre-merge sync code (#29281) 2024-04-30 15:46:53 +02:00
fetchers_concurrent_bodies.go all: implement flat deposit requests encoding (#30425) 2024-10-09 12:24:58 +02:00
fetchers_concurrent_receipts.go cmd/devp2p, eth: drop eth/66 (#28239) 2023-10-03 15:03:19 +03:00
metrics.go eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00
peer.go cmd, eth: switch the dev synctarget to hash from block (#28209) 2023-09-29 22:11:15 +03:00
queue.go metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
queue_test.go all: implement flat deposit requests encoding (#30425) 2024-10-09 12:24:58 +02:00
resultstore.go all: fix typos in comments (#28682) 2023-12-18 09:35:12 +01:00
skeleton.go eth/downloader: fix case where skeleton reorgs below the filled block (#29358) 2024-04-24 09:07:39 +02:00
skeleton_test.go eth/downloader: fix flaky test (#29852) 2024-05-27 16:26:55 +02:00
statesync.go eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00
testchain_test.go all: remove forkchoicer and reorgNeeded (#29179) 2024-09-04 15:03:06 +02:00