Documentation ¶
Index ¶
- Constants
- func ErrBytes(err error) []byte
- func FormatBalance(bal uint64) string
- func GetHost(uri string) (string, error)
- func InitSubDirectory(rootPath string, name string) (string, error)
- func NewHandler(name string, service interface{}, lockOption ...common.LockOption) (*common.HTTPHandler, error)
- func Outf(format string, args ...interface{})
- func ParseBalance(bal string) (uint64, error)
- func Repeat[T any](v T, n int) []T
- func ToID(bytes []byte) ids.ID
- type BoundedBuffer
Constants ¶
const NativeDecimals = 9
Variables ¶
This section is empty.
Functions ¶
func FormatBalance ¶
func NewHandler ¶
func NewHandler( name string, service interface{}, lockOption ...common.LockOption, ) (*common.HTTPHandler, error)
NewHandler returns a new Handler for a service where:
- The handler's functionality is defined by [service] [service] should be a gorilla RPC service (see https://www.gorillatoolkit.org/pkg/rpc/v2)
- The name of the service is [name]
- The LockOption is the first element of [lockOption] By default the LockOption is WriteLock [lockOption] should have either 0 or 1 elements. Elements beside the first are ignored.
func Outf ¶
func Outf(format string, args ...interface{})
Outputs to stdout.
e.g.,
Out("{{green}}{{bold}}hi there %q{{/}}", "aa") Out("{{magenta}}{{bold}}hi therea{{/}} {{cyan}}{{underline}}b{{/}}")
ref. https://github.com/onsi/ginkgo/blob/v2.0.0/formatter/formatter.go#L52-L73
func ParseBalance ¶
Types ¶
type BoundedBuffer ¶
type BoundedBuffer[K any] struct { // contains filtered or unexported fields }
BoundedBuffer keeps [size] entries of type [K] in a buffer and calls [callback] on any item that is overwritten. This is typically used for dereferencing old roots during block processing.
BoundedBuffer is not thread-safe and requires the caller synchronize usage.
func NewBoundedBuffer ¶
func NewBoundedBuffer[K any](size int, callback func(K)) *BoundedBuffer[K]
NewBoundedBuffer creates a new BoundedBuffer.
func (*BoundedBuffer[K]) Insert ¶
func (b *BoundedBuffer[K]) Insert(h K)
Insert adds a new value to the buffer. If the buffer is full, the oldest value will be overwritten and [callback] will be invoked.
func (*BoundedBuffer[K]) Items ¶
func (b *BoundedBuffer[K]) Items() []K
func (*BoundedBuffer[K]) Last ¶
func (b *BoundedBuffer[K]) Last() (K, bool)
Last retrieves the last item added to the buffer.
If no items have been added to the buffer, Last returns the default value of [K] and [false].