refactor(config): simplify applyEventConfig (follow-up to #6615)#6735
Open
vividctrlalt wants to merge 1 commit intotronprotocol:developfrom
Open
refactor(config): simplify applyEventConfig (follow-up to #6615)#6735vividctrlalt wants to merge 1 commit intotronprotocol:developfrom
vividctrlalt wants to merge 1 commit intotronprotocol:developfrom
Conversation
Follow-up to tronprotocol#6615. The `||` chains guarding eventPluginConfig and eventFilter construction were always-true after the bean-binding refactor (reference.conf ships default `topics` and `contractAddress`), so both fields were built on every startup regardless of `event.subscribe.enable`. Their only consumer (Manager.java:564) is already gated by `isEventSubscribe()`, so collapsing the entry to `if (!ec.isEnable()) return;` is equivalent. Tests in ArgsTest cover enable=false (skip both), enable=true (build both), and enable=true with an invalid filter block (epc built, filter left null).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Follow-up to #6615 as committed in this thread.
The 5-condition
||chain inapplyEventConfig(and the 3-condition variant in the FilterQuery section) was an over-faithful migration of develop'shasPathlogic — that signal is erased once values flow throughConfigBeanFactory+withFallback. Withreference.confshippingtopics = [...]andcontractAddress = [""]defaults, both conditions evaluate totrueon every startup.PARAMETER.eventPluginConfigandPARAMETER.eventFilterwere therefore built unconditionally, regardless ofevent.subscribe.enable.Why it's safe
Manager.java:564is the sole consumer of both fields, gated byisEventSubscribe()(=ec.isEnable()). Whether the fields are populated or null whenenable=falsemakes no observable difference — the plugin never starts.Change
||chains with a single early-out:if (!ec.isEnable()) return;if {...}wrappers (the dedent is mechanical)Tests
ArgsTestregression coverage:testEventConfigDisabledSkipsEpcAndFilter— enable=false → both nulltestEventConfigEnabledBuildsEpcAndFilter— enable=true → both builttestEventConfigEnabledWithInvalidFromBlockLeavesFilterNull— epc built, filter left null on parse failure