aboutsummaryrefslogtreecommitdiff
path: root/src/leveldb/table/table.cc
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-10-25 02:33:03 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2014-10-25 02:39:56 -0700
commit65e4e8427d900b27f579dc12af6c74b3ec628286 (patch)
treeeff17ddb47e11f894826d921abe5b5634a74c168 /src/leveldb/table/table.cc
parentb847e0139eae06f4ea3c44ae414dc0110598a1be (diff)
parent5b9f8425a515739e2149bf5bfb2ae6ed60bfbaf2 (diff)
downloadbitcoin-65e4e8427d900b27f579dc12af6c74b3ec628286.tar.xz
Merge pull request #5093
4b0e2d7 Squashed 'src/leveldb/' changes from 7924331..7d41e6f (Pieter Wuille)
Diffstat (limited to 'src/leveldb/table/table.cc')
-rw-r--r--src/leveldb/table/table.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/leveldb/table/table.cc b/src/leveldb/table/table.cc
index 71c1756e5f..dff8a82590 100644
--- a/src/leveldb/table/table.cc
+++ b/src/leveldb/table/table.cc
@@ -41,7 +41,7 @@ Status Table::Open(const Options& options,
Table** table) {
*table = NULL;
if (size < Footer::kEncodedLength) {
- return Status::InvalidArgument("file is too short to be an sstable");
+ return Status::Corruption("file is too short to be an sstable");
}
char footer_space[Footer::kEncodedLength];
@@ -58,7 +58,11 @@ Status Table::Open(const Options& options,
BlockContents contents;
Block* index_block = NULL;
if (s.ok()) {
- s = ReadBlock(file, ReadOptions(), footer.index_handle(), &contents);
+ ReadOptions opt;
+ if (options.paranoid_checks) {
+ opt.verify_checksums = true;
+ }
+ s = ReadBlock(file, opt, footer.index_handle(), &contents);
if (s.ok()) {
index_block = new Block(contents);
}
@@ -92,6 +96,9 @@ void Table::ReadMeta(const Footer& footer) {
// TODO(sanjay): Skip this if footer.metaindex_handle() size indicates
// it is an empty block.
ReadOptions opt;
+ if (rep_->options.paranoid_checks) {
+ opt.verify_checksums = true;
+ }
BlockContents contents;
if (!ReadBlock(rep_->file, opt, footer.metaindex_handle(), &contents).ok()) {
// Do not propagate errors since meta info is not needed for operation
@@ -120,6 +127,9 @@ void Table::ReadFilter(const Slice& filter_handle_value) {
// We might want to unify with ReadBlock() if we start
// requiring checksum verification in Table::Open.
ReadOptions opt;
+ if (rep_->options.paranoid_checks) {
+ opt.verify_checksums = true;
+ }
BlockContents block;
if (!ReadBlock(rep_->file, opt, filter_handle, &block).ok()) {
return;