logic.gno
0.82 Kb · 30 lines
1// Package logic is version 0 of the logic realm of the "state realm + swappable
2// logic" upgrade pattern (pattern C of the exploration; see ../../README.md).
3//
4// It owns no state at all. Everything it writes lands in the root data realm,
5// which is what makes replacing this realm cheap: there is nothing here to
6// migrate.
7package logic
8
9import (
10 root "gno.land/r/moul/x/upgrade/store/root/v0"
11
12 "gno.land/p/nt/ufmt/v0"
13)
14
15// Step is this version's business rule: one call, one unit.
16const Step = 1
17
18// Inc applies this version's rule to the shared counter.
19func Inc(cur realm) int {
20 return root.Inc(cross(cur), Step)
21}
22
23// Get reads the shared counter. Same number every version sees.
24func Get() int {
25 return root.Get()
26}
27
28func Render(_ string) string {
29 return ufmt.Sprintf("store/logic/v0: counter=%d step=%d\n", Get(), Step)
30}