github.com/myafeier/fabric@v1.0.1-0.20170722181825-3a4b1f2bce86/protos/gossip/message.proto (about)

     1  // Copyright IBM Corp. All Rights Reserved.
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  //
     5  syntax = "proto3";
     6  
     7  option go_package = "github.com/hyperledger/fabric/protos/gossip" ;
     8  
     9  package gossip;
    10  
    11  
    12  // Gossip
    13  service Gossip {
    14  
    15      // GossipStream is the gRPC stream used for sending and receiving messages
    16      rpc GossipStream (stream Envelope) returns (stream Envelope) {}
    17  
    18      // Ping is used to probe a remote peer's aliveness
    19      rpc Ping (Empty) returns (Empty) {}
    20  }
    21  
    22  
    23  // Envelope contains a marshalled
    24  // GossipMessage and a signature over it.
    25  // It may also contain a SecretEnvelope
    26  // which is a marshalled Secret
    27  message Envelope {
    28      bytes payload   = 1;
    29      bytes signature = 2;
    30      SecretEnvelope secret_envelope = 3;
    31  }
    32  
    33  // SecretEnvelope is a marshalled Secret
    34  // and a signature over it.
    35  // The signature should be validated by the peer
    36  // that signed the Envelope the SecretEnvelope
    37  // came with
    38  message SecretEnvelope {
    39      bytes payload   = 1;
    40      bytes signature = 2;
    41  }
    42  
    43  // Secret is an entity that might be omitted
    44  // from an Envelope when the remote peer that is receiving
    45  // the Envelope shouldn't know the secret's content.
    46  message Secret {
    47      oneof content {
    48          string internalEndpoint = 1;
    49      }
    50  }
    51  
    52  // GossipMessage defines the message sent in a gossip network
    53  message GossipMessage {
    54  
    55      // used mainly for testing, but will might be used in the future
    56      // for ensuring message delivery by acking
    57      uint64 nonce  = 1;
    58  
    59      // The channel of the message.
    60      // Some GossipMessages may set this to nil, because
    61      // they are cross-channels but some may not
    62      bytes channel = 2;
    63  
    64  
    65      enum Tag {
    66          UNDEFINED    = 0;
    67          EMPTY        = 1;
    68          ORG_ONLY     = 2;
    69          CHAN_ONLY    = 3;
    70          CHAN_AND_ORG = 4;
    71          CHAN_OR_ORG  = 5;
    72      }
    73  
    74      // determines to which peers it is allowed
    75      // to forward the message
    76      Tag tag = 3;
    77  
    78      oneof content {
    79          // Membership
    80          AliveMessage alive_msg = 5;
    81          MembershipRequest mem_req = 6;
    82          MembershipResponse mem_res = 7;
    83  
    84          // Contains a ledger block
    85          DataMessage data_msg = 8;
    86  
    87          // Used for push&pull
    88          GossipHello hello = 9;
    89          DataDigest  data_dig = 10;
    90          DataRequest data_req = 11;
    91          DataUpdate  data_update = 12;
    92  
    93          // Empty message, used for pinging
    94          Empty empty = 13;
    95  
    96          // ConnEstablish, used for establishing a connection
    97          ConnEstablish conn = 14;
    98  
    99          // Used for relaying information
   100          // about state
   101          StateInfo state_info = 15;
   102  
   103          // Used for sending sets of StateInfo messages
   104          StateInfoSnapshot state_snapshot = 16;
   105  
   106          // Used for asking for StateInfoSnapshots
   107          StateInfoPullRequest state_info_pull_req = 17;
   108  
   109          //  Used to ask from a remote peer a set of blocks
   110          RemoteStateRequest state_request = 18;
   111  
   112          // Used to send a set of blocks to a remote peer
   113          RemoteStateResponse state_response = 19;
   114  
   115          // Used to indicate intent of peer to become leader
   116          LeadershipMessage leadership_msg = 20;
   117  
   118          // Used to learn of a peer's certificate
   119          PeerIdentity peer_identity = 21;
   120      }
   121  }
   122  
   123  // StateInfo is used for a peer to relay its state information
   124  // to other peers
   125  message StateInfo {
   126      bytes metadata     = 1;
   127      PeerTime timestamp = 2;
   128      bytes pki_id       = 3;
   129  
   130      // channel_MAC is an authentication code that proves
   131      // that the peer that sent this message knows
   132      // the name of the channel.
   133      bytes channel_MAC  = 4;
   134  }
   135  
   136  // StateInfoSnapshot is an aggregation of StateInfo messages
   137  message StateInfoSnapshot {
   138      repeated Envelope elements = 1;
   139  }
   140  
   141  // StateInfoPullRequest is used to fetch a StateInfoSnapshot
   142  // from a remote peer
   143  message StateInfoPullRequest {
   144      // channel_MAC is an authentication code that proves
   145      // that the peer that sent this message knows
   146      // the name of the channel.
   147      bytes channel_MAC  = 1;
   148  }
   149  
   150  // ConnEstablish is the message used for the gossip handshake
   151  // Whenever a peer connects to another peer, it handshakes
   152  // with it by sending this message that proves its identity
   153  message ConnEstablish {
   154      bytes pki_id          = 1;
   155      bytes identity        = 2;
   156      bytes tls_cert_hash   = 3;
   157  }
   158  
   159  // PeerIdentity defines the identity of the peer
   160  // Used to make other peers learn of the identity
   161  // of a certain peer
   162  message PeerIdentity {
   163      bytes pki_id    = 1;
   164      bytes cert     = 2;
   165      bytes metadata = 3;
   166  }
   167  
   168  // Messages related to pull mechanism
   169  
   170  enum PullMsgType {
   171      UNDEFINED     = 0;
   172      BLOCK_MSG     = 1;
   173      IDENTITY_MSG  = 2;
   174  }
   175  
   176  // DataRequest is a message used for a peer to request
   177  // certain data blocks from a remote peer
   178  message DataRequest {
   179      uint64 nonce             = 1;
   180      repeated string digests  = 2;
   181      PullMsgType msg_type     = 3;
   182  }
   183  
   184  // GossipHello is the message that is used for the peer to initiate
   185  // a pull round with another peer
   186  message GossipHello {
   187      uint64 nonce        = 1;
   188      bytes metadata      = 2;
   189      PullMsgType msg_type = 3;
   190  }
   191  
   192  // DataUpdate is the final message in the pull phase
   193  // sent from the receiver to the initiator
   194  message DataUpdate {
   195      uint64 nonce                = 1;
   196      repeated Envelope data      = 2;
   197      PullMsgType msg_type        = 3;
   198  }
   199  
   200  // DataDigest is the message sent from the receiver peer
   201  // to the initator peer and contains the data items it has
   202  message DataDigest {
   203      uint64 nonce             = 1;
   204      repeated string digests  = 2; // Maybe change this to bitmap later on
   205      PullMsgType msg_type     = 3;
   206  }
   207  
   208  
   209  // Ledger block messages
   210  
   211  // DataMessage is the message that contains a block
   212  message DataMessage {
   213      Payload payload = 1;
   214  }
   215  
   216  // Payload contains a block
   217  message Payload {
   218      uint64  seq_num = 1;
   219      bytes   data    = 2;
   220  }
   221  
   222  
   223  // Membership messages
   224  
   225  // AliveMessage is sent to inform remote peers
   226  // of a peer's existence and activity
   227  message AliveMessage {
   228      Member membership  = 1;
   229      PeerTime timestamp = 2;
   230      bytes identity     = 4;
   231  }
   232  
   233  // Leadership Message is sent during leader election to inform
   234  // remote peers about intent of peer to proclaim itself as leader
   235  message LeadershipMessage {
   236      bytes pki_id        = 1;
   237      PeerTime timestamp = 2;
   238      bool is_declaration = 3;
   239  }
   240  
   241  // PeerTime defines the logical time of a peer's life
   242  message PeerTime {
   243      uint64 inc_num = 1;
   244      uint64 seq_num = 2;
   245  }
   246  
   247  // MembershipRequest is used to ask membership information
   248  // from a remote peer
   249  message MembershipRequest {
   250      Envelope self_information = 1;
   251      repeated bytes known         = 2;
   252  }
   253  
   254  // MembershipResponse is used for replying to MembershipRequests
   255  message MembershipResponse {
   256      repeated Envelope alive = 1;
   257      repeated Envelope dead  = 2;
   258  }
   259  
   260  // Member holds membership-related information
   261  // about a peer
   262  message Member {
   263      string endpoint = 1;
   264      bytes  metadata = 2;
   265      bytes  pki_id    = 3;
   266  }
   267  
   268  
   269  // Empty is used for pinging and in tests
   270  message Empty {}
   271  
   272  
   273  // State transfer
   274  
   275  // RemoteStateRequest is used to ask a set of blocks
   276  // from a remote peer
   277  message RemoteStateRequest {
   278      uint64 start_seq_num = 1;
   279      uint64 end_seq_num = 2;
   280  }
   281  
   282  // RemoteStateResponse is used to send a set of blocks
   283  // to a remote peer
   284  message RemoteStateResponse {
   285      repeated Payload payloads = 1;
   286  }