github.com/kchristidis/fabric@v1.0.4-0.20171028114726-837acd08cde1/protos/peer/events.proto (about)

     1  /*
     2  Copyright IBM Corp. 2016 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  		 http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  syntax = "proto3";
    18  
    19  import "common/common.proto";
    20  import "peer/chaincode_event.proto";
    21  import "peer/transaction.proto";
    22  
    23  option java_package = "org.hyperledger.fabric.protos.peer";
    24  option java_outer_classname = "EventsPackage";
    25  option go_package = "github.com/hyperledger/fabric/protos/peer";
    26  
    27  package protos;
    28  
    29  
    30  //----Event objects----
    31  
    32  enum EventType {
    33          REGISTER = 0;
    34          BLOCK = 1;
    35  	CHAINCODE = 2;
    36  	REJECTION = 3;
    37  }
    38  
    39  //ChaincodeReg is used for registering chaincode Interests
    40  //when EventType is CHAINCODE
    41  message ChaincodeReg {
    42      string chaincode_id = 1;
    43      string event_name = 2;
    44  }
    45  
    46  message Interest {
    47      EventType event_type = 1;
    48      //Ideally we should just have the following oneof for different
    49      //Reg types and get rid of EventType. But this is an API change
    50      //Additional Reg types may add messages specific to their type
    51      //to the oneof.
    52      oneof RegInfo {
    53          ChaincodeReg chaincode_reg_info = 2;
    54      }
    55      string chainID = 3;
    56  }
    57  
    58  //---------- consumer events ---------
    59  //Register is sent by consumers for registering events
    60  //string type - "register"
    61  message Register {
    62      repeated Interest events = 1;
    63  }
    64  
    65  //Rejection is sent by consumers for erroneous transaction rejection events
    66  //string type - "rejection"
    67  message Rejection {
    68      Transaction tx = 1;
    69      string error_msg = 2;
    70  }
    71  
    72  //---------- producer events ---------
    73  message Unregister {
    74      repeated Interest events = 1;
    75  }
    76  
    77  // SignedEvent is used for any communication between consumer and producer
    78  message SignedEvent {
    79      // Signature over the event bytes
    80      bytes signature = 1;
    81      // Marshal of Event object
    82      bytes eventBytes = 2;
    83  }
    84  
    85  //Event is used by
    86  //  - consumers (adapters) to send Register
    87  //  - producer to advertise supported types and events
    88  message Event {
    89      //TODO need timestamp
    90  
    91      oneof Event {
    92          //Register consumer sent event
    93          Register register = 1;
    94  
    95          //producer events
    96          common.Block block = 2;
    97          ChaincodeEvent chaincode_event = 3;
    98          Rejection rejection = 4;
    99  
   100          //Unregister consumer sent events
   101          Unregister unregister = 5;
   102      }
   103      // Creator of the event, specified as a certificate chain
   104      bytes creator = 6;
   105  }
   106  
   107  // Interface exported by the events server
   108  service Events {
   109      // event chatting using Event
   110      rpc Chat(stream SignedEvent) returns (stream Event) {}
   111  }