util

package
v1.0.0-test.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReleased    = errors.New("leveldb: resource already relesed")
	ErrHasReleaser = errors.New("leveldb: releaser already defined")
)

Functions

func AccountPrefix

func AccountPrefix() []byte

func Hash

func Hash(data []byte, seed uint32) uint32

Hash return hash of the given data.

func ParseKey

func ParseKey(key []byte) (prefix []byte, subName []byte, realKey []byte)

ParseKey parse key -account,<32B> -storage,<20B>,<32B>

func WritePageFile

func WritePageFile(file *os.File, data []byte, pos int64) error

Types

type BasicReleaser

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

BasicReleaser provides basic implementation of Releaser and ReleaseSetter.

func (*BasicReleaser) Release

func (r *BasicReleaser) Release()

Release implements Releaser.Release.

func (*BasicReleaser) Released

func (r *BasicReleaser) Released() bool

Released returns whether Release method already called.

func (*BasicReleaser) SetReleaser

func (r *BasicReleaser) SetReleaser(releaser Releaser)

SetReleaser implements ReleaseSetter.SetReleaser.

type CRC

type CRC uint32

CRC is a CRC-32 checksum computed using Castagnoli's polynomial.

func NewCRC

func NewCRC(b []byte) CRC

NewCRC creates a new crc based on the given bytes.

func (CRC) Update

func (c CRC) Update(b []byte) CRC

Update updates the crc with the given bytes.

func (CRC) Value

func (c CRC) Value() uint32

Value returns a masked crc.

type NoopReleaser

type NoopReleaser struct{}

func (NoopReleaser) Release

func (NoopReleaser) Release()

type Range

type Range struct {
	// Start of the key range, include in the range.
	Start []byte

	// Limit of the key range, not include in the range.
	Limit []byte
}

Range is a key range.

func BytesPrefix

func BytesPrefix(prefix []byte) *Range

BytesPrefix returns key range that satisfy the given prefix. This only applicable for the standard 'bytes comparer'.

type ReleaseSetter

type ReleaseSetter interface {
	// SetReleaser associates the given releaser to the resources. The
	// releaser will be called once coresponding resources released.
	// Calling SetReleaser with nil will clear the releaser.
	//
	// This will panic if a releaser already present or coresponding
	// resource is already released. Releaser should be cleared first
	// before assigned a new one.
	SetReleaser(releaser Releaser)
}

ReleaseSetter is the interface that wraps the basic SetReleaser method.

type Releaser

type Releaser interface {
	// Release releases associated resources. Release should always success
	// and can be called multiple times without causing error.
	Release()
}

Releaser is the interface that wraps the basic Release method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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