Skip to content

Commit 0cfb77b

Browse files
committed
FAB-12288 reduce log level extracting pvt data col.
Reducing log level from warning to debug for filtering messages while extracting private data read-write set. This commit also removes dependencies on fmt and errors packages while treating errors. Change-Id: I50d773d2427f62854292cb18f1a2dc26956482d2 Signed-off-by: Artem Barger <bartem@il.ibm.com>
1 parent 4c7ffa3 commit 0cfb77b

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

gossip/privdata/dataretriever.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ SPDX-License-Identifier: Apache-2.0
77
package privdata
88

99
import (
10-
"errors"
11-
"fmt"
12-
1310
"github.com/hyperledger/fabric/core/ledger"
1411
"github.com/hyperledger/fabric/core/transientstore"
1512
"github.com/hyperledger/fabric/gossip/privdata/common"
1613
"github.com/hyperledger/fabric/gossip/util"
1714
gossip2 "github.com/hyperledger/fabric/protos/gossip"
1815
"github.com/hyperledger/fabric/protos/ledger/rwset"
16+
"github.com/pkg/errors"
1917
)
2018

2119
// StorageDataRetriever defines an API to retrieve private date from the storage
@@ -64,7 +62,7 @@ func (dr *dataRetriever) CollectionRWSet(digests []*gossip2.PvtDataDigest, block
6462
height, err := dr.store.LedgerHeight()
6563
if err != nil {
6664
// if there is an error getting info from the ledger, we need to try to read from transient store
67-
return nil, false, fmt.Errorf("wasn't able to read ledger height, due to %s", err)
65+
return nil, false, errors.Wrap(err, "wasn't able to read ledger height")
6866
}
6967
if height <= blockNum {
7068
logger.Debug("Current ledger height ", height, "is below requested block sequence number",
@@ -112,7 +110,7 @@ func (dr *dataRetriever) fromLedger(digests []*gossip2.PvtDataDigest, blockNum u
112110

113111
pvtData, err := dr.store.GetPvtDataByNum(blockNum, filter)
114112
if err != nil {
115-
return nil, errors.New(fmt.Sprint("wasn't able to obtain private data, block sequence number", blockNum, "due to", err))
113+
return nil, errors.Errorf("wasn't able to obtain private data, block sequence number %d, due to %s", blockNum, err)
116114
}
117115

118116
results := make(Dig2PvtRWSetWithConfig)
@@ -137,24 +135,24 @@ func (dr *dataRetriever) fromLedger(digests []*gossip2.PvtDataDigest, blockNum u
137135

138136
confHistoryRetriever, err := dr.store.GetConfigHistoryRetriever()
139137
if err != nil {
140-
return nil, errors.New(fmt.Sprint("cannot obtain configuration history retriever, for collection, ", dig.Collection,
141-
" txID ", dig.TxId, " block sequence number ", dig.BlockSeq, " due to", err))
138+
return nil, errors.Errorf("cannot obtain configuration history retriever, for collection <%s>"+
139+
" txID <%s> block sequence number <%d> due to <%s>", dig.Collection, dig.TxId, dig.BlockSeq, err)
142140
}
143141

144142
configInfo, err := confHistoryRetriever.MostRecentCollectionConfigBelow(dig.BlockSeq, dig.Namespace)
145143
if err != nil {
146-
return nil, errors.New(fmt.Sprint("cannot find recent collection config update below block sequence = ", dig.BlockSeq,
147-
" collection name = ", dig.Collection, " for chaincode ", dig.Namespace))
144+
return nil, errors.Errorf("cannot find recent collection config update below block sequence = %d,"+
145+
" collection name = <%s> for chaincode <%s>", dig.BlockSeq, dig.Collection, dig.Namespace)
148146
}
149147

150148
if configInfo == nil {
151-
return nil, errors.New(fmt.Sprint("no collection config update below block sequence = ", dig.BlockSeq,
152-
" collection name = ", dig.Collection, " for chaincode ", dig.Namespace, " is available "))
149+
return nil, errors.Errorf("no collection config update below block sequence = <%d>"+
150+
" collection name = <%s> for chaincode <%s> is available ", dig.BlockSeq, dig.Collection, dig.Namespace)
153151
}
154152
configs := extractCollectionConfig(configInfo.CollectionConfig, dig.Collection)
155153
if configs == nil {
156-
return nil, errors.New(fmt.Sprint("no collection config was found for collection ", dig.Collection,
157-
" namespace ", dig.Namespace, " txID ", dig.TxId))
154+
return nil, errors.Errorf("no collection config was found for collection <%s>"+
155+
" namespace <%s> txID <%s>", dig.Collection, dig.Namespace, dig.TxId)
158156
}
159157
pvtRWSetWithConfig.CollectionConfig = configs
160158
results[common.DigKey{
@@ -173,17 +171,17 @@ func (dr *dataRetriever) fromTransientStore(dig *gossip2.PvtDataDigest, filter m
173171
results := &util.PrivateRWSetWithConfig{}
174172
it, err := dr.store.GetTxPvtRWSetByTxid(dig.TxId, filter)
175173
if err != nil {
176-
return nil, errors.New(fmt.Sprint("was not able to retrieve private data from transient store, namespace", dig.Namespace,
177-
", collection name", dig.Collection, ", txID", dig.TxId, ", due to", err))
174+
return nil, errors.Errorf("was not able to retrieve private data from transient store, namespace <%s>"+
175+
", collection name %s, txID <%s>, due to <%s>", dig.Namespace, dig.Collection, dig.TxId, err)
178176
}
179177
defer it.Close()
180178

181179
maxEndorsedAt := uint64(0)
182180
for {
183181
res, err := it.NextWithConfig()
184182
if err != nil {
185-
return nil, errors.New(fmt.Sprint("error getting next element out of private data iterator, namespace", dig.Namespace,
186-
", collection name", dig.Collection, ", txID", dig.TxId, ", due to", err))
183+
return nil, errors.Errorf("error getting next element out of private data iterator, namespace <%s>"+
184+
", collection name <%s>, txID <%s>, due to <%s>", dig.Namespace, dig.Collection, dig.TxId, err)
187185
}
188186
if res == nil {
189187
return results, nil
@@ -229,13 +227,13 @@ func (dr *dataRetriever) extractPvtRWsets(pvtRWSets []*rwset.NsPvtReadWriteSet,
229227
for _, nsws := range pvtRWSets {
230228
// and in each namespace - iterate over all collections
231229
if nsws.Namespace != namespace {
232-
logger.Warning("Received private data namespace ", nsws.Namespace, " instead of ", namespace, " skipping...")
230+
logger.Debug("Received private data namespace ", nsws.Namespace, " instead of ", namespace, " skipping...")
233231
continue
234232
}
235233
for _, col := range nsws.CollectionPvtRwset {
236234
// This isn't the collection we're looking for
237235
if col.CollectionName != collectionName {
238-
logger.Warning("Received private data collection ", col.CollectionName, " instead of ", collectionName, " skipping...")
236+
logger.Debug("Received private data collection ", col.CollectionName, " instead of ", collectionName, " skipping...")
239237
continue
240238
}
241239
// Add the collection pRWset to the accumulated set

0 commit comments

Comments
 (0)