shardchain

package
v0.0.0-...-3a5d5d8 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: LGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LDBDirPrefix      = "feechain_db"
	LDBShardDirPrefix = "feechain_sharddb"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection interface {
	// ShardChain returns the blockchain for the given shard,
	// opening one as necessary.
	ShardChain(shardID uint32) (*core.BlockChain, error)

	// CloseShardChain closes the given shard chain.
	CloseShardChain(shardID uint32) error

	// Close closes all shard chains.
	Close() error
}

Collection is a collection of per-shard blockchains.

type CollectionImpl

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

CollectionImpl is the main implementation of the shard chain collection. See the Collection interface for details.

func NewCollection

func NewCollection(
	dbFactory DBFactory, dbInit DBInitializer, engine engine.Engine,
	chainConfig *params.ChainConfig,
) *CollectionImpl

NewCollection creates and returns a new shard chain collection.

dbFactory is the shard chain database factory to use.

dbInit is the shard chain initializer to use when the database returned by the factory is brand new (empty).

func (*CollectionImpl) Close

func (sc *CollectionImpl) Close() error

Close closes all shard chains.

func (*CollectionImpl) CloseShardChain

func (sc *CollectionImpl) CloseShardChain(shardID uint32) error

CloseShardChain closes the given shard chain.

func (*CollectionImpl) DisableCache

func (sc *CollectionImpl) DisableCache(shardID uint32)

DisableCache disables caching mode for newly opened chains. It does not affect already open chains. For best effect, use this immediately after creating collection.

func (*CollectionImpl) ShardChain

func (sc *CollectionImpl) ShardChain(shardID uint32) (*core.BlockChain, error)

ShardChain returns the blockchain for the given shard, opening one as necessary.

type DBFactory

type DBFactory interface {
	// NewChainDB returns a new database for the blockchain for
	// given shard.
	NewChainDB(shardID uint32) (ethdb.Database, error)
}

DBFactory is a blockchain database factory.

type DBInitializer

type DBInitializer interface {
	InitChainDB(db ethdb.Database, shardID uint32) error
}

DBInitializer initializes a newly created chain database.

type LDBFactory

type LDBFactory struct {
	RootDir string // directory in which to put shard databases in.
}

LDBFactory is a LDB-backed blockchain database factory.

func (*LDBFactory) NewChainDB

func (f *LDBFactory) NewChainDB(shardID uint32) (ethdb.Database, error)

NewChainDB returns a new LDB for the blockchain for given shard.

type LDBShardFactory

type LDBShardFactory struct {
	RootDir    string // directory in which to put shard databases in.
	DiskCount  int
	ShardCount int
	CacheTime  int
	CacheSize  int
}

LDBShardFactory is a merged Multi-LDB-backed blockchain database factory.

func (*LDBShardFactory) NewChainDB

func (f *LDBShardFactory) NewChainDB(shardID uint32) (ethdb.Database, error)

NewChainDB returns a new memDB for the blockchain for given shard.

type MemDBFactory

type MemDBFactory struct{}

MemDBFactory is a memory-backed blockchain database factory.

func (*MemDBFactory) NewChainDB

func (f *MemDBFactory) NewChainDB(shardID uint32) (ethdb.Database, error)

NewChainDB returns a new memDB for the blockchain for given shard.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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