storage

package
v0.0.0-...-6b2b62e Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package storage provides storage for chestnut.

Package storage provides storage for chestnut.

Package storage provides storage for chestnut.

Index

Constants

View Source
const ANN_PREFIX = "ann" //announce
View Source
const ATH_PREFIX = "ath" //auth
View Source
const BLK_PREFIX = "blk" //block
View Source
const CHD_PREFIX = "chd" //cached
View Source
const CNT_PREFIX = "cnt" //content
View Source
const GRP_PREFIX = "grp" //group
View Source
const PRD_PREFIX = "prd" //producer
View Source
const SMA_PREFIX = "sma" //schema
View Source
const TRX_PREFIX = "trx" //trx

Variables

View Source
var (
	DefaultLogFileSize     int64  = 16 << 20
	DefaultMemTableSize    int64  = 8 << 20
	DefaultMaxEntries      uint32 = 50000
	DefaultBlockCacheSize  int64  = 32 << 20
	DefaultCompressionType        = options.Snappy
	DefaultPrefetchSize           = 10
)

Functions

This section is empty.

Types

type CSBadger

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

func (*CSBadger) BatchWrite

func (s *CSBadger) BatchWrite(keys [][]byte, values [][]byte) error

func (*CSBadger) Close

func (s *CSBadger) Close() error

func (*CSBadger) Delete

func (s *CSBadger) Delete(key []byte) error

func (*CSBadger) Foreach

func (s *CSBadger) Foreach(fn func([]byte, []byte, error) error) error

func (*CSBadger) Get

func (s *CSBadger) Get(key []byte) ([]byte, error)

func (*CSBadger) GetSequence

func (s *CSBadger) GetSequence(key []byte, bandwidth uint64) (Sequence, error)

func (*CSBadger) Init

func (s *CSBadger) Init(path string) error

func (*CSBadger) IsExist

func (s *CSBadger) IsExist(key []byte) (bool, error)

func (*CSBadger) PrefixForeach

func (s *CSBadger) PrefixForeach(prefix []byte, fn func([]byte, []byte, error) error) error

func (*CSBadger) PrefixForeachKey

func (s *CSBadger) PrefixForeachKey(prefix []byte, valid []byte, reverse bool, fn func([]byte, error) error) error

func (*CSBadger) Set

func (s *CSBadger) Set(key []byte, val []byte) error

type ChestnutStorage

type ChestnutStorage interface {
	Init(path string) error
	Close() error
	Set(key []byte, val []byte) error
	Delete(key []byte) error
	Get(key []byte) ([]byte, error)
	PrefixForeach(prefix []byte, fn func([]byte, []byte, error) error) error
	PrefixForeachKey(prefix []byte, valid []byte, reverse bool, fn func([]byte, error) error) error
	Foreach(fn func([]byte, []byte, error) error) error
	IsExist([]byte) (bool, error)

	// For appdb, atomic batch write
	BatchWrite(keys [][]byte, values [][]byte) error
	GetSequence([]byte, uint64) (Sequence, error)
}

type DbMgr

type DbMgr struct {
	GroupInfoDb ChestnutStorage
	Db          ChestnutStorage
	Auth        ChestnutStorage
	DataPath    string
}

func (*DbMgr) AddBlock

func (dbMgr *DbMgr) AddBlock(newBlock *chestnutpb.Block, cached bool, prefix ...string) error

add Block

func (*DbMgr) AddGensisBlock

func (dbMgr *DbMgr) AddGensisBlock(gensisBlock *chestnutpb.Block, prefix ...string) error

func (*DbMgr) AddGroup

func (dbMgr *DbMgr) AddGroup(groupItem *chestnutpb.GroupItem) error

add group

func (*DbMgr) AddPost

func (dbMgr *DbMgr) AddPost(trx *chestnutpb.Trx, prefix ...string) error

add post

func (*DbMgr) AddProducedBlockCount

func (dbMgr *DbMgr) AddProducedBlockCount(groupId, producerPubkey string, prefix ...string) error

func (*DbMgr) AddProducer

func (dbMgr *DbMgr) AddProducer(item *chestnutpb.ProducerItem, prefix ...string) error

func (*DbMgr) AddTrx

func (dbMgr *DbMgr) AddTrx(trx *chestnutpb.Trx, prefix ...string) error

save trx

func (*DbMgr) CloseDb

func (dbMgr *DbMgr) CloseDb()

func (*DbMgr) GatherBlocksFromCache

func (dbMgr *DbMgr) GatherBlocksFromCache(newBlock *chestnutpb.Block, cached bool, prefix ...string) ([]*chestnutpb.Block, error)

func (*DbMgr) GetAllSchemasByGroup

func (dbMgr *DbMgr) GetAllSchemasByGroup(groupId string, prefix ...string) ([]*chestnutpb.SchemaItem, error)

func (*DbMgr) GetAnnounceProducersByGroup

func (dbMgr *DbMgr) GetAnnounceProducersByGroup(groupId string, prefix ...string) ([]*chestnutpb.AnnounceItem, error)

func (*DbMgr) GetAnnouncedProducer

func (dbMgr *DbMgr) GetAnnouncedProducer(groupId string, pubkey string, prefix ...string) (*chestnutpb.AnnounceItem, error)

func (*DbMgr) GetAnnouncedUsersByGroup

func (dbMgr *DbMgr) GetAnnouncedUsersByGroup(groupId string, prefix ...string) ([]*chestnutpb.AnnounceItem, error)

func (*DbMgr) GetBlkedUsers

func (dbMgr *DbMgr) GetBlkedUsers(prefix ...string) ([]*chestnutpb.DenyUserItem, error)

func (*DbMgr) GetBlock

func (dbMgr *DbMgr) GetBlock(blockId string, cached bool, prefix ...string) (*chestnutpb.Block, error)

get block by block_id

func (*DbMgr) GetBlockHeight

func (dbMgr *DbMgr) GetBlockHeight(blockId string, prefix ...string) (int64, error)

func (*DbMgr) GetGroupsBytes

func (dbMgr *DbMgr) GetGroupsBytes() ([][]byte, error)

Get group list

func (*DbMgr) GetGrpCtnt

func (dbMgr *DbMgr) GetGrpCtnt(groupId string, ctntype string, prefix ...string) ([]*chestnutpb.PostItem, error)

func (*DbMgr) GetParentBlock

func (dbMgr *DbMgr) GetParentBlock(blockId string, prefix ...string) (*chestnutpb.Block, error)

func (*DbMgr) GetProducers

func (dbMgr *DbMgr) GetProducers(groupId string, prefix ...string) ([]*chestnutpb.ProducerItem, error)

func (*DbMgr) GetSchemaByGroup

func (dbMgr *DbMgr) GetSchemaByGroup(groupId, schemaType string, prefix ...string) (*chestnutpb.SchemaItem, error)

func (*DbMgr) GetSubBlock

func (dbMgr *DbMgr) GetSubBlock(blockId string, prefix ...string) ([]*chestnutpb.Block, error)

func (*DbMgr) GetTrx

func (dbMgr *DbMgr) GetTrx(trxId string, prefix ...string) (*chestnutpb.Trx, error)

get trx

func (*DbMgr) IsBlockExist

func (dbMgr *DbMgr) IsBlockExist(blockId string, cached bool, prefix ...string) (bool, error)

check if block existed

func (*DbMgr) IsParentExist

func (dbMgr *DbMgr) IsParentExist(parentBlockId string, cached bool, prefix ...string) (bool, error)

check if parent block existed

func (*DbMgr) IsProducer

func (dbMgr *DbMgr) IsProducer(groupId, producerPubKey string, prefix ...string) (bool, error)

func (*DbMgr) IsProducerAnnounced

func (dbMgr *DbMgr) IsProducerAnnounced(groupId, producerSignPubkey string, prefix ...string) (bool, error)

func (*DbMgr) IsTrxExist

func (dbMgr *DbMgr) IsTrxExist(trxId string, prefix ...string) (bool, error)

func (*DbMgr) IsUser

func (dbMgr *DbMgr) IsUser(groupId, userPubKey string, prefix ...string) (bool, error)

func (*DbMgr) IsUserBlocked

func (dbMgr *DbMgr) IsUserBlocked(groupId, userId string, prefix ...string) (bool, error)

func (*DbMgr) RemoveGroupData

func (dbMgr *DbMgr) RemoveGroupData(item *chestnutpb.GroupItem, prefix ...string) error

func (*DbMgr) RmBlock

func (dbMgr *DbMgr) RmBlock(blockId string, cached bool, prefix ...string) error

remove block

func (*DbMgr) RmGroup

func (dbMgr *DbMgr) RmGroup(item *chestnutpb.GroupItem) error

func (*DbMgr) RmTrx

func (dbMgr *DbMgr) RmTrx(trxId string, prefix ...string) error

UNUSED Remove Trx

func (*DbMgr) TryMigration

func (dbMgr *DbMgr) TryMigration(nodeDataVer int)

func (*DbMgr) UpdGroup

func (dbMgr *DbMgr) UpdGroup(groupItem *chestnutpb.GroupItem) error

func (*DbMgr) UpdTrx

func (dbMgr *DbMgr) UpdTrx(trx *chestnutpb.Trx, prefix ...string) error

func (*DbMgr) UpdateAnnounce

func (dbMgr *DbMgr) UpdateAnnounce(trx *chestnutpb.Trx, prefix ...string) (err error)

func (*DbMgr) UpdateBlkListItem

func (dbMgr *DbMgr) UpdateBlkListItem(trx *chestnutpb.Trx, prefix ...string) (err error)

func (*DbMgr) UpdateProducer

func (dbMgr *DbMgr) UpdateProducer(trx *chestnutpb.Trx, prefix ...string) error

func (*DbMgr) UpdateProducerAnnounceResult

func (dbMgr *DbMgr) UpdateProducerAnnounceResult(groupId, producerSignPubkey string, result bool, prefix ...string) error

func (*DbMgr) UpdateSchema

func (dbMgr *DbMgr) UpdateSchema(trx *chestnutpb.Trx, prefix ...string) (err error)

type Sequence

type Sequence interface {
	Next() (uint64, error)
	Release() error
}

Jump to

Keyboard shortcuts

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