Transaction

EA4330680C17EC…982994567865

Block 26,073 · index 0 · indexed

Summary

Hash
EA4330680C17ECD95DEE1FB2B27B3C9F724B20B5ED97DB1FED78982994567865
Block
26,073
Size
4051 bytes
Gas used
8,680,076 / 10,416,151
Fee
1000000ugnot
Memo
gnopublish
Status
success

Messages

Arguments · 9

  1. #1heapdemo
  2. #2README.md
  3. #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:** ![gno.land/r/moul/x/daily/heapdemo/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/r/moul/x/daily/heapdemo/v0/deps.png) > 🧪 **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 -->
  4. #4gnomod.toml
  5. #5module = "gno.land/r/moul/x/daily/heapdemo/v0" gno = "0.9"
  6. #6heapdemo.gno
  7. #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. #8/gno.MemPackageType
  9. #9 MPUserProd

Result log

msg:0,success:true,log:,events:[]

← Back to block 26,073