Fix *U*Int64 parsing, add hardcore mode to ledger verifier.

This commit is contained in:
Nicholas Dudfield
2014-05-06 14:54:22 +07:00
parent 12f43a5334
commit 5280d994a2
4 changed files with 39 additions and 7 deletions

View File

@@ -37,12 +37,23 @@ Ledger.prototype.calc_tx_hash = function () {
return tx_map.hash();
};
Ledger.prototype.calc_account_hash = function () {
Ledger.prototype.calc_account_hash = function (hardcore) {
var account_map = new SHAMap();
this.ledger_json.accountState.forEach(function (le) {
var data = SerializedObject.from_json(le);
if (hardcore) {
try {
var json = data.to_json();
data = SerializedObject.from_json(json);
} catch (e) {
console.log("erred on", le);
console.log("to_json() was", json);
console.log("e", e);
}
};
account_map.add_item(le.index, data, SHAMapTreeNode.TYPE_ACCOUNT_STATE);
});

View File

@@ -224,7 +224,10 @@ var STInt64 = exports.Int64 = new SerializedType({
serialize_hex(so, hex, true); //noLength = true
},
parse: function (so) {
var result = new BigInteger(so.read(8), 256);
var bytes = so.read(8);
// We need to add a 0, so if the high bit is set it won't think it's a
// pessimistic numeric fraek. What doth lief?
var result = new BigInteger([0].concat(bytes), 256);
assert(result instanceof BigInteger);
return result;
}