PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/moul/x/vm/vmkit/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / x / vm / vmkit
Files
9 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/x/vm/vmkit/v0
gno
0.9

Files (9)

  • README.mdmarkdown
  • gnomod.tomltoml
  • codec.gnogno
  • fuel.gnogno
  • host.gnogno
  • instance.gnogno
  • machine.gnogno
  • testhost.gnogno
  • vmkit_test.gnogno
  • fuel.gnogno
    1package vmkit23// Unmetered is the fuel value that disables the budget: a [Meter] built with4// it never reports exhaustion. It exists so a benchmark can measure the5// dispatch loop without the meter in it, and so a trusted caller can run a6// program to completion in one slice. Gas remains the real backstop.7const Unmetered int64 = -189// Meter is a fuel budget being spent. It allocates nothing after10// construction, because it sits in the hot path of every guest instruction.11type Meter struct {12	budget int64 // Unmetered, or the number of units this slice may spend13	used   int6414}1516// NewMeter returns a meter good for `budget` units, or an unmetered one when17// budget is [Unmetered]. A budget of zero is a meter with nothing to spend,18// which is a legitimate way to ask "is this instance still runnable".19func NewMeter(budget int64) *Meter {20	if budget < 0 {21		budget = Unmetered22	}23	return &Meter{budget: budget}24}2526// Charge spends n units and reports whether they were available. On false27// nothing is spent, so the caller can stop before executing the instruction28// it could not pay for. That ordering is what makes a resumed machine29// re-execute exactly the instruction it stopped at, and no other.30func (m *Meter) Charge(n int64) bool {31	if m.budget == Unmetered {32		m.used += n33		return true34	}35	if m.used+n > m.budget {36		return false37	}38	m.used += n39	return true40}4142// Used reports how much fuel has been spent.43func (m *Meter) Used() int64 { return m.used }4445// Remaining reports what is left, or [Unmetered].46func (m *Meter) Remaining() int64 {47	if m.budget == Unmetered {48		return Unmetered49	}50	return m.budget - m.used51}5253// Exhausted reports whether the next single unit would fail.54func (m *Meter) Exhausted() bool { return !m.affordable(1) }5556func (m *Meter) affordable(n int64) bool {57	return m.budget == Unmetered || m.used+n <= m.budget58}59

    Functions

    not supported for pure packages by the node (vm/qfuncs)

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.