Transaction
325C5D0265493E…D5A7FAE646AE
Block 26,356 · index 0 · indexed
Summary
- Hash
- 325C5D0265493E896204164DD2539C9A319966E47D069C434354D5A7FAE646AE
- Block
- 26,356
- Size
- 4051 bytes
- Gas used
- 8,758,067 / 10,509,740
- Fee
- 1000000ugnot
- Memo
- gnopublish
- Status
- success
Messages
Arguments · 9
- #1heapdemo
- #2README.md
- #3# `gno.land/r/moul/x/daily/heapdemo/v0` **Live demo of [`p/moul/x/daily/heap`](https://github.com/moul/gno-contracts/tree/main/p/moul/x/daily/heap/v0).** A thin, stateless realm: it holds no state of its own and contains none of the library's logic — `Render` just exercises the package and shows the result. Because it is stateless, the rendered page is identical on every call and on every node. Render it at [`/r/moul/x/daily/heapdemo/v0`](https://gno.land/r/moul/x/daily/heapdemo/v0). The library README explains the design and the trade-offs; this realm is the worked example. <!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) --> --- Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage. **Dependency graph:**  > 🧪 **Highly experimental — potentially vibe-coded.** Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md). <!-- END GNOCONTRACTS FOOTER -->
- #4gnomod.toml
- #5module = "gno.land/r/moul/x/daily/heapdemo/v0" gno = "0.9"
- #6heapdemo.gno
- #7// Package heapdemo is a small gnoweb demo of the binary heap / priority queue // provided by the [p/moul/x/daily/heap](/p/moul/x/daily/heap/v0) library: it // shows min- and max-ordering and the deterministic tiebreak. // // It contains no heap logic of its own. Stateless, so Render is deterministic — // which is precisely what the library is for. package heapdemo import ( "strconv" "strings" "gno.land/p/moul/x/daily/heap/v0" ) type job struct { name string priority int } // queue is the shared workload used by every section below. var queue = []job{ {"send email", 5}, {"pay invoice", 1}, {"backup db", 3}, {"rotate keys", 1}, {"clear cache", 9}, } // Render renders the demo for gnoweb. func Render(path string) string { var b strings.Builder b.WriteString("# Binary Heap\n\n") b.WriteString("A priority queue, demoing the ") b.WriteString("[`p/moul/x/daily/heap`](/p/moul/x/daily/heap/v0) library.\n\n") b.WriteString("## The workload\n\n") b.WriteString("| job | priority |\n|---|---|\n") for _, j := range queue { b.WriteString("| " + j.name + " | " + strconv.Itoa(j.priority) + " |\n") } b.WriteString("\n## Min-heap — lowest priority first\n\n") b.WriteString(popOrder(fill(heap.New()))) b.WriteString("\n## Max-heap — highest priority first\n\n") b.WriteString(popOrder(fill(heap.NewMax()))) b.WriteString("\n## Ties\n\n") b.WriteString("`pay invoice` and `rotate keys` share priority 1. Both heaps pop them ") b.WriteString("**oldest-first**: the tiebreak is insertion order and does *not* invert ") b.WriteString("with the heap kind.\n\n") b.WriteString("> Without a total order, two nodes could pop equal-priority items in ") b.WriteString("different sequences and render different pages — a consensus bug, not a ") b.WriteString("cosmetic one.\n") return b.String() } func fill(h *heap.Heap) *heap.Heap { for _, j := range queue { h.Push(j.name, j.priority) } return h } func popOrder(h *heap.Heap) string { var b strings.Builder b.WriteString("| # | job | priority |\n|---|---|---|\n") i := 0 for { v, p, ok := h.Pop() if !ok { break } i++ b.WriteString("| " + strconv.Itoa(i) + " | " + v + " | " + strconv.Itoa(p) + " |\n") } return b.String() }
- #8/gno.MemPackageType
- #9 MPUserProd
Result log
msg:0,success:true,log:,events:[]