haystack.gno

0.67 Kb ยท 32 lines
 1package haystack
 2
 3import (
 4	"gno.land/p/n2p5/haystack"
 5)
 6
 7var storage = haystack.New()
 8
 9func Render(path string) string {
10	return `
11Put a Needle in the Haystack.
12`
13}
14
15// Add takes a fixed-length hex-encoded needle bytes and adds it to the haystack key-value store.
16// If storage encounters an error, it will panic.
17func Add(needleHex string) {
18	err := storage.Add(needleHex)
19	if err != nil {
20		panic(err)
21	}
22}
23
24// Get takes a fixed-length hex-encoded needle hash and returns the hex-encoded needle bytes.
25// If storage encounters an error, it will panic.
26func Get(hashHex string) string {
27	needleHex, err := storage.Get(hashHex)
28	if err != nil {
29		panic(err)
30	}
31	return needleHex
32}