ipfs_log

package
v0.0.0-...-7f34ccf Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StorageName is the name of the storage driver
	StorageName = "ipfs-log"
)

Variables

View Source
var Dbname = "ifdb-event-kv-ipfs-log"

Dbname is the default name for the database

Functions

This section is empty.

Types

type DB

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

DB represents the database instance

func (*DB) Close

func (db *DB) Close() error

Close closes the database instances

func (*DB) Compact

func (db *DB) Compact() error

Compact is a no-op for this storage driver

func (*DB) Delete

func (db *DB) Delete(key []byte) error

Delete removes a key-value pair from the database

func (*DB) Get

func (db *DB) Get(key []byte) ([]byte, error)

Get retrieves a value by key from the database

func (*DB) GetLevelDB

func (d *DB) GetLevelDB() *leveldb.DB

GetLevelDB returns the underlying leveldb instance

func (*DB) GetStorageEngine

func (s *DB) GetStorageEngine() interface{}

GetStorageEngine returns the storage engine instance

func (*DB) NewIterator

func (db *DB) NewIterator() driver.IIterator

NewIterator creates a new iterator for iterating over the database

func (*DB) NewSnapshot

func (db *DB) NewSnapshot() (driver.ISnapshot, error)

NewSnapshot creates a new snapshot of the database

func (*DB) NewWriteBatch

func (db *DB) NewWriteBatch() driver.IWriteBatch

NewWriteBatch creates a new write batch for batch operations

func (*DB) Put

func (db *DB) Put(key, value []byte) error

Put inserts a key-value pair into the database

func (*DB) SyncDelete

func (db *DB) SyncDelete(key []byte) error

SyncDelete is a synchronous version of Delete

func (*DB) SyncPut

func (db *DB) SyncPut(key []byte, value []byte) error

SyncPut is a synchronous version of Put

type Iterator

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

Iterator wraps the leveldb iterator to provide a higher-level interface.

func (*Iterator) Close

func (it *Iterator) Close() error

Close releases the iterator, making it unusable.

func (*Iterator) First

func (it *Iterator) First()

First moves the iterator to the first item.

func (*Iterator) Key

func (it *Iterator) Key() []byte

Key returns the key of the current iterator position.

func (*Iterator) Last

func (it *Iterator) Last()

Last moves the iterator to the last item.

func (*Iterator) Next

func (it *Iterator) Next()

Next advances the iterator to the next item.

func (*Iterator) Prev

func (it *Iterator) Prev()

Prev moves the iterator to the previous item.

func (*Iterator) Seek

func (it *Iterator) Seek(key []byte)

Seek moves the iterator to the first key that is greater than or equal to the given key.

func (*Iterator) Valid

func (it *Iterator) Valid() bool

Valid returns whether the iterator is positioned at a valid item.

func (*Iterator) Value

func (it *Iterator) Value() []byte

Value returns the value of the current iterator position.

type Snapshot

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

Snapshot represents a read-only snapshot of the database at a particular point in time.

func (*Snapshot) Close

func (s *Snapshot) Close()

Close releases the snapshot, making it unusable.

func (*Snapshot) Get

func (s *Snapshot) Get(key []byte) ([]byte, error)

Get retrieves the value for a key from the snapshot. It returns the value and any error encountered.

func (*Snapshot) NewIterator

func (s *Snapshot) NewIterator() driver.IIterator

NewIterator creates a new iterator for the snapshot. It returns an IIterator interface which can be used to iterate over the snapshot's data.

type Store

type Store struct{}

Store is the implementation of the storage driver

func (Store) Open

func (s Store) Open(path string, cfg *config.Config) (driver.IDB, error)

Open initializes and opens the database

func (Store) Repair

func (s Store) Repair(path string, cfg *config.Config) error

Repair is a no-op for this storage driver

func (Store) String

func (s Store) String() string

String returns the name of the storage driver

type WriteBatch

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

WriteBatch represents a batch of write operations to be committed to the database.

func (*WriteBatch) Close

func (w *WriteBatch) Close()

Close releases any resources held by the write batch.

func (*WriteBatch) Commit

func (w *WriteBatch) Commit() error

Commit writes the batch's operations to the database. It returns an error if the commit fails.

func (*WriteBatch) Data

func (w *WriteBatch) Data() []byte

Data returns the raw data of the write batch. This is useful for debugging or replication purposes.

func (*WriteBatch) Delete

func (w *WriteBatch) Delete(key []byte)

Delete removes a key-value pair from the write batch. This operation does not immediately delete from the database.

func (*WriteBatch) Put

func (w *WriteBatch) Put(key, value []byte)

Put adds a key-value pair to the write batch. This operation does not immediately write to the database.

func (*WriteBatch) Rollback

func (w *WriteBatch) Rollback() error

Rollback discards all operations in the write batch. It returns an error if the rollback fails.

func (*WriteBatch) SyncCommit

func (w *WriteBatch) SyncCommit() error

SyncCommit writes the batch's operations to the database and ensures they are written to stable storage. It returns an error if the commit fails.

Jump to

Keyboard shortcuts

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