-
Notifications
You must be signed in to change notification settings - Fork 18
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
Generic events sub #36
Generic events sub #36
Conversation
ed7b697
to
d0b692a
Compare
8aad187
to
27c6d19
Compare
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.
Here is my first review. Please do not force push new changes as long as the review is in progress and the code is not stable yet.
You may consider integrating into this PR already some of the places where the subscription will be used. Otherwise it could happen that we only realize necessary changes later.
backend/ethereum/glue/doc.go
Outdated
|
||
// Package glue glues together go-perun and go-ethereum. | ||
// It contains generic functionality and can he used even without go-perun. | ||
package glue // import "perun.network/go-perun/backend/ethereum/glue" |
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.
The package name "glue" is very vague. Use package name "subscription" instead?
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.
Renamed it to subscription
for now. I also wanted to put the reorg-resistant TX stuff in here, then the name subscription
would not be enough.
Ok i will try it out at some spots where we use it. |
While using the |
Since the So we either make an addictional |
I don't understand. Why do we need to check for Anyways, adding a package seems cleaner to me. Or could we maybe check for the error without using a dedicated function? |
Ok i meant we need to use
The error checking function is like 5 lines of boilerplate code that i would need in 4-5 places. |
ae9c7db
to
7734441
Compare
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.
Only general comments. Looks good.
@@ -184,7 +184,7 @@ func (f *Funder) sendFundingTx(ctx context.Context, request channel.FundingReq, | |||
// nolint: gocritic | |||
if bal == nil || bal.Sign() <= 0 { | |||
f.log.WithFields(log.Fields{"channel": request.Params.ID(), "idx": request.Idx}).Debug("Skipped zero funding.") | |||
} else if alreadyFunded, err := checkFunded(ctx, bal, contract, fundingID); err != nil { | |||
} else if alreadyFunded, err := f.checkFunded(ctx, bal, contract, fundingID); err != nil { |
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.
Not sure why we check the funding here before we actually do it, but this should probably be not the subject of the current PR.
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.
The framework could be restarted after sending the deposit
transactions, in which case we do not want to send them twice.
It is still a race condition in that case, but should mitigate most of it. This is what the docu means with It is idempotent.
.
@matthiasgeihs
Filter: [][]interface{}{filter}, | ||
} | ||
} | ||
sub, err := subscription.NewEventSub(ctx, f, contract, event, startBlockOffset) |
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.
There is a difference in functionality here compared to before. Before, we were starting from block 1. Here we are starting from current block - offset. I think it's OK because we also do it in other places but in general this is an open issue how to choose the startBlockOffset correctly.
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.
I will open an issue for brainstorming it.
PS: Done in #91
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
7734441
to
a325916
Compare
Add generic event subs in preparation for #19.