Skip to content

Commit 07548ec

Browse files
committed
[FAB-16026] Convert RetrievedPvtdata to interface
* This will be necessary for consumers utilizing other interfaces in ledger interface Change-Id: Icbbb0b008c178cc03695f7971e41b1db459aade3 Signed-off-by: Danny Cao <dcao@us.ibm.com>
1 parent b558893 commit 07548ec

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

core/ledger/ledger_interface.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,13 @@ type Hasher interface {
646646
Hash(msg []byte, opts bccsp.HashOpts) (hash []byte, err error)
647647
}
648648

649+
// RetrievedPvtdata is a dependency that is implemented by coordinator/gossip for ledger
650+
// to be able to purge the transactions from the block after retrieving private data
651+
type RetrievedPvtdata interface {
652+
GetBlockPvtdata() *BlockPvtdata
653+
Purge()
654+
}
655+
649656
// TxPvtdataInfo captures information about the requested private data to be retrieved
650657
// and is populated by ledger during commit
651658
type TxPvtdataInfo struct {

gossip/privdata/pvtdataprovider.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ type RetrievedPvtdata struct {
4444
transientBlockRetention uint64
4545
}
4646

47+
// GetBlockPvtdata returns the BlockPvtdata
48+
func (r *RetrievedPvtdata) GetBlockPvtdata() *ledger.BlockPvtdata {
49+
return r.blockPvtdata
50+
}
51+
4752
// Purge purges transactions in the block
4853
func (r *RetrievedPvtdata) Purge() {
4954
purgeStart := time.Now()

gossip/privdata/pvtdataprovider_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func testRetrievePrivateDataSuccess(t *testing.T,
484484
expectedBlockPvtdata := formatExpectedBlockPvtdata(expectedRwSets)
485485
// sometimes the collection private write sets are added out of order
486486
// so we need to sort it to check equality with expected
487-
blockPvtdata := sortBlockPvtdata(retrievedPvtdata.blockPvtdata)
487+
blockPvtdata := sortBlockPvtdata(retrievedPvtdata.GetBlockPvtdata())
488488
assert.Equal(t, expectedBlockPvtdata, blockPvtdata, scenario)
489489

490490
// Test pvtdata is purged from store on Done() call
@@ -567,12 +567,12 @@ func setupPrivateDataProvider(t *testing.T,
567567

568568
func testPurged(t *testing.T,
569569
scenario string,
570-
retrievedPvtdata *RetrievedPvtdata,
570+
retrievedPvtdata ledger.RetrievedPvtdata,
571571
store *transientstore.Store,
572572
txPvtdataInfo []*ledger.TxPvtdataInfo) {
573573

574574
retrievedPvtdata.Purge()
575-
for _, pvtdata := range retrievedPvtdata.blockPvtdata.PvtData {
575+
for _, pvtdata := range retrievedPvtdata.GetBlockPvtdata().PvtData {
576576
func() {
577577
txID := getTxIDBySeqInBlock(pvtdata.SeqInBlock, txPvtdataInfo)
578578
require.NotEqual(t, txID, "", fmt.Sprintf("Could not find txID for SeqInBlock %d", pvtdata.SeqInBlock), scenario)

0 commit comments

Comments
 (0)