github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/protos/gossip/message.proto (about)

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