-
Notifications
You must be signed in to change notification settings - Fork 13
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
Execution SDK on Cosmos #1463
Execution SDK on Cosmos #1463
Conversation
62fec93
to
6fb82d4
Compare
…its the appropriate cosmos events and manage errors.
6a2bd92
to
3216db2
Compare
- remove/comment panics - handle channel closing - move filter related methods to api package - change app.handler return type - add valid method for hash - move some part to x packages
1b0bf06
to
1da0b08
Compare
0157e3b
to
e78699b
Compare
} else { | ||
hashC <- hash | ||
} | ||
case <-ctx.Done(): |
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.
Nice use of a context ;)
Update of the js libs: mesg-foundation/js-sdk#135 |
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.
🎊 working well on my side!
go func() { | ||
loop: | ||
for { | ||
select { | ||
case event := <-eventStream: | ||
tags := event.Events[EventHashType] | ||
if len(tags) != 1 { | ||
errC <- fmt.Errorf("event %s has %d tag(s), but only 1 is expected", EventHashType, len(tags)) | ||
break | ||
} | ||
|
||
hash, err := hash.Decode(tags[0]) | ||
if err != nil { | ||
errC <- err | ||
} else { | ||
hashC <- hash | ||
} | ||
case <-ctx.Done(): | ||
break loop | ||
} | ||
} | ||
close(errC) | ||
close(hashC) | ||
c.Unsubscribe(context.Background(), subscriber, query) | ||
}() |
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.
For code clarity, this could be move as a separated function and like that, we could have the following:
defer func() {
close(errC)
close(hashC)
c.Unsubscribe(context.Background(), subscriber, query)
}()
for {
select {
case <- Done:
return
}
}
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.
@krhubert i let you make the decision ;)
@@ -123,6 +115,8 @@ func loadOrGenDevGenesis(app *cosmos.App, kb *cosmos.Keybase, cfg *config.Config | |||
} | |||
|
|||
func main() { | |||
xrand.SeedInit() |
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 clear what's the reason for this. Is it for the subscriber name that we generate?
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.
yes. but i think the goal of the package xrand is to centralized on random related function.
So we don't have the send the random everywhere in the code. it's done once and that's it.
execC := make(chan *execution.Execution) | ||
errC := make(chan error) | ||
go func() { | ||
loop: |
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.
same comment as before, could be done with a defer and return in the ctx.Done
instead of a loop:
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.
@krhubert i let you make the decision ;)
… yet (issue with new node sync)
This PR moves the Execution SDK on Cosmos 🎊
Dependent on #1509 and #1512
You can check the commits after 499b03b:
https://github.com/mesg-foundation/engine/pull/1463/files/499b03b84cf150f0dfe6a72947da81446a6a2f27..02e26b848ab0388a8957b359c1bcd8c24b11f88c