shardchain

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: LGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LDBDirPrefix      = "posichain_db"
	LDBShardDirPrefix = "posichain_sharddb"
)
View Source
const (
	LDBTiKVPrefix = "posichain_tikv"
)

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, options ...core.Options) (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(
	harmonyconfig *harmonyconfig.HarmonyConfig,
	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, options ...core.Options) (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.

type TiKvCacheConfig added in v0.1.8

type TiKvCacheConfig struct {
	StateDBCacheSizeInMB        uint32
	StateDBCachePersistencePath string
	StateDBRedisServerAddr      string
	StateDBRedisLRUTimeInDay    uint32
}

type TiKvFactory added in v0.1.8

type TiKvFactory struct {
	PDAddr      []string
	Role        string
	CacheConfig statedb_cache.StateDBCacheConfig
	// contains filtered or unexported fields
}

TiKvFactory is a memory-backed blockchain database factory.

func (*TiKvFactory) CloseAllDB added in v0.1.8

func (f *TiKvFactory) CloseAllDB()

CloseAllDB close all tikv database

func (*TiKvFactory) NewCacheStateDB added in v0.1.8

func (f *TiKvFactory) NewCacheStateDB(shardID uint32) (*statedb_cache.StateDBCacheDatabase, error)

NewCacheStateDB create shard statedb storage with memory cache

func (*TiKvFactory) NewChainDB added in v0.1.8

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

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

func (*TiKvFactory) NewStateDB added in v0.1.8

func (f *TiKvFactory) NewStateDB(shardID uint32) (ethdb.Database, error)

NewStateDB create shard tikv database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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