mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 04:57:17 +00:00
e02d6acc7d
* save progress * try now * don't create bloom inside rlpDecode * don't create bloom inside ApplyTransaction * clean * clean * clean * clean * clean * clean * clean * clean * rename method * print timings * print timings * print timings * sort before flush * fix err lint * clean * move tests to transactions * compressed version * up bound * up bound * more tests * more tests * more tests * more tests * better removal * clean * better performance of get/put methods * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * optimize rpcdaemon * fix test * fix rpcdaemon * fix test * simplify * simplify * fix nil pointer * clean * revert some changes * add some logs * clean * try without optimize * clean * clean * clean * clean * try * move log_index to own stage * move log_index to own stage * integration add log_index stage * integration add log_index stage * clean * clean * print timing * remove duplicates at unwind * extract truncateBitmaps func * try detect * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * add blackList of topics * clean * clean * clean * clean * clean * clean * clean * clean * sharding 1 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 2 * sharded 3 * sharded 3 * sharded 3 * speedup things by putCurrent and putReserve * clean * optimize trim * clean * remove blacklist * add more info to err * ? * clean * clean * clean * clean * clean * working version * switch to cgo version of roaring bitmaps * clean * clean * clean * clean * more docs * clean * clean * fix logs bloom field * Fix debug_getModifiedAccountsByNumber * Try to fix crash * fix problem with "absent block" * fix problem with "absent block" * remove optimize method call * remove roaring iterator * fix problem with rebuild indicess * remove debug prints * tests for eth_getLogs involving topics * add tests for new stage, speparate topics into 2 buckets * version up * remove debug logs * remove debug logs * remove bloom filter implementation * Optimisation * Optimisatin not required, make rpctest lenient to geth errors * Lenient to geth failures Co-authored-by: Alexey Akhunov <akhounov@gmail.com>
173 lines
5.1 KiB
Go
173 lines
5.1 KiB
Go
// Copyright 2018 The go-ethereum Authors
|
|
// This file is part of the go-ethereum library.
|
|
//
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Lesser General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package ethdb
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// DESCRIBED: For info on database buckets see docs/programmers_guide/db_walkthrough.MD
|
|
|
|
// ErrKeyNotFound is returned when key isn't found in the database.
|
|
var ErrKeyNotFound = errors.New("db: key not found")
|
|
|
|
// Putter wraps the database write operations.
|
|
type Putter interface {
|
|
// Put inserts or updates a single entry.
|
|
Put(bucket string, key, value []byte) error
|
|
}
|
|
|
|
// Getter wraps the database read operations.
|
|
type Getter interface {
|
|
// Get returns the value for a given key if it's present.
|
|
Get(bucket string, key []byte) ([]byte, error)
|
|
|
|
// Get returns prober chunk of index or error if index is not created.
|
|
// Key must contain 8byte inverted block number in the end.
|
|
GetIndexChunk(bucket string, key []byte, timestamp uint64) ([]byte, error)
|
|
|
|
// Has indicates whether a key exists in the database.
|
|
Has(bucket string, key []byte) (bool, error)
|
|
|
|
// Walk iterates over entries with keys greater or equal to startkey.
|
|
// Only the keys whose first fixedbits match those of startkey are iterated over.
|
|
// walker is called for each eligible entry.
|
|
// If walker returns false or an error, the walk stops.
|
|
Walk(bucket string, startkey []byte, fixedbits int, walker func(k, v []byte) (bool, error)) error
|
|
|
|
// MultiWalk is similar to multiple Walk calls folded into one.
|
|
MultiWalk(bucket string, startkeys [][]byte, fixedbits []int, walker func(int, []byte, []byte) error) error
|
|
}
|
|
|
|
type GetterPutter interface {
|
|
Getter
|
|
Putter
|
|
}
|
|
|
|
// Deleter wraps the database delete operations.
|
|
type Deleter interface {
|
|
// Delete removes a single entry.
|
|
Delete(bucket string, key []byte) error
|
|
}
|
|
|
|
type Closer interface {
|
|
Close()
|
|
}
|
|
|
|
// Database wraps all database operations. All methods are safe for concurrent use.
|
|
type Database interface {
|
|
Getter
|
|
Putter
|
|
Deleter
|
|
Closer
|
|
|
|
// MultiPut inserts or updates multiple entries.
|
|
// Entries are passed as an array:
|
|
// bucket0, key0, val0, bucket1, key1, val1, ...
|
|
MultiPut(tuples ...[]byte) (uint64, error)
|
|
|
|
// NewBatch - starts in-mem batch
|
|
//
|
|
// Common pattern:
|
|
//
|
|
// batch := db.NewBatch()
|
|
// defer batch.Rollback()
|
|
// ... some calculations on `batch`
|
|
// batch.Commit()
|
|
//
|
|
NewBatch() DbWithPendingMutations //
|
|
Begin(ctx context.Context) (DbWithPendingMutations, error) // starts db transaction
|
|
Last(bucket string) ([]byte, []byte, error)
|
|
|
|
// IdealBatchSize defines the size of the data batches should ideally add in one write.
|
|
IdealBatchSize() int
|
|
|
|
Keys() ([][]byte, error)
|
|
|
|
// [TURBO-GETH] Freezer support (minimum amount that is actually used)
|
|
// FIXME: implement support if needed
|
|
Ancients() (uint64, error)
|
|
TruncateAncients(items uint64) error
|
|
Append(bucket string, key, value []byte) error
|
|
}
|
|
|
|
// MinDatabase is a minimalistic version of the Database interface.
|
|
type MinDatabase interface {
|
|
Get(bucket string, key []byte) ([]byte, error)
|
|
Put(bucket string, key, value []byte) error
|
|
Delete(bucket string, key []byte) error
|
|
}
|
|
|
|
// DbWithPendingMutations is an extended version of the Database,
|
|
// where all changes are first made in memory.
|
|
// Later they can either be committed to the database or rolled back.
|
|
type DbWithPendingMutations interface {
|
|
Database
|
|
|
|
// Commit - commits transaction (or flush data into underlying db object in case of `mutation`)
|
|
//
|
|
// Common pattern:
|
|
//
|
|
// tx := db.Begin()
|
|
// defer tx.Rollback()
|
|
// ... some calculations on `tx`
|
|
// tx.Commit()
|
|
//
|
|
Commit() (uint64, error)
|
|
|
|
// CommitAndBegin - commits and starts new transaction inside same db object.
|
|
// useful for periodical commits implementation.
|
|
//
|
|
// Common pattern:
|
|
//
|
|
// tx := db.Begin()
|
|
// defer tx.Rollback()
|
|
// for {
|
|
// ... some calculations on `tx`
|
|
// tx.CommitAndBegin()
|
|
// // defer here - is not useful, because 'tx' object is reused and first `defer` will work perfectly
|
|
// }
|
|
// tx.Commit()
|
|
//
|
|
CommitAndBegin(ctx context.Context) error
|
|
Rollback()
|
|
BatchSize() int
|
|
|
|
Reserve(bucket string, key []byte, i int) ([]byte, error)
|
|
}
|
|
|
|
type HasKV interface {
|
|
KV() KV
|
|
}
|
|
|
|
type HasTx interface {
|
|
Tx() Tx
|
|
}
|
|
|
|
type HasNetInterface interface {
|
|
DB() Database
|
|
}
|
|
|
|
type BucketsMigrator interface {
|
|
BucketExists(bucket string) (bool, error) // makes them empty
|
|
ClearBuckets(buckets ...string) error // makes them empty
|
|
DropBuckets(buckets ...string) error // drops them, use of them after drop will panic
|
|
}
|
|
|
|
var errNotSupported = errors.New("not supported")
|