diff --git a/core/ledger/kvledger/txmgmt/rwsetutil/rwset_builder.go b/core/ledger/kvledger/txmgmt/rwsetutil/rwset_builder.go index 6b947379815..79379a60779 100644 --- a/core/ledger/kvledger/txmgmt/rwsetutil/rwset_builder.go +++ b/core/ledger/kvledger/txmgmt/rwsetutil/rwset_builder.go @@ -94,24 +94,16 @@ func (b *RWSetBuilder) AddToRangeQuerySet(ns string, rqi *kvrwset.RangeQueryInfo } // AddToHashedReadSet adds a key and corresponding version to the hashed read-set -func (b *RWSetBuilder) AddToHashedReadSet(ns string, coll string, key string, version *version.Height) error { - kvReadHash, err := newPvtKVReadHash(key, version) - if err != nil { - return err - } +func (b *RWSetBuilder) AddToHashedReadSet(ns string, coll string, key string, version *version.Height) { + kvReadHash := newPvtKVReadHash(key, version) b.getOrCreateCollHashedRwBuilder(ns, coll).readMap[key] = kvReadHash - return nil } // AddToPvtAndHashedWriteSet adds a key and value to the private and hashed write-set -func (b *RWSetBuilder) AddToPvtAndHashedWriteSet(ns string, coll string, key string, value []byte) error { - kvWrite, kvWriteHash, err := newPvtKVWriteAndHash(key, value) - if err != nil { - return err - } +func (b *RWSetBuilder) AddToPvtAndHashedWriteSet(ns string, coll string, key string, value []byte) { + kvWrite, kvWriteHash := newPvtKVWriteAndHash(key, value) b.getOrCreateCollPvtRwBuilder(ns, coll).writeMap[key] = kvWrite b.getOrCreateCollHashedRwBuilder(ns, coll).writeMap[key] = kvWriteHash - return nil } // GetTxSimulationResults returns the proto bytes of public rwset diff --git a/core/ledger/kvledger/txmgmt/rwsetutil/rwset_builder_test.go b/core/ledger/kvledger/txmgmt/rwsetutil/rwset_builder_test.go index ee6df49997c..d4831234b2a 100644 --- a/core/ledger/kvledger/txmgmt/rwsetutil/rwset_builder_test.go +++ b/core/ledger/kvledger/txmgmt/rwsetutil/rwset_builder_test.go @@ -227,14 +227,12 @@ func TestTxSimulationResultWithPvtData(t *testing.T) { } func constructTestPvtKVReadHash(t *testing.T, key string, version *version.Height) *kvrwset.KVReadHash { - kvReadHash, err := newPvtKVReadHash(key, version) - testutil.AssertNoError(t, err, "") + kvReadHash := newPvtKVReadHash(key, version) return kvReadHash } func constructTestPvtKVWriteHash(t *testing.T, key string, value []byte) *kvrwset.KVWriteHash { - _, kvWriteHash, err := newPvtKVWriteAndHash(key, value) - testutil.AssertNoError(t, err, "") + _, kvWriteHash := newPvtKVWriteAndHash(key, value) return kvWriteHash } diff --git a/core/ledger/kvledger/txmgmt/rwsetutil/rwset_proto_util.go b/core/ledger/kvledger/txmgmt/rwsetutil/rwset_proto_util.go index 32c7bf1a617..f3d0028e850 100644 --- a/core/ledger/kvledger/txmgmt/rwsetutil/rwset_proto_util.go +++ b/core/ledger/kvledger/txmgmt/rwsetutil/rwset_proto_util.go @@ -303,16 +303,16 @@ func newKVWrite(key string, value []byte) *kvrwset.KVWrite { return &kvrwset.KVWrite{Key: key, IsDelete: value == nil, Value: value} } -func newPvtKVReadHash(key string, version *version.Height) (*kvrwset.KVReadHash, error) { - return &kvrwset.KVReadHash{KeyHash: util.ComputeStringHash(key), Version: newProtoVersion(version)}, nil +func newPvtKVReadHash(key string, version *version.Height) *kvrwset.KVReadHash { + return &kvrwset.KVReadHash{KeyHash: util.ComputeStringHash(key), Version: newProtoVersion(version)} } -func newPvtKVWriteAndHash(key string, value []byte) (*kvrwset.KVWrite, *kvrwset.KVWriteHash, error) { +func newPvtKVWriteAndHash(key string, value []byte) (*kvrwset.KVWrite, *kvrwset.KVWriteHash) { kvWrite := newKVWrite(key, value) var keyHash, valueHash []byte keyHash = util.ComputeStringHash(key) if !kvWrite.IsDelete { valueHash = util.ComputeHash(value) } - return kvWrite, &kvrwset.KVWriteHash{KeyHash: keyHash, IsDelete: kvWrite.IsDelete, ValueHash: valueHash}, nil + return kvWrite, &kvrwset.KVWriteHash{KeyHash: keyHash, IsDelete: kvWrite.IsDelete, ValueHash: valueHash} } diff --git a/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr/lockbased_tx_simulator.go b/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr/lockbased_tx_simulator.go index e8c0122ace1..ebf0ef18df7 100644 --- a/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr/lockbased_tx_simulator.go +++ b/core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr/lockbased_tx_simulator.go @@ -88,7 +88,8 @@ func (s *lockBasedTxSimulator) SetPrivateData(ns, coll, key string, value []byte return err } s.writePerformed = true - return s.rwsetBuilder.AddToPvtAndHashedWriteSet(ns, coll, key, value) + s.rwsetBuilder.AddToPvtAndHashedWriteSet(ns, coll, key, value) + return nil } // SetPrivateMetadata implements method in interface `ledger.TxSimulator`