@sschepis/resolang
Version:
ResoLang - Core quantum resonance computation library for browser and Node.js
82 lines • 2.39 kB
TypeScript
/**
* Gas costs for different operations
* Calibrated to reflect computational complexity
*/
export declare const GAS_COSTS: {
readonly STATEMENT: 1;
readonly VARIABLE_DECLARATION: 3;
readonly VARIABLE_ASSIGNMENT: 2;
readonly EXPRESSION_EVAL: 1;
readonly CONDITION_CHECK: 2;
readonly LOOP_ITERATION: 3;
readonly FUNCTION_CALL: 10;
readonly BLOCK_ENTER: 1;
readonly ADD: 1;
readonly SUBTRACT: 1;
readonly MULTIPLY: 2;
readonly DIVIDE: 3;
readonly MODULO: 3;
readonly COMPARE: 1;
readonly IS_PRIME: 50;
readonly FACTORIZE: 100;
readonly GET_PRIMES: 20;
readonly COMPUTE_RESONANCE: 150;
readonly QUATERNION_CREATE: 25;
readonly SUPERPOSITION_CREATE: 50;
readonly ENTROPY_COMPUTE: 30;
readonly COHERENCE_MEASURE: 30;
readonly ENERGY_COMPUTE: 20;
readonly STATE_TRANSFORM: 40;
readonly VECTOR_OP: 10;
readonly PAY: 200;
readonly STAKE: 250;
readonly REWARD: 200;
readonly ACCOUNT_LOOKUP: 10;
readonly BALANCE_CHECK: 15;
readonly TRANSFER_RECORD: 50;
readonly ARRAY_CREATE: 5;
readonly ARRAY_ACCESS: 2;
readonly MEMBER_ACCESS: 2;
readonly LOG: 10;
readonly STORE_RESULT: 15;
};
export type GasOperation = keyof typeof GAS_COSTS;
/**
* Custom error for gas exhaustion
*/
export declare class GasExhaustedError extends Error {
readonly gasUsed: number;
readonly gasLimit: number;
constructor(message: string, gasUsed: number, gasLimit: number);
}
/**
* Gas meter for tracking and limiting gas consumption
*/
export declare class GasMeter {
private gasUsed;
private gasLimit;
private operations;
private enabled;
constructor(gasLimit?: number, enabled?: boolean);
/**
* Consume gas for an operation
* @throws GasExhaustedError if gas limit is exceeded
*/
consume(operation: GasOperation, multiplier?: number): void;
/** Get total gas used */
getGasUsed(): number;
/** Get remaining gas */
getGasRemaining(): number;
/** Get gas limit */
getGasLimit(): number;
/** Get breakdown of gas by operation */
getOperationBreakdown(): Record<GasOperation, {
count: number;
totalCost: number;
}>;
/** Reset the gas meter */
reset(): void;
/** Check if gas metering is enabled */
isEnabled(): boolean;
}
//# sourceMappingURL=gas.d.ts.map