github.com/s7techlab/cckit@v0.10.5/gateway/chaincode.proto (about)

     1  // Gateway to network/chaincode
     2  // Two types of gateways: 1. Gateway to all chaincodes in Network 2. Gateway to some concrete chaincode instance in some channel
     3  syntax = "proto3";
     4  
     5  option go_package = "github.com/s7techlab/cckit/gateway";
     6  package cckit.gateway;
     7  
     8  import "google/api/annotations.proto";
     9  import "google/protobuf/timestamp.proto";
    10  import "hyperledger/fabric/peer/proposal_response.proto";
    11  import "hyperledger/fabric/peer/chaincode_event.proto";
    12  
    13  import "mwitkow/go-proto-validators/validator.proto";
    14  
    15  // Chaincode communication service. Allows to locate channel/chaincode.
    16  service ChaincodeService {
    17      // Exec: Query or Invoke
    18      rpc Exec (ChaincodeExecRequest) returns (protos.Response) {
    19          option (google.api.http) = {
    20              post: "/chaincode/exec"
    21              body: "*"
    22          };
    23      }
    24  
    25      // Query chaincode on home peer. Do NOT send to orderer.
    26      rpc Query (ChaincodeQueryRequest) returns (protos.Response) {
    27          option (google.api.http) = {
    28              get: "/chaincode/query"
    29          };
    30      }
    31  
    32      // Invoke chaincode on peers, according to endorsement policy and the SEND to orderer
    33      rpc Invoke (ChaincodeInvokeRequest) returns (protos.Response) {
    34          option (google.api.http) = {
    35              post: "/chaincode/invoke"
    36              body: "*"
    37          };
    38      }
    39  
    40      // Chaincode events stream
    41      rpc EventsStream (ChaincodeEventsStreamRequest) returns (stream ChaincodeEvent) {
    42          option (google.api.http) = {
    43              get: "/chaincode/events-stream"
    44          };
    45      }
    46  
    47      // Chaincode events
    48      rpc Events (ChaincodeEventsRequest) returns (ChaincodeEvents) {
    49          option (google.api.http) = {
    50              get: "/chaincode/events"
    51          };
    52      }
    53  }
    54  
    55  // Chaincode events subscription service
    56  service ChaincodeEventsService {
    57      // Chaincode events stream
    58      rpc EventsStream (ChaincodeEventsStreamRequest) returns (stream ChaincodeEvent) {
    59          option (google.api.http) = {
    60              get: "/chaincode/events-stream"
    61          };
    62      }
    63  
    64      // Chaincode events
    65      rpc Events (ChaincodeEventsRequest) returns (ChaincodeEvents) {
    66          option (google.api.http) = {
    67              get: "/chaincode/events"
    68          };
    69      }
    70  }
    71  
    72  // Chaincode instance communication service. Channel/chaincode already fixed.
    73  service ChaincodeInstanceService {
    74      // Exec: Query or Invoke
    75      rpc Exec (ChaincodeInstanceExecRequest) returns (protos.Response) {
    76          option (google.api.http) = {
    77              post: "/chaincode-instance/exec"
    78              body: "*"
    79          };
    80      }
    81  
    82      // Query chaincode on home peer. Do NOT send to orderer.
    83      rpc Query (ChaincodeInstanceQueryRequest) returns (protos.Response) {
    84          option (google.api.http) = {
    85              get: "/chaincode-instance/query"
    86          };
    87      }
    88      // Invoke chaincode on peers, according to endorsement policy and the SEND to orderer
    89      rpc Invoke (ChaincodeInstanceInvokeRequest) returns (protos.Response) {
    90          option (google.api.http) = {
    91              post: "/chaincode-instance/invoke"
    92              body: "*"
    93          };
    94      }
    95      // Chaincode events stream
    96      rpc EventsStream (ChaincodeInstanceEventsStreamRequest) returns (stream ChaincodeEvent) {
    97          option (google.api.http) = {
    98              get: "/chaincode-instance/events-stream"
    99          };
   100      }
   101  
   102      // Chaincode events
   103      rpc Events (ChaincodeInstanceEventsRequest) returns (ChaincodeEvents) {
   104          option (google.api.http) = {
   105              get: "/chaincode-instance/events"
   106          };
   107      }
   108  }
   109  
   110  // Chaincode instance events subscription service
   111  service ChaincodeInstanceEventsService {
   112      // Chaincode events stream
   113      rpc EventsStream (ChaincodeInstanceEventsStreamRequest) returns (stream ChaincodeEvent) {
   114          option (google.api.http) = {
   115              get: "/chaincode-instance/events-stream"
   116          };
   117      }
   118  
   119      // Chaincode events s
   120      rpc Events (ChaincodeInstanceEventsRequest) returns (ChaincodeEvents) {
   121          option (google.api.http) = {
   122              get: "/chaincode-instance/events"
   123          };
   124      }
   125  }
   126  
   127  // Chaincode locator - channel name and chaincode name
   128  message ChaincodeLocator {
   129      // Chaincode name
   130      string chaincode = 1 [(validator.field) = {string_not_empty : true}];
   131      // Channel name
   132      string channel = 2 [(validator.field) = {string_not_empty : true}];
   133  }
   134  
   135  // Chaincode invocation input
   136  message ChaincodeInput {
   137      // Input contains the arguments for invocation.
   138      repeated bytes args = 1;
   139  
   140      // TransientMap contains data (e.g. cryptographic material) that might be used
   141      // to implement some form of application-level confidentiality. The contents
   142      // of this field are supposed to always be omitted from the transaction and
   143      // excluded from the ledger.
   144      map<string, bytes> transient = 2;
   145  }
   146  
   147  
   148  // Chaincode invocation type
   149  enum InvocationType {
   150      // Simulation
   151      INVOCATION_TYPE_QUERY = 0;
   152      // Simulation and applying to ledger
   153      INVOCATION_TYPE_INVOKE = 1;
   154  }
   155  
   156  // Chaincode execution specification
   157  message ChaincodeExecRequest {
   158      ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
   159      InvocationType type = 2;
   160      ChaincodeInput input = 3;
   161  }
   162  
   163  message ChaincodeQueryRequest {
   164      ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
   165      ChaincodeInput input = 3;
   166  }
   167  
   168  message ChaincodeInvokeRequest {
   169      ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
   170      ChaincodeInput input = 3;
   171  }
   172  
   173  
   174  // Block limit number for event stream subscription or event list
   175  // Values can be negative
   176  message BlockLimit {
   177      // Block number
   178      int64 num = 1;
   179  }
   180  
   181  // Chaincode events stream request
   182  message ChaincodeEventsStreamRequest {
   183      ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
   184      BlockLimit from_block = 2;
   185      BlockLimit to_block = 3;
   186      repeated string event_name = 4;
   187  }
   188  
   189  // Chaincode events list request
   190  message ChaincodeEventsRequest {
   191      ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
   192      BlockLimit from_block = 2;
   193      BlockLimit to_block = 3;
   194      repeated string event_name = 4;
   195      uint32 limit = 5;
   196  }
   197  
   198  message ChaincodeInstanceExecRequest {
   199      InvocationType type = 1;
   200      ChaincodeInput input = 2;
   201  }
   202  
   203  message ChaincodeInstanceQueryRequest {
   204      ChaincodeInput input = 1;
   205  }
   206  
   207  message ChaincodeInstanceInvokeRequest {
   208      ChaincodeInput input = 1;
   209  }
   210  
   211  message ChaincodeInstanceEventsStreamRequest {
   212      BlockLimit from_block = 1;
   213      BlockLimit to_block = 2;
   214      repeated string event_name = 3;
   215  }
   216  
   217  message ChaincodeInstanceEventsRequest {
   218      BlockLimit from_block = 1;
   219      BlockLimit to_block = 2;
   220      repeated string event_name = 3;
   221      uint32 limit = 4;
   222  }
   223  
   224  message ChaincodeEvents {
   225      ChaincodeLocator locator = 1 [(validator.field) = {msg_exists : true}];
   226      BlockLimit from_block = 2;
   227      BlockLimit to_block = 3;
   228      repeated ChaincodeEvent items = 4;
   229  }
   230  
   231  message RawJson {
   232      bytes value = 1;
   233  }
   234  
   235  message ChaincodeEvent {
   236      protos.ChaincodeEvent event = 1;
   237      uint64 block = 2;
   238      google.protobuf.Timestamp tx_timestamp = 3;
   239      RawJson payload = 4;
   240  }
   241  
   242