@typeberry/convert 0.2.0-f9e8db5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +18 -0
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -20535,6 +20535,24 @@ class interpreter_Interpreter {
20535
20535
  getMemoryPage(pageNumber) {
20536
20536
  return this.memory.getPageDump(tryAsPageNumber(pageNumber));
20537
20537
  }
20538
+ calculateBlockGasCost() {
20539
+ const codeLength = this.code.length;
20540
+ const blocks = new Map();
20541
+ let currentBlock = "0";
20542
+ let gasCost = 0;
20543
+ const getNextIstructionIndex = (index) => index + 1 + this.mask.getNoOfBytesToNextInstruction(index + 1);
20544
+ for (let index = 0; index < codeLength; index = getNextIstructionIndex(index)) {
20545
+ const instruction = this.code[index];
20546
+ if (this.basicBlocks.isBeginningOfBasicBlock(index)) {
20547
+ blocks.set(currentBlock, gasCost);
20548
+ currentBlock = index.toString();
20549
+ gasCost = 0;
20550
+ }
20551
+ gasCost += instructionGasMap[instruction];
20552
+ }
20553
+ blocks.set(currentBlock, gasCost);
20554
+ return blocks;
20555
+ }
20538
20556
  }
20539
20557
 
20540
20558
  ;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/index.ts