github.com/kaituanwang/hyperledger@v2.0.1+incompatible/pkg/statedata/types.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 SPDX-License-Identifier: Apache-2.0 4 */ 5 6 package statedata 7 8 import ( 9 "fmt" 10 ) 11 12 // KeyValue encapsulates a key and corresponding value 13 type KeyValue struct { 14 Key string 15 Value []byte 16 } 17 18 // DataKey represents a key in a namespace 19 type DataKey struct { 20 Ns, Key string 21 } 22 23 func (d *DataKey) String() string { 24 return fmt.Sprintf("Ns = %s, Key = %s", d.Ns, d.Key) 25 } 26 27 // PvtdataKeyHash represents the hash of a key in a collection within a namespace 28 type PvtdataKeyHash struct { 29 Ns, Coll string 30 KeyHash string 31 } 32 33 func (p *PvtdataKeyHash) String() string { 34 return fmt.Sprintf("Ns = %s, Coll = %s, KeyHash = %x", p.Ns, p.Coll, p.KeyHash) 35 } 36 37 // ProposedWrites encapsulates the final writes that a transaction intends to commit 38 // This is intended to be used to evaluate the endorsement policies by the Processor for 39 // the endorser transactions 40 type ProposedWrites struct { 41 Data []*DataKey 42 PvtdataHash []*PvtdataKeyHash 43 } 44 45 // ReadHint encapsulates the details of the hint about what keys a `Processor` may read during processing of a transaction 46 type ReadHint struct { 47 Data map[DataKey]*ReadHintDetails 48 PvtdataHash map[PvtdataKeyHash]*ReadHintDetails 49 } 50 51 // ReadHintDetails captures the details about what data associated with a key a transaction may read (whether the value, or metadata, or both) 52 type ReadHintDetails struct { 53 Value, Metadata bool 54 } 55 56 // WriteHint is intended to be used to give a transaction processor a hint what keys a transaction may write in its pre-simulated section (if any). 57 // The intention is to help transaction processor compute its ReadHint 58 type WriteHint struct { 59 Data []*DataKey 60 PvtdataHash []*PvtdataKeyHash 61 }