summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Taaki <genjix@riseup.net>2014-04-06 17:28:05 (GMT)
committer Amir Taaki <genjix@riseup.net>2014-04-06 17:28:05 (GMT)
commit48fd8ffedf732c56a44e85d938e90c6a81a0b812 (patch)
tree79f0e6369cc0e41f996b775b3ed5bb89143af75b
parent70b146b1fcbd235cb9f3f897649c40e69fe2b887 (diff)
tidy up code so loop looks less confusing.
-rw-r--r--src/blockchain/leveldb/leveldb_validate_block.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/blockchain/leveldb/leveldb_validate_block.cpp b/src/blockchain/leveldb/leveldb_validate_block.cpp
index 32cc217..0130318 100644
--- a/src/blockchain/leveldb/leveldb_validate_block.cpp
+++ b/src/blockchain/leveldb/leveldb_validate_block.cpp
@@ -73,7 +73,8 @@ uint64_t leveldb_validate_block::median_time_past()
{
// read last 11 block times into array and select median value
std::vector<uint64_t> times;
- for (int i = (int)(height_ - 1); i >= 0 && i >= (int)(height_ - 11); --i)
+ int first = static_cast<int>(height_) - 1, last = first - 10;
+ for (int i = first; i >= 0 && i >= last; --i)
times.push_back(fetch_block(i).timestamp);
BITCOIN_ASSERT(
(height_ < 11 && times.size() == height_) || times.size() == 11);
@@ -192,4 +193,4 @@ bool leveldb_validate_block::orphan_is_spent(
return false;
}
-} // namespace libbitcoin \ No newline at end of file
+} // namespace libbitcoin