indexes

package
v0.3.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: 14 Imported by: 0

Documentation

Index

Constants

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 (
	// 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_SigToCid = []byte("sig-to-cid")
View Source
var Kind_SlotToCid = []byte("slot-to-cid")

Functions

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

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 (*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.

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