Skip to content

cnct: add resolver constructors#3665

Merged
joostjager merged 6 commits into
lightningnetwork:masterfrom
joostjager:resolver-constructors
Nov 12, 2019
Merged

cnct: add resolver constructors#3665
joostjager merged 6 commits into
lightningnetwork:masterfrom
joostjager:resolver-constructors

Conversation

@joostjager
Copy link
Copy Markdown
Contributor

@joostjager joostjager commented Nov 1, 2019

This PR makes the instantiation of resolvers stricter and thereby opens up the path to also add initialization logic to a resolver.

Spin off of #3644

@joostjager joostjager requested a review from Roasbeef as a code owner November 1, 2019 13:12
@joostjager joostjager requested review from halseth and removed request for Roasbeef November 1, 2019 13:12
@joostjager joostjager added this to the 0.9.0 milestone Nov 1, 2019
@joostjager joostjager requested a review from carlaKC November 5, 2019 09:08
Comment thread contractcourt/contract_resolvers.go Outdated
Comment thread contractcourt/briefcase.go Outdated
Comment thread contractcourt/channel_arbitrator.go Outdated
Comment thread contractcourt/briefcase.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do these methods really achieve, that Decode doesn't?

Copy link
Copy Markdown
Contributor Author

@joostjager joostjager Nov 6, 2019

Choose a reason for hiding this comment

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

The end result is the same, but it encapsulates the instantiation of the resolver inside the resolver. If we want to follow up with additional initialization of resolvers (for example set up the initial report), it is clear where to do it. Otherwise that init code will need to be called separately from chan arb which carries more risk of making a mistake.

@joostjager joostjager force-pushed the resolver-constructors branch 2 times, most recently from 3658a7f to 219f047 Compare November 6, 2019 12:32
@joostjager joostjager requested a review from halseth November 6, 2019 12:34
@joostjager
Copy link
Copy Markdown
Contributor Author

Now the resolvers are really ready to get their reports initialized in their (new or decode) constructors

@joostjager joostjager self-assigned this Nov 6, 2019
Comment thread contractcourt/contract_resolvers.go Outdated
Comment thread contractcourt/channel_arbitrator.go Outdated
Comment thread contractcourt/htlc_success_resolver.go Outdated
Comment thread contractcourt/htlc_incoming_contest_resolver.go Outdated
@joostjager joostjager force-pushed the resolver-constructors branch from 219f047 to ee35bed Compare November 6, 2019 13:47
@joostjager joostjager requested a review from halseth November 6, 2019 14:00
Copy link
Copy Markdown
Collaborator

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

I'm struggling to review this one meaningfully, I don't quite have enough context. Added two nits for now, and I'll try another pass when I understand it more.

Comment thread contractcourt/htlc_timeout_resolver.go Outdated
Comment thread contractcourt/htlc_outgoing_contest_resolver.go Outdated
@joostjager joostjager force-pushed the resolver-constructors branch 2 times, most recently from 82c66ff to 9a4aced Compare November 7, 2019 11:53
@joostjager joostjager requested a review from carlaKC November 7, 2019 11:55
@joostjager joostjager force-pushed the resolver-constructors branch from 9a4aced to d9e25f2 Compare November 7, 2019 12:11
Comment thread contractcourt/briefcase.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't really see the point of splitting these into different methods instead of using the interface Decode method, now that they all have the same method signature.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to newResolverFromReader. Resolver structs aren't dumb data structs that can just have a Serializable interfaces. There is more logic required, which is probably also why the Attach and Supplement method appeared.

@joostjager joostjager force-pushed the resolver-constructors branch from d9e25f2 to a8546c4 Compare November 11, 2019 13:34
@joostjager joostjager force-pushed the resolver-constructors branch from a8546c4 to 32249cb Compare November 11, 2019 13:35
@joostjager joostjager requested a review from halseth November 11, 2019 13:42
Copy link
Copy Markdown
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

LGTM 🐟

Comment thread contractcourt/briefcase.go
Comment thread contractcourt/commit_sweep_resolver.go Outdated
return c, nil
}

// AttachConfig should be called once a resolved is successfully decoded from
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: delete in the same commit as we remove the last reference to this method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the last commit that contains the last ref?

Copy link
Copy Markdown
Collaborator

@carlaKC carlaKC left a comment

Choose a reason for hiding this comment

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

LGTM 🌵

@joostjager joostjager merged commit 76c2b2c into lightningnetwork:master Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants