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

Execution SDK on Cosmos #1463

Merged
merged 25 commits into from
Nov 22, 2019
Merged

Execution SDK on Cosmos #1463

merged 25 commits into from
Nov 22, 2019

Conversation

krhubert
Copy link
Contributor

@krhubert krhubert commented Nov 4, 2019

@NicolasMahe NicolasMahe reopened this Nov 19, 2019
@NicolasMahe NicolasMahe changed the title wip execution Execution SDK on Cosmos Nov 19, 2019
@NicolasMahe NicolasMahe added this to the next milestone Nov 19, 2019
@NicolasMahe
Copy link
Member

@krhubert please check the cosmos stream function, it's completely related with #1509.
I'm ok if you think it easier to combine #1509 in this PR to make proper implementation of stream.

- 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
cosmos/client.go Outdated Show resolved Hide resolved
cosmos/module.go Outdated Show resolved Hide resolved
sdk/execution/sdk.go Outdated Show resolved Hide resolved
} else {
hashC <- hash
}
case <-ctx.Done():
Copy link
Member

@NicolasMahe NicolasMahe Nov 21, 2019

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 ;)

e2e/execution_test.go Outdated Show resolved Hide resolved
@NicolasMahe NicolasMahe marked this pull request as ready for review November 21, 2019 09:03
@NicolasMahe
Copy link
Member

Update of the js libs: mesg-foundation/js-sdk#135

Copy link
Member

@NicolasMahe NicolasMahe left a 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!

Comment on lines +145 to +169
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)
}()
Copy link
Member

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
  }
}

Copy link
Member

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()
Copy link
Member

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?

Copy link
Member

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.

sdk/execution/sdk.go Outdated Show resolved Hide resolved
sdk/execution/sdk.go Outdated Show resolved Hide resolved
execC := make(chan *execution.Execution)
errC := make(chan error)
go func() {
loop:
Copy link
Member

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:

Copy link
Member

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 ;)

@antho1404 antho1404 merged commit bebd574 into dev Nov 22, 2019
@antho1404 antho1404 deleted the feature/execution-store branch November 22, 2019 10:13
@NicolasMahe NicolasMahe added release:change Pull requests that change something existant breaking change and removed release:change Pull requests that change something existant labels Nov 26, 2019
@NicolasMahe NicolasMahe mentioned this pull request Nov 26, 2019
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.

3 participants