indexes

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaxUint24 = 1<<24 - 1
	MaxUint40 = 1<<40 - 1
	MaxUint48 = 1<<48 - 1
	MaxUint64 = 1<<64 - 1
)
View Source
const (
	// 6 bytes for offset (uint48, max 281.5 TB (terabytes)),
	// 3 bytes for size (uint24, max 16.7 MB (megabytes), which is plenty considering the max object size is ~1 MB)
	IndexValueSize_CidToOffsetAndSize = 6 + 3
)
View Source
const (
	// 6 bytes for offset (uint48, max 281.5 TB (terabytes)),
	// 3 bytes for size (uint24, max 16.7 MB (megabytes), which is plenty considering the max object size is ~1 MB)
	IndexValueSize_PubkeyToOffsetAndSize = 6 + 3
)
View Source
const (
	// 36 bytes for cid
	IndexValueSize_SigToCid = 36
)
View Source
const (
	// 36 bytes for cid
	IndexValueSize_SlotToCid = 36
)

Variables

View Source
var (
	ErrInvalidNetwork = errors.New("invalid network")
	ErrInvalidRootCid = errors.New("invalid root cid")
)
View Source
var Kind_CidToOffsetAndSize = []byte("cid-to-offset-and-size")
View Source
var Kind_PubkeyToOffsetAndSize = []byte("pubkey-to-offset-and-size")
View Source
var Kind_SigToCid = []byte("sig-to-cid")
View Source
var Kind_SlotToCid = []byte("slot-to-cid")

Functions

func BtoUint24 added in v0.4.0

func BtoUint24(buf []byte) uint32

BtoUint24 converts a 3-byte slice to a uint32.

func BtoUint40 added in v0.4.0

func BtoUint40(buf []byte) uint64

BtoUint40 converts a 5-byte slice to a uint64.

func BtoUint48 added in v0.4.0

func BtoUint48(buf []byte) uint64

BtoUint48 converts a 6-byte slice to a uint64.

func BtoUint64 added in v0.4.0

func BtoUint64(buf []byte) uint64

BtoUint64 converts an 8-byte little-endian slice to a uint64.

func FormatFilename_PubkeyToOffsetAndSize added in v0.4.0

func FormatFilename_PubkeyToOffsetAndSize(epoch uint64, rootCid cid.Cid, network Network) string

func IsFileNewFormat

func IsFileNewFormat(path string) (bool, error)

func IsFileOldFormat

func IsFileOldFormat(file io.ReaderAt) (bool, error)

func IsFileOldFormatByPath

func IsFileOldFormatByPath(path string) (bool, error)

func IsOldMagic

func IsOldMagic(magicBytes [8]byte) bool

func IsValidNetwork

func IsValidNetwork(network Network) bool

func Uint24tob added in v0.4.0

func Uint24tob(v uint32) []byte

Uint24tob converts a uint32 to a 3-byte slice; panics if v > maxUint24.

func Uint40tob added in v0.4.0

func Uint40tob(v uint64) []byte

Uint40tob converts a uint64 to a 5-byte slice; panics if v > maxUint40.

func Uint48tob added in v0.4.0

func Uint48tob(v uint64) []byte

Uint48tob converts a uint64 to a 6-byte slice; panics if v > maxUint48.

func Uint64tob added in v0.4.0

func Uint64tob(v uint64) []byte

Uint64tob converts a uint64 to an 8-byte little-endian slice.

Types

type CidToOffsetAndSize_Reader

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

func OpenWithReader_CidToOffsetAndSize

func OpenWithReader_CidToOffsetAndSize(reader ReaderAtCloser) (*CidToOffsetAndSize_Reader, error)

func Open_CidToOffsetAndSize

func Open_CidToOffsetAndSize(file string) (*CidToOffsetAndSize_Reader, error)

func (*CidToOffsetAndSize_Reader) Close

func (r *CidToOffsetAndSize_Reader) Close() error

func (*CidToOffsetAndSize_Reader) Get

func (r *CidToOffsetAndSize_Reader) Get(cid_ cid.Cid) (*OffsetAndSize, error)

func (*CidToOffsetAndSize_Reader) Meta

Meta returns the metadata for the index.

func (*CidToOffsetAndSize_Reader) Prefetch

func (r *CidToOffsetAndSize_Reader) Prefetch(b bool)

type CidToOffsetAndSize_Writer

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

func NewWriter_CidToOffsetAndSize

func NewWriter_CidToOffsetAndSize(
	epoch uint64,
	rootCid cid.Cid,
	network Network,
	tmpDir string,
	numItems uint64,
) (*CidToOffsetAndSize_Writer, error)

func (*CidToOffsetAndSize_Writer) Close

func (w *CidToOffsetAndSize_Writer) Close() error

func (*CidToOffsetAndSize_Writer) GetFilepath

func (w *CidToOffsetAndSize_Writer) GetFilepath() string

GetFilepath returns the path to the sealed index file.

func (*CidToOffsetAndSize_Writer) Put

func (w *CidToOffsetAndSize_Writer) Put(cid_ cid.Cid, offset uint64, size uint64) error

func (*CidToOffsetAndSize_Writer) Seal

func (w *CidToOffsetAndSize_Writer) Seal(ctx context.Context, dstDir string) error

type Deprecated_CidToOffset_Reader

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

func Deprecated_OpenWithReader_CidToOffset

func Deprecated_OpenWithReader_CidToOffset(reader ReaderAtCloser) (*Deprecated_CidToOffset_Reader, error)

func Deprecated_Open_CidToOffset

func Deprecated_Open_CidToOffset(file string) (*Deprecated_CidToOffset_Reader, error)

func (*Deprecated_CidToOffset_Reader) Close

func (*Deprecated_CidToOffset_Reader) Get

func (r *Deprecated_CidToOffset_Reader) Get(cid_ cid.Cid) (uint64, error)

Get returns the offset for the given cid.

func (*Deprecated_CidToOffset_Reader) Meta

Meta returns the metadata for the index.

func (*Deprecated_CidToOffset_Reader) Prefetch

func (r *Deprecated_CidToOffset_Reader) Prefetch(b bool)

type Metadata

type Metadata struct {
	Epoch     uint64
	RootCid   cid.Cid
	Network   Network
	IndexKind []byte
}

func (*Metadata) AssertEpoch

func (m *Metadata) AssertEpoch(x uint64) error

Assert Epoch is x.

func (*Metadata) AssertIndexKind

func (m *Metadata) AssertIndexKind(x []byte) error

Assert IndexKind is x.

func (*Metadata) AssertNetwork

func (m *Metadata) AssertNetwork(x Network) error

Assert Network is x.

func (*Metadata) AssertRootCid

func (m *Metadata) AssertRootCid(x cid.Cid) error

Assert RootCid is x.

type Network

type Network string
const (
	NetworkMainnet Network = "mainnet"
	NetworkTestnet Network = "testnet"
	NetworkDevnet  Network = "devnet"
)

type OffsetAndSize

type OffsetAndSize struct {
	Offset uint64 // uint48, 6 bytes, max 281.5 TB (terabytes)
	Size   uint64 // uint24, 3 bytes, max 16.7 MB (megabytes)
}

func NewOffsetAndSize

func NewOffsetAndSize(offset uint64, size uint64) *OffsetAndSize

func OffsetAndSizeSliceFromBytes added in v0.4.0

func OffsetAndSizeSliceFromBytes(buf []byte) ([]OffsetAndSize, error)

func (OffsetAndSize) Bytes

func (oas OffsetAndSize) Bytes() []byte

Bytes returns the offset and size as a byte slice.

func (*OffsetAndSize) FromBytes

func (oas *OffsetAndSize) FromBytes(buf []byte) error

FromBytes parses the offset and size from a byte slice.

func (*OffsetAndSize) IsValid

func (oas *OffsetAndSize) IsValid() bool

IsValid returns true if the offset and size are valid.

func (OffsetAndSize) IsZero added in v0.4.0

func (oas OffsetAndSize) IsZero() bool

IsZero

type PubkeyToOffsetAndSize_Reader added in v0.4.0

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

func OpenWithReader_PubkeyToOffsetAndSize added in v0.4.0

func OpenWithReader_PubkeyToOffsetAndSize(reader ReaderAtCloser) (*PubkeyToOffsetAndSize_Reader, error)

func Open_PubkeyToOffsetAndSize added in v0.4.0

func Open_PubkeyToOffsetAndSize(file string) (*PubkeyToOffsetAndSize_Reader, error)

func (*PubkeyToOffsetAndSize_Reader) Close added in v0.4.0

func (*PubkeyToOffsetAndSize_Reader) Get added in v0.4.0

func (r *PubkeyToOffsetAndSize_Reader) Get(pk solana.PublicKey) (*OffsetAndSize, error)

func (*PubkeyToOffsetAndSize_Reader) Meta added in v0.4.0

Meta returns the metadata for the index.

func (*PubkeyToOffsetAndSize_Reader) Prefetch added in v0.4.0

func (r *PubkeyToOffsetAndSize_Reader) Prefetch(b bool)

type PubkeyToOffsetAndSize_Writer added in v0.4.0

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

func NewWriter_PubkeyToOffsetAndSize added in v0.4.0

func NewWriter_PubkeyToOffsetAndSize(
	epoch uint64,
	rootCid cid.Cid,
	network Network,
	tmpDir string,
) (*PubkeyToOffsetAndSize_Writer, error)

func (*PubkeyToOffsetAndSize_Writer) Close added in v0.4.0

func (*PubkeyToOffsetAndSize_Writer) GetFilepath added in v0.4.0

func (w *PubkeyToOffsetAndSize_Writer) GetFilepath() string

GetFilepath returns the path to the sealed index file.

func (*PubkeyToOffsetAndSize_Writer) Put added in v0.4.0

func (w *PubkeyToOffsetAndSize_Writer) Put(pk solana.PublicKey, offset uint64, size uint64) error

func (*PubkeyToOffsetAndSize_Writer) Seal added in v0.4.0

func (*PubkeyToOffsetAndSize_Writer) SealWithFilename added in v0.4.0

func (w *PubkeyToOffsetAndSize_Writer) SealWithFilename(ctx context.Context, dstFilepath string) error

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.Closer
}

type SigToCid_Reader

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

func OpenWithReader_SigToCid

func OpenWithReader_SigToCid(reader ReaderAtCloser) (*SigToCid_Reader, error)

func OpenWithReader_SigToCid_Deprecated

func OpenWithReader_SigToCid_Deprecated(reader ReaderAtCloser) (*SigToCid_Reader, error)

func Open_SigToCid

func Open_SigToCid(filepath string) (*SigToCid_Reader, error)

func (*SigToCid_Reader) Close

func (r *SigToCid_Reader) Close() error

func (*SigToCid_Reader) Get

func (r *SigToCid_Reader) Get(sig solana.Signature) (cid.Cid, error)

func (*SigToCid_Reader) IsDeprecatedOldVersion

func (r *SigToCid_Reader) IsDeprecatedOldVersion() bool

func (*SigToCid_Reader) Meta

func (r *SigToCid_Reader) Meta() *Metadata

Meta returns the metadata for the index.

func (*SigToCid_Reader) Prefetch

func (r *SigToCid_Reader) Prefetch(b bool)

type SigToCid_Writer

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

func NewWriter_SigToCid

func NewWriter_SigToCid(
	epoch uint64,
	rootCid cid.Cid,
	network Network,
	tmpDir string,
	numItems uint64,
) (*SigToCid_Writer, error)

func (*SigToCid_Writer) Close

func (w *SigToCid_Writer) Close() error

func (*SigToCid_Writer) GetFilepath

func (w *SigToCid_Writer) GetFilepath() string

GetFilepath returns the path to the sealed index file.

func (*SigToCid_Writer) Put

func (w *SigToCid_Writer) Put(sig solana.Signature, cid_ cid.Cid) error

func (*SigToCid_Writer) Seal

func (w *SigToCid_Writer) Seal(ctx context.Context, dstDir string) error

type SlotToCid_Reader

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

func OpenWithReader_SlotToCid

func OpenWithReader_SlotToCid(reader ReaderAtCloser) (*SlotToCid_Reader, error)

func OpenWithReader_SlotToCid_Deprecated

func OpenWithReader_SlotToCid_Deprecated(reader ReaderAtCloser) (*SlotToCid_Reader, error)

func Open_SlotToCid

func Open_SlotToCid(filepath string) (*SlotToCid_Reader, error)

func (*SlotToCid_Reader) Close

func (r *SlotToCid_Reader) Close() error

func (*SlotToCid_Reader) Get

func (r *SlotToCid_Reader) Get(slot uint64) (cid.Cid, error)

func (*SlotToCid_Reader) IsDeprecatedOldVersion

func (r *SlotToCid_Reader) IsDeprecatedOldVersion() bool

func (*SlotToCid_Reader) Meta

func (r *SlotToCid_Reader) Meta() *Metadata

Meta returns the metadata for the index.

func (*SlotToCid_Reader) Prefetch

func (r *SlotToCid_Reader) Prefetch(b bool)

type SlotToCid_Writer

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

func NewWriter_SlotToCid

func NewWriter_SlotToCid(
	epoch uint64,
	rootCid cid.Cid,
	network Network,
	tmpDir string,
	numItems uint64,
) (*SlotToCid_Writer, error)

func (*SlotToCid_Writer) Close

func (w *SlotToCid_Writer) Close() error

func (*SlotToCid_Writer) GetFilepath

func (w *SlotToCid_Writer) GetFilepath() string

GetFilepath returns the path to the sealed index file.

func (*SlotToCid_Writer) Put

func (w *SlotToCid_Writer) Put(slot uint64, cid_ cid.Cid) error

func (*SlotToCid_Writer) Seal

func (w *SlotToCid_Writer) Seal(ctx context.Context, dstDir string) error

Jump to

Keyboard shortcuts

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