Skip to content

Commit

Permalink
[FAB-7500] Remove not used code from the committer
Browse files Browse the repository at this point in the history
This commit removes old Commit API from committer_impl.go, since it's
no longer in use.

Change-Id: I08b886e283e903f4daef2abb0bed0540d755b1df
Signed-off-by: Artem Barger <bartem@il.ibm.com>
  • Loading branch information
C0rWin committed Dec 18, 2017
1 parent 525d214 commit f0b3731
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
27 changes: 2 additions & 25 deletions core/committer/committer_impl.go
Expand Up @@ -63,26 +63,6 @@ func NewLedgerCommitterReactive(ledger ledger.PeerLedger, eventer ConfigBlockEve
return &LedgerCommitter{PeerLedger: ledger, eventer: eventer}
}

// Commit commits block to into the ledger
// Note, it is important that this always be called serially
func (lc *LedgerCommitter) Commit(block *common.Block) error {
// Do validation and whatever needed before
// committing new block
if err := lc.preCommit(block); err != nil {
return err
}

// Committing new block
if err := lc.PeerLedger.CommitWithPvtData(&ledger.BlockAndPvtData{Block: block}); err != nil {
return err
}

// post commit actions, such as event publishing
lc.postCommit(block)

return nil
}

// preCommit takes care to validate the block and update based on its
// content
func (lc *LedgerCommitter) preCommit(block *common.Block) error {
Expand All @@ -104,8 +84,6 @@ func (lc *LedgerCommitter) CommitWithPvtData(blockAndPvtData *ledger.BlockAndPvt
return err
}

// TODO: Need to validate the hashes of private data with those in the block

// Committing new block
if err := lc.PeerLedger.CommitWithPvtData(blockAndPvtData); err != nil {
return err
Expand All @@ -119,7 +97,6 @@ func (lc *LedgerCommitter) CommitWithPvtData(blockAndPvtData *ledger.BlockAndPvt

// GetPvtDataAndBlockByNum retrieves private data and block for given sequence number
func (lc *LedgerCommitter) GetPvtDataAndBlockByNum(seqNum uint64) (*ledger.BlockAndPvtData, error) {
// TODO: Need to create filter based on chaincode collections policies
return lc.PeerLedger.GetPvtDataAndBlockByNum(seqNum, nil)
}

Expand All @@ -144,7 +121,7 @@ func (lc *LedgerCommitter) LedgerHeight() (uint64, error) {
var info *common.BlockchainInfo
var err error
if info, err = lc.GetBlockchainInfo(); err != nil {
logger.Errorf("Cannot get blockchain info, %s\n", info)
logger.Errorf("Cannot get blockchain info, %s", info)
return uint64(0), err
}

Expand All @@ -157,7 +134,7 @@ func (lc *LedgerCommitter) GetBlocks(blockSeqs []uint64) []*common.Block {

for _, seqNum := range blockSeqs {
if blck, err := lc.GetBlockByNumber(seqNum); err != nil {
logger.Errorf("Not able to acquire block num %d, from the ledger skipping...\n", seqNum)
logger.Errorf("Not able to acquire block num %d, from the ledger skipping...", seqNum)
continue
} else {
logger.Debug("Appending next block with seqNum = ", seqNum, " to the resulting set")
Expand Down
9 changes: 7 additions & 2 deletions core/committer/committer_test.go
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/hyperledger/fabric/common/tools/configtxgen/encoder"
"github.com/hyperledger/fabric/common/tools/configtxgen/localconfig"
"github.com/hyperledger/fabric/common/util"
ledger2 "github.com/hyperledger/fabric/core/ledger"
"github.com/hyperledger/fabric/core/ledger/ledgermgmt"
"github.com/hyperledger/fabric/protos/common"
"github.com/spf13/viper"
Expand Down Expand Up @@ -61,7 +62,9 @@ func TestKVLedgerBlockStorage(t *testing.T) {
simResBytes, _ := simRes.GetPubSimulationBytes()
block1 := testutil.ConstructBlock(t, 1, gbHash, [][]byte{simResBytes}, true)

err = committer.Commit(block1)
err = committer.CommitWithPvtData(&ledger2.BlockAndPvtData{
Block: block1,
})
assert.NoError(t, err)

height, err = committer.LedgerHeight()
Expand Down Expand Up @@ -103,6 +106,8 @@ func TestNewLedgerCommitterReactive(t *testing.T) {
profile := localconfig.Load(localconfig.SampleSingleMSPSoloProfile)
block := encoder.New(profile).GenesisBlockForChannel(chainID)

committer.Commit(block)
committer.CommitWithPvtData(&ledger2.BlockAndPvtData{
Block: block,
})
assert.Equal(t, int32(1), atomic.LoadInt32(&configArrived))
}
1 change: 1 addition & 0 deletions test/tools/LTE/experiments/init_test.go
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/hyperledger/fabric/core/ledger/testutil"

"fmt"

"github.com/spf13/viper"
)

Expand Down

0 comments on commit f0b3731

Please sign in to comment.