|
19 | 19 |
|
20 | 20 | typedef std::map<std::string, std::string> mapValue_t;
|
21 | 21 |
|
22 |
| - |
23 |
| -static inline void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue) |
24 |
| -{ |
25 |
| - if (!mapValue.count("n")) |
26 |
| - { |
27 |
| - nOrderPos = -1; // TODO: calculate elsewhere |
28 |
| - return; |
29 |
| - } |
30 |
| - nOrderPos = atoi64(mapValue["n"]); |
31 |
| -} |
32 |
| - |
33 |
| - |
34 |
| -static inline void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue) |
35 |
| -{ |
36 |
| - if (nOrderPos == -1) |
37 |
| - return; |
38 |
| - mapValue["n"] = ToString(nOrderPos); |
39 |
| -} |
40 |
| - |
41 | 22 | /** Legacy class used for deserializing vtxPrev for backwards compatibility.
|
42 | 23 | * vtxPrev was removed in commit 93a18a3650292afbb441a47d1fa1b94aeb0164e3,
|
43 | 24 | * but old wallet.dat files may still contain vtxPrev vectors of CMerkleTxs.
|
@@ -192,7 +173,9 @@ class CWalletTx
|
192 | 173 | mapValue_t mapValueCopy = mapValue;
|
193 | 174 |
|
194 | 175 | mapValueCopy["fromaccount"] = "";
|
195 |
| - WriteOrderPos(nOrderPos, mapValueCopy); |
| 176 | + if (nOrderPos != -1) { |
| 177 | + mapValueCopy["n"] = ToString(nOrderPos); |
| 178 | + } |
196 | 179 | if (nTimeSmart) {
|
197 | 180 | mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
|
198 | 181 | }
|
@@ -232,8 +215,10 @@ class CWalletTx
|
232 | 215 | setConfirmed();
|
233 | 216 | }
|
234 | 217 |
|
235 |
| - ReadOrderPos(nOrderPos, mapValue); |
236 |
| - nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0; |
| 218 | + const auto it_op = mapValue.find("n"); |
| 219 | + nOrderPos = (it_op != mapValue.end()) ? atoi64(it_op->second) : -1; |
| 220 | + const auto it_ts = mapValue.find("timesmart"); |
| 221 | + nTimeSmart = (it_ts != mapValue.end()) ? static_cast<unsigned int>(atoi64(it_ts->second)) : 0; |
237 | 222 |
|
238 | 223 | mapValue.erase("fromaccount");
|
239 | 224 | mapValue.erase("spent");
|
|
0 commit comments