-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
peer: more interfaces, refactor unit tests #5067
Changes from 3 commits
49e417e
e5bf234
d79a55c
6ca8946
af6a358
5274bac
1a831e1
a60c600
d18560a
c013447
17f253b
8390f7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ import ( | |
"net" | ||
"time" | ||
|
||
"github.com/lightningnetwork/lnd/htlcswitch" | ||
"github.com/lightningnetwork/lnd/lnwallet" | ||
"github.com/lightningnetwork/lnd/lnwire" | ||
) | ||
|
||
|
@@ -54,3 +56,35 @@ type MessageConn interface { | |
// ReadNextBody reads the next body. | ||
ReadNextBody([]byte) ([]byte, error) | ||
} | ||
|
||
// MessageLink is an interface that contains some functionality from a | ||
// htlcswitch.ChannelLink. | ||
type MessageLink interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be more idiomatic Go, maybe we could name this interface There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer to keep it as MessageLink |
||
// ChanID returns the ChannelID of the MessageLink. | ||
ChanID() lnwire.ChannelID | ||
|
||
// HandleChannelUpdate passes lnwire.Message to the MessageLink. | ||
HandleChannelUpdate(lnwire.Message) | ||
} | ||
|
||
// MessageSwitch is an interface that manages setup, retrieval, and shutdown of | ||
// MessageLink implementations. | ||
type MessageSwitch interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The motivation is to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. channelSwitch needs to wrap There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you could get over There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to be able to replace
So IMO this is a workaround until we can cleanup the htlcswitch package. One thing would be to remove ** I have a test-case that requires a non-nil link to be returned. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a blocker for your ACK? I can figure out the best step to avoid this "type confusion" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree we should do this. And what confused me here is that, the change made in current commits do not acheive this goal? You have a
This is probably my main blocker because, imo, packages should be independent in the sense of actual implementations of interfaces.
You could also make
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests do not use |
||
// BestHeight returns the best height known to the MessageSwitch. | ||
BestHeight() uint32 | ||
|
||
// CircuitModifier returns a reference to a CircuitModifier. | ||
CircuitModifier() htlcswitch.CircuitModifier | ||
|
||
// GetLink retrieves a MessageLink given a ChannelID. | ||
GetLink(lnwire.ChannelID) (MessageLink, error) | ||
|
||
// InitLink creates a link given a ChannelLinkConfig and | ||
// LightningChannel. | ||
InitLink(htlcswitch.ChannelLinkConfig, | ||
*lnwallet.LightningChannel) error | ||
|
||
// RemoveLink removes a MessageLink from the MessageSwitch given a | ||
// ChannelID. | ||
RemoveLink(lnwire.ChannelID) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MessageLink
orChannelLink
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is using the underlying htlcswitch method
AddLink
andNewChannelLink
, so I'd say aChannelLink