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

Categorise chaincode operations by peer and gateway #194

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Jun 2, 2024

  1. Categorise chaincode operations by peer and gateway

    Previous implementation was standalone functions, with all requiring both a gRPC
    connection and a client signing identity. This required:
    
    - An underisably large number of prameters.
    - Unwritten conventions on parameter ordering.
    - Documentation comments to highlight when the connection should be to a
      specific peer or to an organization gateway.
    - Duplication of arguments across multiple functions for calling code driving
      the chaincode lifecycle.
    
    This implementation defines a Peer and Gateway struct that hold a gRPC
    connection and a client identity. Each of these types defines methods
    appropriate to their logical role to:
    
    - Avoid the need to provide gRPC connection and client identity arguments on
      every call.
    - Provide calling code with logical context for what they are interacting with.
    - Allow IDE code completion to suggest appropriate methods for the connection type.
    
    For example, this pseudo-code flow:
    
        chaincode.Install(ctx, peerConnection, id, chaincodePackage)
        chaincode.Approve(ctx, gatewayConnection, id, chaincodeDefinition)
        chaincode.Commit(ctx, gatewayConnection, id, chaincodeDefinition)
    
    becomes:
    
        peer.Install(ctx, chaincodePackage)
        gateway.Approve(ctx, chaincodeDefinition)
        gateway.Commit(ctx, chaincodeDefinition)
    
    Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
    bestbeforetoday committed Jun 2, 2024
    Configuration menu
    Copy the full SHA
    c4071a7 View commit details
    Browse the repository at this point in the history