Documentation ¶
Index ¶
- Variables
- func MultihashKeyFromKeccak256(h []byte) (string, error)
- func NewBatch(db *sqlx.DB, tx *sqlx.Tx, blockNumber *big.Int) ethdb.Batch
- func NewDatabase(db *sqlx.DB, cacheConfig CacheConfig) ethdb.Database
- func NewIterator(start, prefix []byte, db *sqlx.DB) ethdb.Iterator
- func NewKeyValueStore(db *sqlx.DB, cacheConfig CacheConfig) ethdb.KeyValueStore
- type Batch
- type CacheConfig
- type Database
- func (d *Database) Ancient(kind string, number uint64) ([]byte, error)
- func (d *Database) AncientDatadir() (string, error)
- func (d *Database) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error)
- func (d *Database) AncientSize(kind string) (uint64, error)
- func (d *Database) Ancients() (uint64, error)
- func (d *Database) Close() error
- func (d *Database) Compact(start []byte, limit []byte) error
- func (d *Database) Delete(key []byte) error
- func (d *Database) Get(key []byte) ([]byte, error)
- func (d *Database) GetCacheStats() groupcache.Stats
- func (d *Database) Has(key []byte) (bool, error)
- func (d *Database) HasAncient(kind string, number uint64) (bool, error)
- func (d *Database) InitCache(cacheConfig CacheConfig)
- func (d *Database) MigrateTable(string, func([]byte) ([]byte, error)) error
- func (d *Database) ModifyAncients(f func(ethdb.AncientWriteOp) error) (int64, error)
- func (d *Database) NewBatch() ethdb.Batch
- func (d *Database) NewBatchWithSize(size int) ethdb.Batch
- func (d *Database) NewIterator(prefix []byte, start []byte) ethdb.Iterator
- func (d *Database) NewSnapshot() (ethdb.Snapshot, error)
- func (d *Database) Put(key []byte, value []byte) error
- func (d *Database) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error)
- func (d *Database) Stat(property string) (string, error)
- func (d *Database) Sync() error
- func (d *Database) Tail() (uint64, error)
- func (d *Database) TruncateHead(n uint64) (uint64, error)
- func (d *Database) TruncateTail(n uint64) (uint64, error)
- type DatabaseProperty
- type Iterator
Constants ¶
This section is empty.
Variables ¶
var ( DefaultCacheConfig = CacheConfig{ Name: "db", Size: 3000000, ExpiryDuration: time.Hour, } )
Functions ¶
func MultihashKeyFromKeccak256 ¶
MultihashKeyFromKeccak256 converts keccak256 hash bytes into a blockstore-prefixed multihash db key string
func NewDatabase ¶
func NewDatabase(db *sqlx.DB, cacheConfig CacheConfig) ethdb.Database
NewDatabase returns a ethdb.Database interface for PG-IPFS
func NewIterator ¶
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 ¶
Delete satisfies the ethdb.Batch interface Delete removes the key from the key-value data store
func (*Batch) Put ¶
Put satisfies the ethdb.Batch interface Put inserts the given value into the key-value data store Key is expected to be the keccak256 hash of value
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
type Database ¶
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 ¶
Ancient satisfies the ethdb.AncientReader interface Ancient retrieves an ancient binary blob from the append-only immutable files
func (*Database) AncientDatadir ¶
AncientDatadir returns an error as we don't have a backing chain freezer.
func (*Database) AncientRange ¶
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 ¶
AncientSize satisfies the ethdb.AncientReader interface AncientSize returns the ancient size of the specified category
func (*Database) Ancients ¶
Ancients satisfies the ethdb.AncientReader interface Ancients returns the ancient item numbers in the ancient store
func (*Database) Compact ¶
Compact satisfies the ethdb.Compacter interface Compact flattens the underlying data store for the given key range
func (*Database) Delete ¶
Delete satisfies the ethdb.KeyValueWriter interface Delete removes the key from the key-value data store
func (*Database) Get ¶
Get satisfies the ethdb.KeyValueReader interface Get retrieves the given key if it's present in the key-value data store
func (*Database) GetCacheStats ¶
func (d *Database) GetCacheStats() groupcache.Stats
func (*Database) Has ¶
Has satisfies the ethdb.KeyValueReader interface Has retrieves if a key is present in the key-value data store
func (*Database) HasAncient ¶
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 ¶
MigrateTable satisfies the ethdb.AncientWriter interface. MigrateTable processes and migrates entries of a given table to a new format.
func (*Database) ModifyAncients ¶
func (*Database) NewBatch ¶
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 ¶
NewBatchWithSize satisfies the ethdb.Batcher interface. NewBatchWithSize creates a write-only database batch with pre-allocated buffer.
func (*Database) NewIterator ¶
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 ¶
NewSnapshot satisfies the ethdb.Snapshotter interface. NewSnapshot creates a database snapshot based on the current state.
func (*Database) Put ¶
Put satisfies the ethdb.KeyValueWriter interface Put inserts the given value into the key-value data store Key is expected to be the keccak256 hash 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 ¶
Stat satisfies the ethdb.Stater interface Stat returns a particular internal stat of the database
func (*Database) Sync ¶
Sync satisfies the ethdb.AncientWriter interface Sync flushes all in-memory ancient store data to disk
func (*Database) Tail ¶
Tail satisfies the ethdb.AncientReader interface. Tail returns the number of first stored item in the freezer.
func (*Database) TruncateHead ¶
TruncateHead satisfies the ethdb.AncientWriter interface. TruncateHead discards all but 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 ¶
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 ¶
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 ¶
Next satisfies the ethdb.Iterator interface Next moves the iterator to the next key/value pair It returns whether the iterator is exhausted