diff --git a/dist/rpcQuery.d.ts.map b/dist/rpcQuery.d.ts.map index f4a5e3e..69ce1d2 100644 --- a/dist/rpcQuery.d.ts.map +++ b/dist/rpcQuery.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"rpcQuery.d.ts","sourceRoot":"","sources":["../src/rpcQuery.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAe,MAAM,SAAS,CAAC;AAMlD,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAe;IAChC,OAAO,CAAC,aAAa,CAAC,CAAM;IAC5B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,UAAU,CAAwC;IAC1D,OAAO,CAAC,eAAe,CAAC,CAAsB;gBAElC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IAMlD,IAAI,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,CAEzB;IAED,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,OAAO;YAQD,IAAI;YA2BJ,UAAU;IAgCxB,OAAO,CAAC,cAAc;IA8CtB,OAAO,CAAC,KAAK;CASd"} \ No newline at end of file +{"version":3,"file":"rpcQuery.d.ts","sourceRoot":"","sources":["../src/rpcQuery.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAe,MAAM,SAAS,CAAC;AAKlD,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAe;IAChC,OAAO,CAAC,aAAa,CAAC,CAAM;IAC5B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,UAAU,CAAwC;IAC1D,OAAO,CAAC,eAAe,CAAC,CAAsB;gBAElC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IAMlD,IAAI,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,CAEzB;IAED,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,OAAO;YAQD,IAAI;YA2BJ,UAAU;IAgCxB,OAAO,CAAC,cAAc;IAgDtB,OAAO,CAAC,KAAK;CASd"} \ No newline at end of file diff --git a/dist/rpcQuery.js b/dist/rpcQuery.js index aa73fd5..e209d64 100644 --- a/dist/rpcQuery.js +++ b/dist/rpcQuery.js @@ -2,7 +2,7 @@ import { clearTimeout, setTimeout } from "timers"; import { pack, unpack } from "msgpackr"; import { Buffer } from "buffer"; import { blake2b } from "libskynet"; -import jsonStringify from "json-stable-stringify"; +import { flatten } from "./util.js"; export default class RpcQuery { _network; _query; @@ -83,12 +83,14 @@ export default class RpcQuery { const responseStore = this._responses; const responseStoreData = Object.values(responseStore); const responseObjects = responseStoreData.reduce((output, item) => { - const hash = Buffer.from(blake2b(Buffer.from(jsonStringify(item?.data)))).toString("hex"); + const itemFlattened = flatten(item?.data).sort(); + const hash = Buffer.from(blake2b(Buffer.from(JSON.stringify(itemFlattened)))).toString("hex"); output[hash] = item?.data; return output; }, {}); const responses = responseStoreData.reduce((output, item) => { - const hash = Buffer.from(blake2b(Buffer.from(jsonStringify(item?.data)))).toString("hex"); + const itemFlattened = flatten(item?.data).sort(); + const hash = Buffer.from(blake2b(Buffer.from(JSON.stringify(itemFlattened)))).toString("hex"); output[hash] = output[hash] ?? 0; output[hash]++; return output;