Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

logic.gno

0.83 Kb · 29 lines
 1// Package logic is version 1 of the logic realm of the "state realm + swappable
 2// logic" upgrade pattern (pattern C of the exploration; see ../../README.md).
 3//
 4// Same shape as v0, different rule. The counter it reads and writes is the same
 5// one v0 was using: the upgrade changed the code without touching the data.
 6package logic
 7
 8import (
 9	root "gno.land/r/moul/x/upgrade/store/root/v0"
10
11	"gno.land/p/nt/ufmt/v0"
12)
13
14// Step is this version's business rule: the change that justified the upgrade.
15const Step = 1000
16
17// Inc applies this version's rule to the shared counter.
18func Inc(cur realm) int {
19	return root.Inc(cross(cur), Step)
20}
21
22// Get reads the shared counter, including everything v0 wrote.
23func Get() int {
24	return root.Get()
25}
26
27func Render(_ string) string {
28	return ufmt.Sprintf("store/logic/v1: counter=%d step=%d\n", Get(), Step)
29}