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

haskell ledger bindings, support uploadDarFile #2146

Merged
merged 3 commits into from
Jul 15, 2019

Conversation

nickchapman-da
Copy link
Contributor

@nickchapman-da nickchapman-da commented Jul 15, 2019

Haskell ledger bindings:

  • Support UploadDarFile RPC of package_management_service
  • And test!

Pull Request Checklist

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

@nickchapman-da nickchapman-da added the component/ledger Sandbox and Ledger API label Jul 15, 2019
Copy link
Contributor

@cocreature cocreature left a comment

Choose a reason for hiding this comment

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

Nice, thank you!



-- Would be nice if the underlying service returned the pid on successful upload.
uploadDarFileGetPid :: LedgerId -> BS.ByteString -> LedgerService (Either String PackageId)
Copy link
Contributor

Choose a reason for hiding this comment

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

That looks like a race condition. What if someone else uploads something in the meantime? Given that we have the package it seems like we can do better even without an API change in the underlying service.

A more important issue: Is this guaranteed to always return a single package id? What if I upload a DAR with multiple packages (e.g. one that has several dependencies). Will they not show up in listPackages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are probably right on both points.
I'll move this function into Test.hs & say it's ok because the caller knows.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Having this in the tests is totally reasonable.

import DA.Ledger.LedgerService
import Network.GRPC.HighLevel.Generated

uploadDarFile :: ByteString -> LedgerService (Either String ()) -- Unlike other services, no LedgerId is needed. (why?!)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get a haddock comment here that explains when you will get back Left?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Great work 👍

@nickchapman-da nickchapman-da merged commit 102cca0 into master Jul 15, 2019
@nickchapman-da nickchapman-da deleted the hlb-upload-dar-file branch July 15, 2019 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/ledger Sandbox and Ledger API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants