@@ -260,7 +260,7 @@ func (c *coordinator) StoreBlock(block *common.Block, privateDataSets util.PvtDa
260
260
}
261
261
262
262
// populate missing RWSets for ineligible collections to be passed to the ledger
263
- for _ , missingRWS := range privateInfo .missingRWSButIneligible {
263
+ for missingRWS := range privateInfo .missingRWSButIneligible {
264
264
blockAndPvtData .MissingPvtData .Add (missingRWS .seqInBlock , missingRWS .namespace , missingRWS .collection , false )
265
265
}
266
266
@@ -294,7 +294,7 @@ func (c *coordinator) StoreBlock(block *common.Block, privateDataSets util.PvtDa
294
294
return nil
295
295
}
296
296
297
- func (c * coordinator ) fetchFromPeers (blockSeq uint64 , ownedRWsets map [rwSetKey ][]byte , privateInfo * privateDataInfo ) {
297
+ func (c * coordinator ) fetchFromPeers (blockSeq uint64 , ownedRWsets map [rwSetKey ][]byte , privateInfo * pvtdataInfo ) {
298
298
dig2src := make (map [privdatacommon.DigKey ][]* peer.Endorsement )
299
299
privateInfo .missingKeys .foreach (func (k rwSetKey ) {
300
300
logger .Debug ("Fetching" , k , "from peers" )
@@ -661,16 +661,16 @@ func endorsersFromOrgs(ns string, col string, endorsers []*peer.Endorsement, org
661
661
return res
662
662
}
663
663
664
- type privateDataInfo struct {
664
+ type pvtdataInfo struct {
665
665
sources map [rwSetKey ][]* peer.Endorsement
666
666
missingKeysByTxIDs rwSetKeysByTxIDs
667
667
missingKeys rwsetKeys
668
668
txns txns
669
- missingRWSButIneligible [] rwSetKey
669
+ missingRWSButIneligible rwsetKeys
670
670
}
671
671
672
672
// listMissingPrivateData identifies missing private write sets and attempts to retrieve them from local transient store
673
- func (c * coordinator ) listMissingPrivateData (block * common.Block , ownedRWsets map [rwSetKey ][]byte ) (* privateDataInfo , error ) {
673
+ func (c * coordinator ) listMissingPrivateData (block * common.Block , ownedRWsets map [rwSetKey ][]byte ) (* pvtdataInfo , error ) {
674
674
if block .Metadata == nil || len (block .Metadata .Metadata ) <= int (common .BlockMetadataIndex_TRANSACTIONS_FILTER ) {
675
675
return nil , errors .New ("Block.Metadata is nil or Block.Metadata lacks a Tx filter bitmap" )
676
676
}
@@ -680,27 +680,29 @@ func (c *coordinator) listMissingPrivateData(block *common.Block, ownedRWsets ma
680
680
}
681
681
682
682
sources := make (map [rwSetKey ][]* peer.Endorsement )
683
- privateRWsetsInBlock := make (map [rwSetKey ]struct {})
683
+ requestedEligiblePrivateRWSets := make (map [rwSetKey ]struct {})
684
684
missing := make (rwSetKeysByTxIDs )
685
+ missingButIneligible := make (rwSetKeysByTxIDs )
685
686
data := blockData (block .Data .Data )
686
687
bi := & transactionInspector {
687
- sources : sources ,
688
- missingKeys : missing ,
689
- ownedRWsets : ownedRWsets ,
690
- privateRWsetsInBlock : privateRWsetsInBlock ,
691
- coordinator : c ,
688
+ sources : sources ,
689
+ missingKeys : missing ,
690
+ ownedRWsets : ownedRWsets ,
691
+ requestedEligiblePrivateRWSets : requestedEligiblePrivateRWSets ,
692
+ coordinator : c ,
693
+ missingRWSButIneligible : missingButIneligible ,
692
694
}
693
695
storePvtDataOfInvalidTx := c .Support .CapabilityProvider .Capabilities ().StorePvtDataOfInvalidTx ()
694
696
txList , err := data .forEachTxn (storePvtDataOfInvalidTx , txsFilter , bi .inspectTransaction )
695
697
if err != nil {
696
698
return nil , err
697
699
}
698
700
699
- privateInfo := & privateDataInfo {
701
+ privateInfo := & pvtdataInfo {
700
702
sources : sources ,
701
703
missingKeysByTxIDs : missing ,
704
+ missingRWSButIneligible : bi .missingRWSButIneligible .flatten (),
702
705
txns : txList ,
703
- missingRWSButIneligible : bi .missingRWSButIneligible ,
704
706
}
705
707
706
708
logger .Debug ("Retrieving private write sets for" , len (privateInfo .missingKeysByTxIDs ), "transactions from transient store" )
@@ -709,9 +711,9 @@ func (c *coordinator) listMissingPrivateData(block *common.Block, ownedRWsets ma
709
711
c .fetchMissingFromTransientStore (privateInfo .missingKeysByTxIDs , ownedRWsets )
710
712
711
713
// In the end, iterate over the ownedRWsets, and if the key doesn't exist in
712
- // the privateRWsetsInBlock - delete it from the ownedRWsets
714
+ // the requestedEligiblePrivateRWSets - delete it from the ownedRWsets
713
715
for k := range ownedRWsets {
714
- if _ , exists := privateRWsetsInBlock [k ]; ! exists {
716
+ if _ , exists := requestedEligiblePrivateRWSets [k ]; ! exists {
715
717
logger .Warning ("Removed" , k .namespace , k .collection , "hash" , k .hash , "from the data passed to the ledger" )
716
718
delete (ownedRWsets , k )
717
719
}
@@ -729,11 +731,11 @@ func (c *coordinator) listMissingPrivateData(block *common.Block, ownedRWsets ma
729
731
730
732
type transactionInspector struct {
731
733
* coordinator
732
- privateRWsetsInBlock map [ rwSetKey ] struct {}
733
- missingKeys rwSetKeysByTxIDs
734
- sources map [rwSetKey ][]* peer.Endorsement
735
- ownedRWsets map [rwSetKey ][]byte
736
- missingRWSButIneligible [] rwSetKey
734
+ requestedEligiblePrivateRWSets rwsetKeys
735
+ missingKeys rwSetKeysByTxIDs
736
+ sources map [rwSetKey ][]* peer.Endorsement
737
+ ownedRWsets map [rwSetKey ][]byte
738
+ missingRWSButIneligible rwSetKeysByTxIDs
737
739
}
738
740
739
741
func (bi * transactionInspector ) inspectTransaction (seqInBlock uint64 , chdr * common.ChannelHeader , txRWSet * rwsetutil.TxRwSet , endorsers []* peer.Endorsement ) error {
@@ -766,20 +768,20 @@ func (bi *transactionInspector) inspectTransaction(seqInBlock uint64, chdr *comm
766
768
collection : hashedCollection .CollectionName ,
767
769
}
768
770
771
+ txAndSeq := txAndSeqInBlock {
772
+ txID : chdr .TxId ,
773
+ seqInBlock : seqInBlock ,
774
+ }
769
775
if ! bi .isEligible (policy , ns .NameSpace , hashedCollection .CollectionName ) {
770
776
logger .Debugf ("Peer is not eligible for collection, channel [%s], chaincode [%s], " +
771
777
"collection name [%s], txID [%s] the policy is [%#v]. Skipping." ,
772
778
chdr .ChannelId , ns .NameSpace , hashedCollection .CollectionName , chdr .TxId , policy )
773
- bi .missingRWSButIneligible = append (bi .missingRWSButIneligible , key )
779
+ bi .missingRWSButIneligible [ txAndSeq ] = append (bi .missingRWSButIneligible [ txAndSeq ] , key )
774
780
continue
775
781
}
776
782
777
- bi .privateRWsetsInBlock [key ] = struct {}{}
783
+ bi .requestedEligiblePrivateRWSets [key ] = struct {}{}
778
784
if _ , exists := bi .ownedRWsets [key ]; ! exists {
779
- txAndSeq := txAndSeqInBlock {
780
- txID : chdr .TxId ,
781
- seqInBlock : seqInBlock ,
782
- }
783
785
bi .missingKeys [txAndSeq ] = append (bi .missingKeys [txAndSeq ], key )
784
786
bi .sources [key ] = endorsersFromOrgs (ns .NameSpace , hashedCollection .CollectionName , endorsers , policy .MemberOrgs ())
785
787
}
0 commit comments