bitcoin/bitcoin — pull request #5115 by laanwj (2014-10-21 14:19:44+00:00)
Title: rpc: Fix leveldb iterator leak, and flush before `gettxoutsetinfo`

This fixes an iterator leak resulting in

bitcoind: db/version_set.cc:789: leveldb::VersionSet::~VersionSet(): Assertion `dummy_versions_.next_ == &dummy_versions_' failed."

exception on shutdown (as well as keeping a copy of the utxo data pinned on disk).

Also make sure to flush pcoinsTip before calling GetStats() to make sure we apply them to the current height.