consts.gno
1.25 Kb ยท 41 lines
1// Package genesis provides a way to store and access dynamic variables that are
2// set during the genesis or block0 initialization phase. This package
3// demonstrates an important aspect of p/ packages in Gno: while they are
4// pure packages, they can have mutable state during initialization (init phase)
5// before becoming read-only.
6//
7// Future improvements:
8// When Gno supports something similar to "go build -X", this package could be
9// enhanced to accept variables from the CLI or environment variables (e.g., in
10// gnodev context). For now, it only supports initialization-time operations
11// that make sense at the beginning of the system's lifecycle.
12package genesis
13
14import (
15 "chain/runtime"
16 "time"
17)
18
19var (
20 // Time is the time of the genesis block.
21 Time = time.Now()
22
23 // Height is the height of the genesis block (usually 0).
24 Height = runtime.ChainHeight()
25
26 // Domain is the domain of the chain.
27 Domain = runtime.ChainDomain()
28
29 // XXX: TZ
30 // XXX: Supply = std.Coins{{"ugnot", std.NewBanker(std.BankerTypeReadonly).TotalSupply("ugnot")}}
31)
32
33// Uptime returns the uptime of the chain.
34func Uptime() time.Duration {
35 return time.Since(Time)
36}
37
38// Upheight returns the height of the chain.
39func Upheight() int64 {
40 return runtime.ChainHeight() - Height
41}