github.com/kchristidis/fabric@v1.0.4-0.20171028114726-837acd08cde1/protos/ledger/rwset/kvrwset/kv_rwset.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  option go_package = "github.com/hyperledger/fabric/protos/ledger/rwset/kvrwset";
    20  option java_package = "org.hyperledger.fabric.protos.ledger.rwset.kvrwset";
    21  
    22  package kvrwset;
    23  
    24  // KVRWSet encapsulates the read-write set for a chaincode that operates upon a KV or Document data model
    25  message KVRWSet {
    26      repeated KVRead reads = 1;
    27      repeated RangeQueryInfo range_queries_info = 2;
    28      repeated KVWrite writes = 3;
    29  }
    30  
    31  // KVRead captures a read operation performed during transaction simulation
    32  // A 'nil' version indicates a non-existing key read by the transaction
    33  message KVRead {
    34      string key = 1;
    35      Version version = 2;
    36  }
    37  
    38  // KVWrite captures a write (update/delete) operation performed during transaction simulation
    39  message KVWrite {
    40      string key = 1;
    41      bool is_delete = 2;
    42      bytes value = 3;
    43  }
    44  
    45  // Version encapsulates the version of a Key
    46  // A version of a committed key is maintained as the height of the transaction that committed the key.
    47  // The height is represenetd as a tuple <blockNum, txNum> where the txNum is the height of the transaction
    48  // (starting with 1) within block
    49  message Version {
    50      uint64 block_num = 1;
    51      uint64 tx_num = 2;
    52  }
    53  
    54  // RangeQueryInfo encapsulates the details of a range query performed by a transaction during simulation.
    55  // This helps protect transactions from phantom reads by varifying during validation whether any new items
    56  // got committed within the given range between transaction simuation and validation
    57  // (in addition to regular checks for updates/deletes of the existing items).
    58  // readInfo field contains either the KVReads (for the items read by the range query) or a merkle-tree hash
    59  // if the KVReads exceeds a pre-configured numbers
    60  message RangeQueryInfo {
    61      string start_key = 1;
    62      string end_key = 2;
    63      bool itr_exhausted = 3;
    64      oneof reads_info {
    65          QueryReads raw_reads = 4;
    66          QueryReadsMerkleSummary reads_merkle_hashes = 5;
    67      }
    68  }
    69  
    70  // QueryReads encapsulates the KVReads for the items read by a transaction as a result of a query execution
    71  message QueryReads {
    72      repeated KVRead kv_reads = 1;
    73  }
    74  
    75  // QueryReadsMerkleSummary encapsulates the Merkle-tree hashes for the QueryReads
    76  // This allows to reduce the size of RWSet in the presence of query results
    77  // by storing certain hashes instead of actual results.
    78  // maxDegree field refers to the maximum number of children in the tree at any level
    79  // maxLevel field contains the lowest level which has lesser nodes than maxDegree (starting from leaf level)
    80  message QueryReadsMerkleSummary {
    81      uint32 max_degree = 1;
    82      uint32 max_level = 2;
    83      repeated bytes max_level_hashes = 3;
    84  }