util

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeBytesArrayToHex

func EncodeBytesArrayToHex(data [][]byte) []string

func EncodeBytesToHex

func EncodeBytesToHex(data []byte) string

func Launch

func Launch(start func() error, shutdown func() error, timeout time.Duration)

Launch service gracefully, or force exit after two consecutive signals

func MustDecodeHexArrayToBytes

func MustDecodeHexArrayToBytes(hexArray []string) [][]byte

func MustDecodeHexToBytes

func MustDecodeHexToBytes(hex string) []byte

func VerifyMerkleProof

func VerifyMerkleProof(rootHash []byte, proof [][]byte, leaf []byte) bool

Types

type Entry

type Entry struct {
	Error error
	Data  any
}

Entry represents each stream. If the stream fails, an error will be present.

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

Stream helps transmit each streams withing a channel.

func NewJSONStream

func NewJSONStream(builder func() any) Stream

NewJSONStream returns a new `Stream` type.

func (Stream) Start

func (s Stream) Start(path string)

Start starts streaming JSON file line by line. If an error occurs, the channel will be closed.

func (Stream) Watch

func (s Stream) Watch() <-chan Entry

Watch watches JSON streams. Each stream entry will either have an error or a User object. Client code does not need to explicitly exit after catching an error as the `Start` method will close the channel automatically.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL