Fix missing disabling of `eth` service (#2199)

why:
  Otherwise it might crash on a not fully initialised call back function
  when most other functions are disabled during the early sync state.
This commit is contained in:
Jordan Hrycaj 2024-05-20 15:02:36 +00:00 committed by GitHub
parent de0388919f
commit bc8e3c02ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -610,6 +610,10 @@ method handleNewBlock*(ctx: EthWireRef,
totalDifficulty: DifficultyInt): totalDifficulty: DifficultyInt):
Result[void, string] Result[void, string]
{.gcsafe.} = {.gcsafe.} =
if ctx.enableTxPool != Enabled:
when trMissingOrDisabledGossipOk:
notEnabled("handleNewBlock")
return ok()
try: try:
if ctx.chain.com.forkGTE(MergeFork): if ctx.chain.com.forkGTE(MergeFork):
debug "Dropping peer for sending NewBlock after merge (EIP-3675)", debug "Dropping peer for sending NewBlock after merge (EIP-3675)",
@ -632,6 +636,10 @@ method handleNewBlockHashes*(ctx: EthWireRef,
hashes: openArray[NewBlockHashesAnnounce]): hashes: openArray[NewBlockHashesAnnounce]):
Result[void, string] Result[void, string]
{.gcsafe.} = {.gcsafe.} =
if ctx.enableTxPool != Enabled:
when trMissingOrDisabledGossipOk:
notEnabled("handleNewBlockHashes")
return ok()
try: try:
if ctx.chain.com.forkGTE(MergeFork): if ctx.chain.com.forkGTE(MergeFork):
debug "Dropping peer for sending NewBlockHashes after merge (EIP-3675)", debug "Dropping peer for sending NewBlockHashes after merge (EIP-3675)",