-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-15450] validate historydb key if it contains nils
There was a logic to skip keys with nil bytes from the historydb results. However, because some valid blockNumTranNumBytes may also contain nil bytes, these history keys are filtered out. This CR updates the logic to handle decoding error and process all keys returned by range query no matter if blockNumTranNumBytes contains a nil byte. If there is a decoding error, block:tran cannot be found, or key is not present in write set, it means that the key is a false key and will be skipped. Change-Id: I296479af55b7c750ef8f797faa807ee0f5489b0a Signed-off-by: Wenjian Qiao <wenjianq@gmail.com>
- Loading branch information
1 parent
8d353ba
commit 942b5ce
Showing
10 changed files
with
624 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
193 changes: 193 additions & 0 deletions
193
core/ledger/kvledger/history/historydb/historyleveldb/fakes/historydb_logger.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
core/ledger/kvledger/history/historydb/historyleveldb/fakes/historyleveldb_logger.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package fakes | ||
|
||
// HistoryleveldbLogger is a wrapper to fakes.Logger so that we can overwrite Warnf. | ||
type HistoryleveldbLogger struct { | ||
*HistorydbLogger | ||
} | ||
|
||
// Warnf copies byte array in arg2 and then delegates to fakes.Logger. | ||
// We have to make the copy because goleveldb iterator | ||
// reuses the byte array for keys and values for the Next() call. | ||
func (hl *HistoryleveldbLogger) Warnf(arg1 string, arg2 ...interface{}) { | ||
for i := 0; i < len(arg2); i++ { | ||
if b, ok := arg2[i].([]byte); ok { | ||
bCopy := make([]byte, len(b)) | ||
copy(bCopy, b) | ||
arg2[i] = bCopy | ||
} | ||
} | ||
hl.HistorydbLogger.Warnf(arg1, arg2...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.