Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LEDGER] merge ledgerstorage with kvledger pkg #942

Merged
merged 2 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/chaincode/lifecycle/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ func (c *Cache) InitializeLocalChaincodes() error {
return nil
}

// Name returns the name of the listener
func (c *Cache) Name() string {
return "lifecycle cache listener"
}

// Initialize will populate the set of currently committed chaincode definitions
// for a channel into the cache. Note, it this looks like a bit of a DRY violation
// with respect to 'Update', but, the error handling is quite different and attempting
Expand Down
5 changes: 5 additions & 0 deletions core/ledger/cceventmgmt/lsccstate_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ type KVLedgerLSCCStateListener struct {
DeployedChaincodeInfoProvider ledger.DeployedChaincodeInfoProvider
}

// Name returns the name of the listener
func (listener *KVLedgerLSCCStateListener) Name() string {
return "lscc state listener"
}

func (listener *KVLedgerLSCCStateListener) Initialize(ledgerID string, qe ledger.SimpleQueryExecutor) error {
// Noop
return nil
Expand Down
5 changes: 5 additions & 0 deletions core/ledger/confighistory/mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func NewMgr(dbPath string, ccInfoProvider ledger.DeployedChaincodeInfoProvider)
return &mgr{ccInfoProvider, p}, nil
}

// Name returns the name of the listener
func (m *mgr) Name() string {
return "collection configuration history listener"
}

func (m *mgr) Initialize(ledgerID string, qe ledger.SimpleQueryExecutor) error {
// Noop
return nil
Expand Down
5 changes: 5 additions & 0 deletions core/ledger/kvledger/coll_elg_notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ type collElgNotifier struct {
listeners map[string]collElgListener
}

// Name returns the name of the listener
func (n *collElgNotifier) Name() string {
return "collection eligibility listener"
}

func (n *collElgNotifier) Initialize(ledgerID string, qe ledger.SimpleQueryExecutor) error {
// Noop
return nil
Expand Down
8 changes: 4 additions & 4 deletions core/ledger/kvledger/hashcheck_pvtdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import (
"bytes"

"github.com/hyperledger/fabric-protos-go/ledger/rwset"
"github.com/hyperledger/fabric/common/ledger/blkstorage"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwsetutil"
"github.com/hyperledger/fabric/core/ledger/ledgerstorage"
"github.com/hyperledger/fabric/protoutil"
)

// constructValidAndInvalidPvtData computes the valid pvt data and hash mismatch list
// from a received pvt data list of old blocks.
func constructValidAndInvalidPvtData(reconciledPvtdata []*ledger.ReconciledPvtdata, blockStore *ledgerstorage.Store) (
func constructValidAndInvalidPvtData(reconciledPvtdata []*ledger.ReconciledPvtdata, blockStore blkstorage.BlockStore) (
map[uint64][]*ledger.TxPvtData, []*ledger.PvtdataHashMismatch, error,
) {
// for each block, for each transaction, retrieve the txEnvelope to
Expand All @@ -42,7 +42,7 @@ func constructValidAndInvalidPvtData(reconciledPvtdata []*ledger.ReconciledPvtda
return validPvtData, invalidPvtData, nil
}

func findValidAndInvalidPvtdata(reconciledPvtdata *ledger.ReconciledPvtdata, blockStore *ledgerstorage.Store) (
func findValidAndInvalidPvtdata(reconciledPvtdata *ledger.ReconciledPvtdata, blockStore blkstorage.BlockStore) (
[]*ledger.TxPvtData, []*ledger.PvtdataHashMismatch, error,
) {
var validPvtData []*ledger.TxPvtData
Expand Down Expand Up @@ -70,7 +70,7 @@ func findValidAndInvalidPvtdata(reconciledPvtdata *ledger.ReconciledPvtdata, blo
return validPvtData, invalidPvtData, nil
}

func retrieveRwsetForTx(blkNum uint64, txNum uint64, blockStore *ledgerstorage.Store) (*rwsetutil.TxRwSet, error) {
func retrieveRwsetForTx(blkNum uint64, txNum uint64, blockStore blkstorage.BlockStore) (*rwsetutil.TxRwSet, error) {
// retrieve the txEnvelope from the block store so that the hash of
// the pvtData can be retrieved for comparison
txEnvelope, err := blockStore.RetrieveTxByBlockNumTranNum(blkNum, txNum)
Expand Down
5 changes: 3 additions & 2 deletions core/ledger/kvledger/hashcheck_pvtdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import (
"github.com/hyperledger/fabric/common/ledger/testutil"
"github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwsetutil"
"github.com/hyperledger/fabric/core/ledger/mock"
"github.com/hyperledger/fabric/protoutil"
"github.com/stretchr/testify/assert"
)

func TestConstructValidInvalidBlocksPvtData(t *testing.T) {
conf, cleanup := testConfig(t)
defer cleanup()
provider := testutilNewProvider(conf, t)
provider := testutilNewProvider(conf, t, &mock.DeployedChaincodeInfoProvider{})
defer provider.Close()

_, gb := testutil.NewBlockGenerator(t, "testLedger", false)
Expand Down Expand Up @@ -82,7 +83,7 @@ func TestConstructValidInvalidBlocksPvtData(t *testing.T) {
Block: blk1,
PvtData: pvtDataBlk1,
MissingPvtData: missingData}
assert.NoError(t, lg.(*kvLedger).blockStore.CommitWithPvtData(blockAndPvtData1))
assert.NoError(t, lg.(*kvLedger).commitToPvtAndBlockStore(blockAndPvtData1))

// construct pvtData from missing data in tx3, tx6, and tx7
pvtdata := []*ledger.ReconciledPvtdata{
Expand Down
Loading