mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-26 15:15:49 +00:00
Fix *U*Int64 parsing, add hardcore mode to ledger verifier.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user