Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heartbeat sender factory #4455

Merged
merged 5 commits into from Sep 13, 2022
Merged

Conversation

sstanculeanu
Copy link
Contributor

@sstanculeanu sstanculeanu commented Sep 12, 2022

Description of the reasoning behind the pull request (what feature was missing / how the problem was manifesting itself / what was the motive behind the refactoring)

  • with 2 types of heartbeat sender, a factory is needed to create the proper one

Proposed Changes

  • implement factory

Testing procedure

  • standard system test

@sstanculeanu sstanculeanu marked this pull request as ready for review September 12, 2022 14:44
@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2022

Codecov Report

Merging #4455 (c52b27f) into feat/multisigner (8475ec8) will increase coverage by 0.02%.
The diff coverage is 95.16%.

@@                 Coverage Diff                  @@
##           feat/multisigner    #4455      +/-   ##
====================================================
+ Coverage             73.92%   73.95%   +0.02%     
====================================================
  Files                   697      698       +1     
  Lines                 88727    88808      +81     
====================================================
+ Hits                  65589    65675      +86     
+ Misses                18204    18200       -4     
+ Partials               4934     4933       -1     
Impacted Files Coverage Δ
node/nodeRunner.go 0.00% <0.00%> (ø)
heartbeat/sender/commonHeartbeatSender.go 88.09% <61.53%> (-11.91%) ⬇️
factory/heartbeatV2Components.go 76.31% <100.00%> (+0.31%) ⬆️
heartbeat/sender/heartbeatSender.go 96.29% <100.00%> (+6.74%) ⬆️
heartbeat/sender/heartbeatSenderFactory.go 100.00% <100.00%> (ø)
heartbeat/sender/multikeyHeartbeatSender.go 87.28% <100.00%> (ø)
...eartbeat/sender/peerAuthenticationSenderFactory.go 100.00% <100.00%> (ø)
heartbeat/sender/sender.go 97.03% <100.00%> (+0.74%) ⬆️
heartbeat/status/metricsUpdater.go 100.00% <100.00%> (ø)
p2p/libp2p/netMessenger.go 77.55% <0.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -59,3 +66,26 @@ func (chs *commonHeartbeatSender) generateMessageBytes(

return chs.marshaller.Marshal(msg)
}

// GetCurrentNodeType will return the current sender type and subtype
func (chs *commonHeartbeatSender) GetCurrentNodeType() (string, core.P2PPeerSubType, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 less duplicated code


_, _, err = nodesCoordinator.GetValidatorWithPublicKey(pkBytes)
if err == nil && isMultikey {
return false, heartbeat.ErrInvalidConfiguration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might return more info here, for easier debugging.
Something like:

return false, fmt.Errorf("%w, len(keysMap) = %d, isValidator = %v", heartbeat.ErrInvalidConfiguration, len(keysMap) > 0, err == nil)

hbSender, err := createHeartbeatSender(args)
assert.Nil(t, err)
assert.False(t, check.IfNil(hbSender))
assert.Equal(t, "*sender.heartbeatSender", fmt.Sprintf("%T", hbSender))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -41,7 +42,7 @@ type ArgSender struct {

// sender defines the component which sends authentication and heartbeat messages
type sender struct {
heartbeatSender *heartbeatSender
heartbeatSender heartbeatSenderHandler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for cleaning up
no way around this, thus.

Version: Version,
WorkingDir: "workingDir",
UseLogView: true,
BaseVersion: fmt.Sprintf("%s-base", Version),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why -base suffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clear now, pushed

@ssd04 ssd04 self-requested a review September 12, 2022 20:32
Copy link
Contributor

@ssd04 ssd04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other things from me 👍

@sstanculeanu sstanculeanu merged commit d61698d into feat/multisigner Sep 13, 2022
@sstanculeanu sstanculeanu deleted the heartbeat_sender_factory branch September 13, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants