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

     1  syntax = "proto3";
     2  import "transaction.proto";
     3  import "common.proto";
     4  
     5  package types;
     6  option go_package = "github.com/turingchain2020/turingchain/types";
     7  
     8  //区块头信息
     9  // 	 version : 版本信息
    10  //	 parentHash :父哈希
    11  // 	 txHash : 交易根哈希
    12  //	 stateHash :状态哈希
    13  // 	 height : 区块高度
    14  //	 blockTime :区块产生时的时标
    15  // 	 txCount : 区块上所有交易个数
    16  //	 difficulty :区块难度系数,
    17  //	 signature :交易签名
    18  message Header {
    19      int64     version    = 1;
    20      bytes     parentHash = 2;
    21      bytes     txHash     = 3;
    22      bytes     stateHash  = 4;
    23      int64     height     = 5;
    24      int64     blockTime  = 6;
    25      int64     txCount    = 9;
    26      bytes     hash       = 10;
    27      uint32    difficulty = 11;
    28      Signature signature  = 8;
    29  }
    30  //  参考Header解释
    31  // mainHash 平行链上使用的字段,代表这个区块的主链hash
    32  message Block {
    33      int64     version        = 1;
    34      bytes     parentHash     = 2;
    35      bytes     txHash         = 3;
    36      bytes     stateHash      = 4;
    37      int64     height         = 5;
    38      int64     blockTime      = 6;
    39      uint32    difficulty     = 11;
    40      bytes     mainHash       = 12;
    41      int64     mainHeight     = 13;
    42      Signature signature      = 8;
    43      repeated Transaction txs = 7;
    44  }
    45  
    46  message Blocks {
    47      repeated Block items = 1;
    48  }
    49  
    50  message BlockSeq {
    51      int64         num    = 1;
    52      BlockSequence seq    = 2;
    53      BlockDetail   detail = 3;
    54  }
    55  
    56  message BlockSeqs {
    57      repeated BlockSeq seqs = 1;
    58  }
    59  
    60  //节点ID以及对应的Block
    61  message BlockPid {
    62      string pid   = 1;
    63      Block  block = 2;
    64  }
    65  // resp
    66  message BlockDetails {
    67      repeated BlockDetail items = 1;
    68  }
    69  
    70  // resp
    71  message Headers {
    72      repeated Header items = 1;
    73  }
    74  
    75  message HeadersPid {
    76      string  pid     = 1;
    77      Headers headers = 2;
    78  }
    79  
    80  //区块视图
    81  // 	 head : 区块头信息
    82  //	 txCount :区块上交易个数
    83  // 	 txHashes : 区块上交易的哈希列表
    84  message BlockOverview {
    85      Header   head           = 1;
    86      int64    txCount        = 2;
    87      repeated bytes txHashes = 3;
    88  }
    89  
    90  //区块详细信息
    91  // 	 block : 区块信息
    92  //	 receipts :区块上所有交易的收据信息列表
    93  message BlockDetail {
    94      Block    block                   = 1;
    95      repeated ReceiptData receipts    = 2;
    96      repeated KeyValue KV             = 3;
    97      bytes             prevStatusHash = 4;
    98  }
    99  
   100  message Receipts {
   101      repeated Receipt receipts = 1;
   102  }
   103  
   104  message ReceiptCheckTxList {
   105      repeated string errs = 1;
   106  }
   107  
   108  //区块链状态
   109  // 	 currentHeight : 区块最新高度
   110  //	 mempoolSize :内存池大小
   111  // 	 msgQueueSize : 消息队列大小
   112  message ChainStatus {
   113      int64 currentHeight = 1;
   114      int64 mempoolSize   = 2;
   115      int64 msgQueueSize  = 3;
   116  }
   117  
   118  //获取区块信息
   119  // 	 start : 获取区块的开始高度
   120  //	 end :获取区块的结束高度
   121  // 	 Isdetail : 是否需要获取区块的详细信息
   122  // 	 pid : peer列表
   123  message ReqBlocks {
   124      int64    start      = 1;
   125      int64    end        = 2;
   126      bool     isDetail   = 3;
   127      repeated string pid = 4;
   128  }
   129  
   130  message MempoolSize {
   131      int64 size = 1;
   132  }
   133  
   134  message ReplyBlockHeight {
   135      int64 height = 1;
   136  }
   137  
   138  //区块体信息
   139  // 	 txs : 区块上所有交易列表
   140  //	 receipts :区块上所有交易的收据信息列表
   141  // 	 mainHash : 主链区块hash,平行链使用
   142  //	 mainHeight :主链区块高度,平行链使用
   143  // 	 hash : 本链区块hash
   144  //	 height :本链区块高度
   145  message BlockBody {
   146      repeated Transaction txs        = 1;
   147      repeated ReceiptData receipts   = 2;
   148      bytes                mainHash   = 3;
   149      int64                mainHeight = 4;
   150      bytes                hash       = 5;
   151      int64                height     = 6;
   152  }
   153  
   154  //区块回执
   155  //	 receipts :区块上所有交易的收据信息列表
   156  // 	 hash : 本链区块hash
   157  //	 height :本链区块高度
   158  message BlockReceipt {
   159      repeated ReceiptData receipts = 1;
   160      bytes                hash     = 2;
   161      int64                height   = 3;
   162  }
   163  
   164  //  区块追赶主链状态,用于判断本节点区块是否已经同步好
   165  message IsCaughtUp {
   166      bool Iscaughtup = 1;
   167  }
   168  
   169  //  ntp时钟状态
   170  message IsNtpClockSync {
   171      bool isntpclocksync = 1;
   172  }
   173  
   174  message ChainExecutor {
   175      string driver    = 1;
   176      string funcName  = 2;
   177      bytes  stateHash = 3;
   178      bytes  param     = 4;
   179      //扩展字段,用于额外的用途
   180      bytes extra = 5;
   181  }
   182  
   183  //  通过block hash记录block的操作类型及add/del:1/2
   184  message BlockSequence {
   185      bytes Hash = 1;
   186      int64 Type = 2;
   187  }
   188  
   189  // resp
   190  message BlockSequences {
   191      repeated BlockSequence items = 1;
   192  }
   193  
   194  //平行链区块详细信息
   195  // 	 blockdetail : 区块详细信息
   196  //	 sequence :区块序列号
   197  //   isSync:写数据库时是否需要刷盘
   198  message ParaChainBlockDetail {
   199      BlockDetail blockdetail = 1;
   200      int64       sequence    = 2;
   201      bool        isSync      = 3;
   202  }
   203  
   204  // 定义para交易结构
   205  message ParaTxDetails {
   206      repeated ParaTxDetail items = 1;
   207  }
   208  
   209  // type:平行链交易所在区块add/del操作,方便平行链回滚
   210  // header:平行链交易所在区块头信息
   211  // txDetails:本区块中指定title平行链的所有交易
   212  // proofs:对应平行链子roothash的存在证明路径
   213  // childHash:此平行链交易的子roothash
   214  // index:对应平行链子roothash在整个区块中的索引
   215  message ParaTxDetail {
   216      int64    type               = 1;
   217      Header   header             = 2;
   218      repeated TxDetail txDetails = 3;
   219      bytes             childHash = 4;
   220      uint32            index     = 5;
   221      repeated bytes proofs       = 6;
   222  }
   223  
   224  //交易的详情:
   225  // index:本交易在block中索引值,用于proof的证明
   226  // tx:本交易内容
   227  // receipt:本交易在主链的执行回执
   228  // proofs:本交易hash在block中merkel中的路径
   229  message TxDetail {
   230      uint32      index     = 1;
   231      Transaction tx        = 2;
   232      ReceiptData receipt   = 3;
   233      repeated bytes proofs = 4;
   234  }
   235  
   236  //通过seq区间和title请求平行链的交易
   237  message ReqParaTxByTitle {
   238      int64  start = 1;
   239      int64  end   = 2;
   240      string title = 3;
   241      bool   isSeq = 4;
   242  }
   243  
   244  //导出block文件头信息
   245  message FileHeader {
   246      int64  startHeight = 1;
   247      string driver      = 2;
   248      string title       = 3;
   249      bool   testNet     = 4;
   250  }
   251  //存储block高度和hash
   252  message EndBlock {
   253      int64 height = 1;
   254      bytes hash   = 2;
   255  }
   256  
   257  //通过seq获取区块的header信息
   258  message HeaderSeq {
   259      int64         num    = 1;
   260      BlockSequence seq    = 2;
   261      Header        header = 3;
   262  }
   263  
   264  //批量推送区块的header信息
   265  message HeaderSeqs {
   266      repeated HeaderSeq seqs = 1;
   267  }
   268  
   269  //记录本平行链所在区块的信息以及子根hash值
   270  // childHash:平行链子roothash值
   271  // startIndex:此平行链的第一笔交易的index索引值
   272  // childHashIndex:此平行链子roothash在本区块中的索引值
   273  // txCount:此平行链交易的个数
   274  message HeightPara {
   275      int64  height         = 1;
   276      string title          = 2;
   277      bytes  hash           = 3;
   278      bytes  childHash      = 4;
   279      int32  startIndex     = 5;
   280      uint32 childHashIndex = 6;
   281      int32  txCount        = 7;
   282  }
   283  
   284  message HeightParas {
   285      repeated HeightPara items = 1;
   286  }
   287  
   288  //记录平行链第一笔交易的index,以及平行链的roothash
   289  // title:子链名字,主链的默认是main
   290  // startIndex:子链第一笔交易的索引
   291  // childHash:子链的根hash
   292  // txCount:子链交易的数量
   293  message ChildChain {
   294      string title      = 1;
   295      int32  startIndex = 2;
   296      bytes  childHash  = 3;
   297      int32  txCount    = 4;
   298  }
   299  
   300  //通过指定title以及height翻页获取拥有此title交易的区块高度列表
   301  message ReqHeightByTitle {
   302      int64  height    = 1;
   303      string title     = 2;
   304      int32  count     = 3;
   305      int32  direction = 4;
   306  }
   307  
   308  message ReplyHeightByTitle {
   309      string   title           = 1;
   310      repeated BlockInfo items = 2;
   311  }
   312  
   313  // title平行链交易所在主链区块的信息
   314  message BlockInfo {
   315      int64 height = 1;
   316      bytes hash   = 2;
   317  }
   318  
   319  //通过高度列表和title获取平行链交易
   320  message ReqParaTxByHeight {
   321      repeated int64 items = 1;
   322      string         title = 2;
   323  }
   324  
   325  //用于比较最优区块的消息结构
   326  message CmpBlock {
   327      Block block   = 1;
   328      bytes cmpHash = 2;
   329  }
   330  
   331  // BlockBodys
   332  message BlockBodys {
   333      repeated BlockBody items = 1;
   334  }
   335  
   336  // ChunkRecords
   337  message ChunkRecords {
   338      repeated ChunkInfo infos = 1;
   339  }
   340  
   341  // ChunkInfoMsg 用于消息传递
   342  message ChunkInfoMsg {
   343      bytes chunkHash = 1;
   344      int64 start     = 2;
   345      int64 end       = 3;
   346  }
   347  
   348  // ChunkInfo用于记录chunk的信息
   349  message ChunkInfo {
   350      int64 chunkNum  = 1;
   351      bytes chunkHash = 2;
   352      int64 start     = 3;
   353      int64 end       = 4;
   354  }
   355  
   356  //获取ChunkRecord信息
   357  // 	 start : 获取Chunk的开始高度
   358  //	 end :获取Chunk的结束高度
   359  // 	 Isdetail : 是否需要获取所有Chunk Record 信息,false时候获取到chunkNum--->chunkhash的KV对,true获取全部
   360  // 	 pid : peer列表
   361  message ReqChunkRecords {
   362      int64    start      = 1;
   363      int64    end        = 2;
   364      bool     isDetail   = 3;
   365      repeated string pid = 4;
   366  }
   367  
   368  message PushSubscribeReq {
   369      string name          = 1;
   370      string URL           = 2;
   371      string encode        = 3;
   372      int64  lastSequence  = 4;
   373      int64  lastHeight    = 5;
   374      string lastBlockHash = 6;
   375      // 0:代表区块;1:代表区块头信息;2:代表交易回执
   376      int32 type = 7;
   377      //允许订阅多个类型的交易回执
   378      map<string, bool> contract = 8;
   379  }
   380  
   381  message PushWithStatus {
   382      PushSubscribeReq push   = 1;
   383      int32            status = 2;
   384  }
   385  
   386  message PushSubscribes {
   387      repeated PushSubscribeReq pushes = 1;
   388  }
   389  
   390  message ReplySubscribePush {
   391      bool   isOk = 1;
   392      string msg  = 2;
   393  }