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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

heavy.gno

0.81 Kb · 34 lines
 1// Package heavy emits events at the chain's size limits, so one transaction's
 2// indexer answer can exceed gnotifd's 64 MiB read limit.
 3package heavy
 4
 5import (
 6	"chain"
 7	"strconv"
 8	"strings"
 9)
10
11// The chain caps an event at 64 attribute pairs, and each key and value at
12// 4,096 bytes.
13const (
14	pairs   = 64
15	attrLen = 4096
16)
17
18// Emit emits n events, each with every attribute pair at its maximum size.
19func Emit(_ realm, n int) {
20	attrs := make([]string, 0, 2*pairs)
21	value := strings.Repeat("v", attrLen)
22	for i := 0; i < pairs; i++ {
23		prefix := strconv.Itoa(i) + "-"
24		attrs = append(attrs, prefix+strings.Repeat("k", attrLen-len(prefix)), value)
25	}
26	for i := 0; i < n; i++ {
27		chain.Emit("Heavy", attrs...)
28	}
29}
30
31// EventBytes is the size of one event's keys and values.
32func EventBytes() int {
33	return 2 * pairs * attrLen
34}