github.com/turingchain2020/turingchain@v1.1.21/types/proto/p2pnext.proto (about)

     1  syntax = "proto3";
     2  
     3  import "p2p.proto";
     4  import "blockchain.proto";
     5  
     6  package types;
     7  option go_package = "github.com/turingchain2020/turingchain/types";
     8  
     9  /**
    10   * 通用消息体
    11   */
    12  
    13  message MessageComm {
    14      // shared between all requests
    15      string version    = 1; // client version
    16      int64  timestamp  = 2; // unix time
    17      string id         = 3; // allows requesters to use request data when processing a response
    18      bool   gossip     = 4; // true to have receiver peer gossip the message to neighbors
    19      string nodeId     = 5; // id of node that created the message (not the peer that may have sent it). =base58(multihash(nodePubKey))
    20      bytes  nodePubKey = 6; // Authoring node Secp256k1 public key (32bytes) - protobufs serielized
    21      bytes  sign       = 7; // signature of message data + method specific data by message authoring node.
    22  }
    23  
    24  message MessageUtil {
    25      MessageComm common = 1;
    26      oneof       value {
    27          P2PPeerInfo     peerInfo   = 2;
    28          P2PVersion      version    = 3;
    29          P2PVerAck       versionAck = 4;
    30          P2PExternalInfo external   = 5;
    31          P2PGetBlocks    getblocks  = 6;
    32          InvDatas        invdatas   = 7;
    33      }
    34  }
    35  
    36  /**
    37   * 请求获取远程节点的节点信息
    38   */
    39  message MessagePeerInfoReq {
    40      /// p2p版本
    41      MessageComm messageData = 1;
    42  }
    43  
    44  /**
    45   * 节点信息
    46   */
    47  
    48  message MessagePeerInfoResp {
    49      MessageComm messageData = 1;
    50      P2PPeerInfo message     = 2;
    51  }
    52  
    53  /**
    54   * p2p节点间发送版本数据结构
    55   */
    56  
    57  message MessageP2PVersionReq {
    58      MessageComm messageData = 1;
    59      P2PVersion  message     = 2;
    60  }
    61  
    62  /**
    63   * P2P 版本返回
    64   */
    65  
    66  message MessageP2PVersionResp {
    67      MessageComm messageData = 1;
    68      P2PVersion  message     = 2;
    69  }
    70  
    71  /**
    72   * P2P 心跳包
    73   */
    74  
    75  message MessagePingReq {
    76      MessageComm messageData = 1;
    77      P2PPing     message     = 2;
    78  }
    79  /**
    80   * 心跳返回包
    81   */
    82  
    83  message MessagePingResp {
    84      MessageComm messageData = 1;
    85      P2PPong     message     = 2;
    86  }
    87  /**
    88   * 获取对方节点所连接的其他节点地址的请求包
    89   */
    90  
    91  message MessageAddrReq {
    92      MessageComm messageData = 1;
    93      P2PGetAddr  message     = 2;
    94  }
    95  
    96  /**
    97   * 返回请求地址列表的社保
    98   */
    99  
   100  message MessageAddrResp {
   101      MessageComm messageData = 1;
   102      P2PAddr     message     = 2;
   103  }
   104  /**
   105   * 返回包括地址以及响应地址高度的列表信息
   106   **/
   107  
   108  message MessageAddrList {
   109      MessageComm messageData = 1;
   110      P2PAddrList message     = 2;
   111  }
   112  /**
   113   * 节点外网信息
   114   */
   115  
   116  message MessageExternalNetReq {
   117      MessageComm messageData = 1;
   118  }
   119  
   120  message MessageExternalNetResp {
   121      MessageComm     messageData = 1;
   122      P2PExternalInfo message     = 2;
   123  }
   124  /**
   125   * 获取区间区块
   126   */
   127  
   128  message MessageGetBlocksReq {
   129      MessageComm  messageData = 1;
   130      P2PGetBlocks message     = 2;
   131  }
   132  
   133  message MessageGetBlocksResp {
   134      MessageComm messageData = 1;
   135      InvDatas    message     = 2;
   136  }
   137  /**
   138   * 获取mempool
   139   */
   140  
   141  message MessageGetMempoolReq {
   142      MessageComm   messageData = 1;
   143      P2PGetMempool message     = 2;
   144  }
   145  
   146  /**
   147   * p2p 协议和软件版本
   148   */
   149  
   150  message MessageVersion {
   151      MessageComm messageData = 1;
   152      Versions    message     = 2;
   153  }
   154  
   155  /**
   156   * p2p 获取区块区间头部信息协议
   157   */
   158  
   159  message MessageHeaderReq {
   160      MessageComm   messageData = 1;
   161      P2PGetHeaders message     = 2;
   162  }
   163  /**
   164   * p2p 区块头传输协议
   165   */
   166  
   167  message MessageHeaderResp {
   168      MessageComm messageData = 1;
   169      P2PHeaders  message     = 2;
   170  }
   171  
   172  /**
   173   * inv 请求协议
   174   */
   175  
   176  message MessageInvDataReq {
   177      MessageComm messageData = 1;
   178      InvData     message     = 2;
   179  }
   180  
   181  /**
   182   * peer 列表
   183   */
   184  
   185  message MessagePeerList {
   186      MessageComm messageData = 1;
   187      PeerList    message     = 2;
   188  }
   189  
   190  /**
   191   *当前节点的网络信息
   192   */
   193  
   194  message MessageNetInfo {
   195      MessageComm messageData = 1;
   196      NodeNetInfo message     = 2;
   197  }
   198  
   199  /**
   200   * p2p节点扫描返回的结构数据
   201   */
   202  
   203  message MessagePeersReply {
   204      MessageComm common     = 1;
   205      PeersReply  peersReply = 2;
   206  }
   207  
   208  /**
   209   * p2p 广播
   210   */
   211  
   212  message MessageBroadCast {
   213      MessageComm   common  = 1;
   214      BroadCastData message = 2;
   215  }
   216  
   217  /**
   218   * p2p 分布式存储
   219   */
   220  
   221  message P2PMessageHeaders {
   222      // shared between all requests
   223      string version   = 1; // client version
   224      int64  timestamp = 2; // unix time
   225      int64  id        = 3; // allows requesters to use request data when processing a response
   226      bytes  sign      = 5; // signature of message data + method specific data by message authoring node.
   227  }
   228  
   229  message P2PRequest {
   230      P2PMessageHeaders headers = 1;
   231      oneof             request {
   232          ReqChunkRecords reqChunkRecords = 2;
   233          ChunkInfoMsg    chunkInfoMsg    = 3;
   234          ChunkInfoList   chunkInfoList   = 4;
   235          ReqBlocks       reqBlocks       = 5;
   236          //新的协议可以继续添加request类型
   237          ReqPeers reqPeers = 6;
   238      }
   239  }
   240  
   241  message ReqPeers {
   242      bytes referKey = 1;
   243      int32 count    = 2;
   244  }
   245  
   246  message HashList {
   247      repeated bytes hashes = 1;
   248  }
   249  
   250  message ChunkInfoList {
   251      repeated ChunkInfoMsg items = 1;
   252  }
   253  
   254  message P2PResponse {
   255      P2PMessageHeaders headers     = 1;
   256      string            error       = 2;
   257      repeated PeerInfo closerPeers = 3;
   258      oneof             response {
   259          BlockBody    blockBody    = 5;
   260          Headers      blockHeaders = 6;
   261          ChunkRecords chunkRecords = 7;
   262          //新的协议可以继续添加response类型
   263          NodeInfo nodeInfo = 8;
   264          // Reply reply = 8;
   265      }
   266  }
   267  
   268  message NodeInfo {
   269      bool  answer = 1;
   270      int64 height = 2;
   271  }
   272  
   273  message PeerInfo {
   274      bytes    ID              = 1;
   275      repeated bytes MultiAddr = 2;
   276  }
   277  
   278  /**
   279   * p2p 订阅topic
   280   */
   281  
   282  message SubTopic {
   283      string topic  = 1;
   284      string module = 2;
   285  }
   286  
   287  message SubTopicReply {
   288      bool   status = 1;
   289      string msg    = 2;
   290  }
   291  
   292  /**
   293   * p2p 发布topic消息
   294   */
   295  
   296  message PublishTopicMsg {
   297      string topic = 1;
   298      bytes  msg   = 2;
   299  }
   300  
   301  message PublishTopicMsgReply {
   302      string topic  = 1;
   303      bool   status = 2;
   304      string msg    = 3;
   305  }
   306  /**
   307   * p2p 接收topic消息
   308   */
   309  message TopicData {
   310      string topic = 1;
   311      string from  = 2;
   312      bytes  data  = 3;
   313  }
   314  
   315  /**
   316   * p2p 获取topic列表
   317   */
   318  
   319  message FetchTopicList {
   320      string module = 1;
   321  }
   322  
   323  message TopicList {
   324      repeated string topics = 1;
   325  }
   326  
   327  /**
   328   * p2p 删除topic
   329   */
   330  
   331  message RemoveTopic {
   332      string topic  = 1;
   333      string module = 2;
   334  }
   335  
   336  message RemoveTopicReply {
   337      string topic  = 1;
   338      bool   status = 2;
   339      string msg    = 3;
   340  }
   341  
   342  /**
   343   *dht protos 网络带宽信息
   344   */
   345  message NetProtocolInfos {
   346      repeated ProtocolInfo protoinfo = 1;
   347  }
   348  
   349  message ProtocolInfo {
   350      string protocol  = 1;
   351      string ratein    = 2;
   352      string rateout   = 3;
   353      string ratetotal = 4;
   354  }