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