~ubuntu-branches/debian/stretch/bitcoin/stretch

« back to all changes in this revision

Viewing changes to src/wallet/db.cpp

  • Committer: Package Import Robot
  • Author(s): Anthony Towns
  • Date: 2016-10-21 17:13:13 UTC
  • mfrom: (1.3.2)
  • Revision ID: package-import@ubuntu.com-20161021171313-7eu2ltpbk0xag3q1
Tags: 0.13.0-0.1
* Non-maintainer upload.
* New upstream release.
* Allow compilation with gcc/g++ 6. (Closes: Bug#835963)
* Additional fixes for openssl 1.1 compatibility. (See Bug#828248)
* Check if -latomic is needed (it is on mips*).
* Remove reproducible build patch, since leveldb build system is
  no longer used in 0.13. (See Bug#791834)
* Update description since the blockchain is much more than "several GB"
  now. (Closes: Bug#835809)

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
    return (fRecovered ? RECOVER_OK : RECOVER_FAIL);
166
166
}
167
167
 
 
168
/* End of headers, beginning of key/value data */
 
169
static const char *HEADER_END = "HEADER=END";
 
170
/* End of key/value data */
 
171
static const char *DATA_END = "DATA=END";
 
172
 
168
173
bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector<CDBEnv::KeyValPair>& vResult)
169
174
{
170
175
    LOCK(cs_db);
193
198
    // Format of bdb dump is ascii lines:
194
199
    // header lines...
195
200
    // HEADER=END
196
 
    // hexadecimal key
197
 
    // hexadecimal value
198
 
    // ... repeated
 
201
    //  hexadecimal key
 
202
    //  hexadecimal value
 
203
    //  ... repeated
199
204
    // DATA=END
200
205
 
201
206
    string strLine;
202
 
    while (!strDump.eof() && strLine != "HEADER=END")
 
207
    while (!strDump.eof() && strLine != HEADER_END)
203
208
        getline(strDump, strLine); // Skip past header
204
209
 
205
210
    std::string keyHex, valueHex;
206
 
    while (!strDump.eof() && keyHex != "DATA=END") {
 
211
    while (!strDump.eof() && keyHex != DATA_END) {
207
212
        getline(strDump, keyHex);
208
 
        if (keyHex != "DATA=END") {
 
213
        if (keyHex != DATA_END) {
 
214
            if (strDump.eof())
 
215
                break;
209
216
            getline(strDump, valueHex);
 
217
            if (valueHex == DATA_END) {
 
218
                LogPrintf("CDBEnv::Salvage: WARNING: Number of keys in data does not match number of values.\n");
 
219
                break;
 
220
            }
210
221
            vResult.push_back(make_pair(ParseHex(keyHex), ParseHex(valueHex)));
211
222
        }
212
223
    }
213
224
 
 
225
    if (keyHex != DATA_END) {
 
226
        LogPrintf("CDBEnv::Salvage: WARNING: Unexpected end of file while reading salvage output.\n");
 
227
        return false;
 
228
    }
 
229
 
214
230
    return (result == 0);
215
231
}
216
232