pgipfsethdb

package
v5.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: AGPL-3.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIDFromKeccak256

func CIDFromKeccak256(hash []byte, codecType uint64) (cid.Cid, error)

CIDFromKeccak256 converts keccak256 hash bytes into a v1 cid

func NewBatch

func NewBatch(db *sqlx.DB, tx *sqlx.Tx, blockNumber *big.Int) ethdb.Batch

NewBatch returns a ethdb.Batch interface for PG-IPFS

func NewDatabase

func NewDatabase(db *sqlx.DB, cacheConfig CacheConfig) ethdb.Database

NewDatabase returns a ethdb.Database interface for PG-IPFS

func NewIterator

func NewIterator(start, prefix []byte, db *sqlx.DB) ethdb.Iterator

NewIterator returns an ethdb.Iterator interface for PG-IPFS

func NewKeyValueStore

func NewKeyValueStore(db *sqlx.DB, cacheConfig CacheConfig) ethdb.KeyValueStore

NewKeyValueStore returns a ethdb.KeyValueStore interface for PG-IPFS

Types

type Batch

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

Batch is the type that satisfies the ethdb.Batch interface for PG-IPFS Ethereum data using a direct Postgres connection

func (*Batch) Delete

func (b *Batch) Delete(cidBytes []byte) (err error)

Delete satisfies the ethdb.Batch interface Delete removes the key from the key-value data store

func (*Batch) Put

func (b *Batch) Put(cidBytes []byte, value []byte) (err error)

Put satisfies the ethdb.Batch interface Put inserts the given value into the key-value data store Key is expected to be a fully formulated cid key TODO: note, now that we expected a cid we could route to the "cids" tables based on prefix instead of to ipld.blocks but is it better to handle this routing here, or use a completely different interface since we already have to refactor at levels above this package in order to pass in cids instead of raw keccak256 hashes

func (*Batch) Replay

func (b *Batch) Replay(w ethdb.KeyValueWriter) error

Replay satisfies the ethdb.Batch interface Replay replays the batch contents

func (*Batch) Reset

func (b *Batch) Reset()

Reset satisfies the ethdb.Batch interface Reset resets the batch for reuse This should be called after every write

func (*Batch) ValueSize

func (b *Batch) ValueSize() int

ValueSize satisfies the ethdb.Batch interface ValueSize retrieves the amount of data queued up for writing The returned value is the total byte length of all data queued to write

func (*Batch) Write

func (b *Batch) Write() error

Write satisfies the ethdb.Batch interface Write flushes any accumulated data to disk

type CacheConfig

type CacheConfig struct {
	Name           string
	Size           int
	ExpiryDuration time.Duration
}

type Database

type Database struct {
	BlockNumber *big.Int
	// contains filtered or unexported fields
}

Database is the type that satisfies the ethdb.Database and ethdb.KeyValueStore interfaces for PG-IPFS Ethereum data using a direct Postgres connection

func (*Database) Ancient

func (d *Database) Ancient(kind string, number uint64) ([]byte, error)

Ancient satisfies the ethdb.AncientReader interface Ancient retrieves an ancient binary blob from the append-only immutable files

func (*Database) AncientDatadir

func (d *Database) AncientDatadir() (string, error)

AncientDatadir returns an error as we don't have a backing chain freezer.

func (*Database) AncientRange

func (d *Database) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error)

AncientRange retrieves all the items in a range, starting from the index 'start'. It will return

  • at most 'count' items,
  • at least 1 item (even if exceeding the maxBytes), but will otherwise return as many items as fit into maxBytes.

func (*Database) AncientSize

func (d *Database) AncientSize(kind string) (uint64, error)

AncientSize satisfies the ethdb.AncientReader interface AncientSize returns the ancient size of the specified category

func (*Database) Ancients

func (d *Database) Ancients() (uint64, error)

Ancients satisfies the ethdb.AncientReader interface Ancients returns the ancient item numbers in the ancient store

func (*Database) Close

func (d *Database) Close() error

Close satisfies the io.Closer interface. Close closes the db connection and deregisters from groupcache.

func (*Database) Compact

func (d *Database) Compact(start []byte, limit []byte) error

Compact satisfies the ethdb.Compacter interface Compact flattens the underlying data store for the given key range

func (*Database) Delete

func (d *Database) Delete(cidBytes []byte) error

Delete satisfies the ethdb.KeyValueWriter interface Delete removes the cid from the key-value data store

func (*Database) Get

func (d *Database) Get(cidBytes []byte) ([]byte, error)

Get satisfies the ethdb.KeyValueReader interface Get retrieves the given cid if it's present in the key-value data store

func (*Database) GetCacheStats

func (d *Database) GetCacheStats() groupcache.Stats

func (*Database) Has

func (d *Database) Has(cidBytes []byte) (bool, error)

Has satisfies the ethdb.KeyValueReader interface Has retrieves if a cid is present in the key-value data store

func (*Database) HasAncient

func (d *Database) HasAncient(kind string, number uint64) (bool, error)

HasAncient satisfies the ethdb.AncientReader interface HasAncient returns an indicator whether the specified data exists in the ancient store

func (*Database) InitCache

func (d *Database) InitCache(cacheConfig CacheConfig)

func (*Database) MigrateTable

func (d *Database) MigrateTable(string, func([]byte) ([]byte, error)) error

MigrateTable satisfies the ethdb.AncientWriter interface. MigrateTable processes and migrates entries of a given table to a new format.

func (*Database) ModifyAncients

func (d *Database) ModifyAncients(f func(ethdb.AncientWriteOp) error) (int64, error)

func (*Database) NewBatch

func (d *Database) NewBatch() ethdb.Batch

NewBatch satisfies the ethdb.Batcher interface NewBatch creates a write-only database that buffers changes to its host db until a final write is called

func (*Database) NewBatchWithSize

func (d *Database) NewBatchWithSize(size int) ethdb.Batch

NewBatchWithSize satisfies the ethdb.Batcher interface. NewBatchWithSize creates a write-only database batch with pre-allocated buffer.

func (*Database) NewIterator

func (d *Database) NewIterator(prefix []byte, start []byte) ethdb.Iterator

NewIterator satisfies the ethdb.Iteratee interface it creates a binary-alphabetical iterator over a subset of database content with a particular key prefix, starting at a particular initial key (or after, if it does not exist).

Note: This method assumes that the prefix is NOT part of the start, so there's no need for the caller to prepend the prefix to the start

func (*Database) NewSnapshot

func (d *Database) NewSnapshot() (ethdb.Snapshot, error)

NewSnapshot satisfies the ethdb.Snapshotter interface. NewSnapshot creates a database snapshot based on the current state.

func (*Database) Put

func (d *Database) Put(cidBytes []byte, value []byte) error

Put satisfies the ethdb.KeyValueWriter interface Put inserts the given value into the key-value data store Key is expected to be a fully formulated cis of value

func (*Database) ReadAncients

func (d *Database) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error)

ReadAncients applies the provided AncientReader function

func (*Database) Stat

func (d *Database) Stat(property string) (string, error)

Stat satisfies the ethdb.Stater interface Stat returns a particular internal stat of the database

func (*Database) Sync

func (d *Database) Sync() error

Sync satisfies the ethdb.AncientWriter interface Sync flushes all in-memory ancient store data to disk

func (*Database) Tail

func (d *Database) Tail() (uint64, error)

Tail satisfies the ethdb.AncientReader interface. Tail returns the number of first stored item in the freezer.

func (*Database) TruncateHead

func (d *Database) TruncateHead(n uint64) error

TruncateHead satisfies the ethdb.AncientWriter interface. TruncateHead discards all but the first n ancient data from the ancient store.

func (*Database) TruncateTail

func (d *Database) TruncateTail(n uint64) error

TruncateTail satisfies the ethdb.AncientWriter interface. TruncateTail discards the first n ancient data from the ancient store.

type DatabaseProperty

type DatabaseProperty int

DatabaseProperty enum type

const (
	Unknown DatabaseProperty = iota
	Size
	Idle
	InUse
	MaxIdleClosed
	MaxLifetimeClosed
	MaxOpenConnections
	OpenConnections
	WaitCount
	WaitDuration
)

func DatabasePropertyFromString

func DatabasePropertyFromString(property string) (DatabaseProperty, error)

DatabasePropertyFromString helper function

type Iterator

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

Iterator is the type that satisfies the ethdb.Iterator interface for PG-IPFS Ethereum data using a direct Postgres connection Iteratee interface is used in Geth for various tests, trie/sync_bloom.go (for fast sync), rawdb.InspectDatabase, and the new core/state/snapshot features. This should not be confused with trie.NodeIterator or state.NodeIteraor (which can be constructed from the ethdb.KeyValueStoreand ethdb.Database interfaces)

func (*Iterator) Error

func (i *Iterator) Error() error

Error satisfies the ethdb.Iterator interface Error returns any accumulated error Exhausting all the key/value pairs is not considered to be an error

func (*Iterator) Key

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

Key satisfies the ethdb.Iterator interface Key returns the key of the current key/value pair, or nil if done The caller should not modify the contents of the returned slice and its contents may change on the next call to Next

func (*Iterator) Next

func (i *Iterator) Next() bool

Next satisfies the ethdb.Iterator interface Next moves the iterator to the next key/value pair It returns whether the iterator is exhausted

func (*Iterator) Release

func (i *Iterator) Release()

Release satisfies the ethdb.Iterator interface Release releases associated resources Release should always succeed and can be called multiple times without causing error

func (*Iterator) Value

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

Value satisfies the ethdb.Iterator interface Value returns the value of the current key/value pair, or nil if done The caller should not modify the contents of the returned slice and its contents may change on the next call to Next

Jump to

Keyboard shortcuts

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