Documentation ¶
Index ¶
- Variables
- func Keccak256ToCid(h []byte, codec uint64) (cid.Cid, error)
- func NewBatch(bs blockservice.BlockService, capacity int) (ethdb.Batch, error)
- func NewBlock(key, value []byte) (blocks.Block, error)
- func NewDatabase(bs blockservice.BlockService) ethdb.Database
- func NewIterator(start, prefix []byte, bs blockservice.BlockService) ethdb.Iterator
- func NewKeyValueStore(bs blockservice.BlockService) ethdb.KeyValueStore
- func NewMockBlockservice() blockservice.BlockService
- type Batch
- 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) Has(key []byte) (bool, error)
- func (d *Database) HasAncient(kind string, number uint64) (bool, error)
- 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) error
- func (d *Database) TruncateTail(n uint64) error
- type DatabaseProperty
- type Iterator
- type MockBlockservice
- func (mbs *MockBlockservice) AddBlock(ctx context.Context, b blocks.Block) error
- func (mbs *MockBlockservice) AddBlocks(ctx context.Context, bs []blocks.Block) error
- func (mbs *MockBlockservice) Blockstore() blockstore.Blockstore
- func (mbs *MockBlockservice) Close() error
- func (mbs *MockBlockservice) DeleteBlock(ctx context.Context, c cid.Cid) error
- func (mbs *MockBlockservice) Exchange() exchange.Interface
- func (mbs *MockBlockservice) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error)
- func (mbs *MockBlockservice) GetBlocks(ctx context.Context, cs []cid.Cid) <-chan blocks.Block
- func (mbs *MockBlockservice) SetError(err error)
- type MockBlockstore
- func (mbs *MockBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (mbs *MockBlockstore) DeleteBlock(ctx context.Context, c cid.Cid) error
- func (mbs *MockBlockstore) Get(ctx context.Context, c cid.Cid) (blocks.Block, error)
- func (mbs *MockBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error)
- func (mbs *MockBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error)
- func (mbs *MockBlockstore) HashOnRead(enabled bool)
- func (mbs *MockBlockstore) Put(ctx context.Context, b blocks.Block) error
- func (mbs *MockBlockstore) PutMany(ctx context.Context, bs []blocks.Block) error
- func (mbs *MockBlockstore) SetError(err error)
Constants ¶
This section is empty.
Variables ¶
var (
EvictionWarningErr = errors.New("warn: batch has exceeded capacity, data has been evicted")
)
Functions ¶
func Keccak256ToCid ¶
Keccak256ToCid takes a keccak256 hash and returns its cid v1 using the provided codec.
func NewBlock ¶
NewBlock takes a keccak256 hash key and the rlp []byte value it was derived from and creates an ipfs block object
func NewDatabase ¶
NewDatabase returns a ethdb.Database interface for IPFS
func NewIterator ¶
NewIterator returns an ethdb.Iterator interface for PG-IPFS
func NewKeyValueStore ¶
func NewKeyValueStore(bs blockservice.BlockService) ethdb.KeyValueStore
NewKeyValueStore returns a ethdb.KeyValueStore interface for IPFS
func NewMockBlockservice ¶
func NewMockBlockservice() blockservice.BlockService
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch is the type that satisfies the ethdb.Batch interface for IPFS Ethereum data using the ipfs blockservice interface This is ipfs-backing-datastore agnostic but must operate through a configured ipfs node (and so is subject to lockfile contention with e.g. an ipfs daemon) If blockservice block exchange is configured the blockservice can fetch data that are missing locally from IPFS peers
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 Returns an error when batch capacity has been exceeded and data was evicted It is up to ensure they do not exceed capacity The alternative is to check the cache len vs its capacity before inserting but this adds additional overhead to every Put/Delete
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 ¶
type Database struct {
// contains filtered or unexported fields
}
Database is the type that satisfies the ethdb.Database and ethdb.KeyValueStore interfaces for IPFS Ethereum data This is ipfs-backing-datastore agnostic but must operate through a configured ipfs node (and so is subject to lockfile contention with e.g. an ipfs daemon) If blockservice block exchange is configured the blockservice can fetch data that are missing locally from IPFS peers
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) Has ¶
Has satisfies the ethdb.KeyValueReader interface Has retrieves if a key is present in the key-value data store This only operates on the local blockstore not through the exchange
func (*Database) HasAncient ¶
HasAncient satisfies the ethdb.AncientReader interface HasAncient returns an indicator whether the specified data exists in the ancient store
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.
func (*Database) TruncateTail ¶
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 ExchangeOnline )
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 IPFS Ethereum data 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
type MockBlockservice ¶
type MockBlockservice struct {
// contains filtered or unexported fields
}
func (*MockBlockservice) Blockstore ¶
func (mbs *MockBlockservice) Blockstore() blockstore.Blockstore
func (*MockBlockservice) Close ¶
func (mbs *MockBlockservice) Close() error
func (*MockBlockservice) DeleteBlock ¶
func (mbs *MockBlockservice) DeleteBlock(ctx context.Context, c cid.Cid) error
func (*MockBlockservice) Exchange ¶
func (mbs *MockBlockservice) Exchange() exchange.Interface
func (*MockBlockservice) GetBlocks ¶
func (mbs *MockBlockservice) GetBlocks(ctx context.Context, cs []cid.Cid) <-chan blocks.Block
func (*MockBlockservice) SetError ¶
func (mbs *MockBlockservice) SetError(err error)
type MockBlockstore ¶
type MockBlockstore struct {
// contains filtered or unexported fields
}
func (*MockBlockstore) AllKeysChan ¶
func (mbs *MockBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
func (*MockBlockstore) DeleteBlock ¶
func (mbs *MockBlockstore) DeleteBlock(ctx context.Context, c cid.Cid) error
func (*MockBlockstore) GetSize ¶
func (mbs *MockBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error)
func (*MockBlockstore) Has ¶
func (mbs *MockBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error)
func (*MockBlockstore) HashOnRead ¶
func (mbs *MockBlockstore) HashOnRead(enabled bool)
func (*MockBlockstore) SetError ¶
func (mbs *MockBlockstore) SetError(err error)