sdxxDAO

package
v0.0.0-...-7037f4e Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2019 The Tomochain Authors Copyright 2021 The Sdxchain Authors This file is part of the Core Sdxchain infrastructure https://swapdex.net Package sdxxDAO provides an interface to work with sdxx database, including leveldb for masternode and mongodb for SDK node

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyKey

func EmptyKey() []byte

use alloc to prevent reference manipulation

Types

type Batch

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

func (*Batch) Put

func (b *Batch) Put(key, value []byte) error

func (*Batch) Reset

func (b *Batch) Reset()

func (*Batch) SetCollection

func (b *Batch) SetCollection(collection string)

func (*Batch) ValueSize

func (b *Batch) ValueSize() int

func (*Batch) Write

func (b *Batch) Write() error

type BatchDatabase

type BatchDatabase struct {
	Debug bool
	// contains filtered or unexported fields
}

func NewBatchDatabase

func NewBatchDatabase(datadir string, cacheLimit int) *BatchDatabase

NewBatchDatabase use rlp as encoding

func NewBatchDatabaseWithEncode

func NewBatchDatabaseWithEncode(datadir string, cacheLimit int) *BatchDatabase

batchdatabase is a fast cache db to retrieve in-mem object

func (*BatchDatabase) Ancient

func (db *BatchDatabase) Ancient(kind string, number uint64) ([]byte, error)

Ancient returns an error as we don't have a backing chain freezer.

func (*BatchDatabase) AncientSize

func (db *BatchDatabase) AncientSize(kind string) (uint64, error)

AncientSize returns an error as we don't have a backing chain freezer.

func (*BatchDatabase) Ancients

func (db *BatchDatabase) Ancients() (uint64, error)

Ancients returns an error as we don't have a backing chain freezer.

func (*BatchDatabase) AppendAncient

func (db *BatchDatabase) AppendAncient(number uint64, hash, header, body, receipts, td []byte) error

AppendAncient returns an error as we don't have a backing chain freezer.

func (*BatchDatabase) Close

func (db *BatchDatabase) Close() error

func (*BatchDatabase) CommitBulk

func (db *BatchDatabase) CommitBulk() error

func (*BatchDatabase) CommitLendingBulk

func (db *BatchDatabase) CommitLendingBulk() error

func (*BatchDatabase) Compact

func (db *BatchDatabase) Compact(start []byte, limit []byte) error

func (*BatchDatabase) Delete

func (db *BatchDatabase) Delete(key []byte) error

func (*BatchDatabase) DeleteItemByTxHash

func (db *BatchDatabase) DeleteItemByTxHash(txhash common.Hash, val interface{})

func (*BatchDatabase) DeleteObject

func (db *BatchDatabase) DeleteObject(hash common.Hash, val interface{}) error

func (*BatchDatabase) Get

func (db *BatchDatabase) Get(key []byte) ([]byte, error)

func (*BatchDatabase) GetListItemByHashes

func (db *BatchDatabase) GetListItemByHashes(hashes []string, val interface{}) interface{}

func (*BatchDatabase) GetListItemByTxHash

func (db *BatchDatabase) GetListItemByTxHash(txhash common.Hash, val interface{}) interface{}

func (*BatchDatabase) GetObject

func (db *BatchDatabase) GetObject(hash common.Hash, val interface{}) (interface{}, error)

func (*BatchDatabase) Has

func (db *BatchDatabase) Has(key []byte) (bool, error)

func (*BatchDatabase) HasAncient

func (db *BatchDatabase) HasAncient(kind string, number uint64) (bool, error)

HasAncient returns an error as we don't have a backing chain freezer.

func (*BatchDatabase) HasObject

func (db *BatchDatabase) HasObject(hash common.Hash, val interface{}) (bool, error)

func (*BatchDatabase) InitBulk

func (db *BatchDatabase) InitBulk()

func (*BatchDatabase) InitLendingBulk

func (db *BatchDatabase) InitLendingBulk()

func (*BatchDatabase) IsEmptyKey

func (db *BatchDatabase) IsEmptyKey(key []byte) bool

func (*BatchDatabase) NewBatch

func (db *BatchDatabase) NewBatch() ethdb.Batch

func (*BatchDatabase) NewIterator

func (db *BatchDatabase) NewIterator(prefix []byte, start []byte) ethdb.Iterator

func (*BatchDatabase) Put

func (db *BatchDatabase) Put(key []byte, val []byte) error

func (*BatchDatabase) PutObject

func (db *BatchDatabase) PutObject(hash common.Hash, val interface{}) error

func (*BatchDatabase) Stat

func (db *BatchDatabase) Stat(property string) (string, error)

func (*BatchDatabase) Sync

func (db *BatchDatabase) Sync() error

Sync returns an error as we don't have a backing chain freezer.

func (*BatchDatabase) TruncateAncients

func (db *BatchDatabase) TruncateAncients(items uint64) error

TruncateAncients returns an error as we don't have a backing chain freezer.

type BatchItem

type BatchItem struct {
	Value interface{}
}

type MongoDatabase

type MongoDatabase struct {
	Session *mgo.Session
	// contains filtered or unexported fields
}

func NewMongoDatabase

func NewMongoDatabase(session *mgo.Session, dbName string, mongoURL string, replicaSetName string, cacheLimit int) (*MongoDatabase, error)

InitSession initializes a new session with mongodb

func (*MongoDatabase) Ancient

func (db *MongoDatabase) Ancient(kind string, number uint64) ([]byte, error)

Ancient returns an error as we don't have a backing chain freezer.

func (*MongoDatabase) AncientSize

func (db *MongoDatabase) AncientSize(kind string) (uint64, error)

AncientSize returns an error as we don't have a backing chain freezer.

func (*MongoDatabase) Ancients

func (db *MongoDatabase) Ancients() (uint64, error)

Ancients returns an error as we don't have a backing chain freezer.

func (*MongoDatabase) AppendAncient

func (db *MongoDatabase) AppendAncient(number uint64, hash, header, body, receipts, td []byte) error

AppendAncient returns an error as we don't have a backing chain freezer.

func (*MongoDatabase) Close

func (db *MongoDatabase) Close() error

func (*MongoDatabase) CommitBulk

func (db *MongoDatabase) CommitBulk() error

func (*MongoDatabase) CommitLendingBulk

func (db *MongoDatabase) CommitLendingBulk() error

func (*MongoDatabase) Compact

func (db *MongoDatabase) Compact(start []byte, limit []byte) error

func (*MongoDatabase) Delete

func (db *MongoDatabase) Delete(key []byte) error

func (*MongoDatabase) DeleteItemByTxHash

func (db *MongoDatabase) DeleteItemByTxHash(txhash common.Hash, val interface{})

func (*MongoDatabase) DeleteObject

func (db *MongoDatabase) DeleteObject(hash common.Hash, val interface{}) error

func (*MongoDatabase) EnsureIndexes

func (db *MongoDatabase) EnsureIndexes() error

func (*MongoDatabase) Get

func (db *MongoDatabase) Get(key []byte) ([]byte, error)

func (*MongoDatabase) GetListItemByHashes

func (db *MongoDatabase) GetListItemByHashes(hashes []string, val interface{}) interface{}

func (*MongoDatabase) GetListItemByTxHash

func (db *MongoDatabase) GetListItemByTxHash(txhash common.Hash, val interface{}) interface{}

func (*MongoDatabase) GetObject

func (db *MongoDatabase) GetObject(hash common.Hash, val interface{}) (interface{}, error)

func (*MongoDatabase) Has

func (db *MongoDatabase) Has(key []byte) (bool, error)

func (*MongoDatabase) HasAncient

func (db *MongoDatabase) HasAncient(kind string, number uint64) (bool, error)

HasAncient returns an error as we don't have a backing chain freezer.

func (*MongoDatabase) HasObject

func (db *MongoDatabase) HasObject(hash common.Hash, val interface{}) (bool, error)

func (*MongoDatabase) InitBulk

func (db *MongoDatabase) InitBulk()

func (*MongoDatabase) InitLendingBulk

func (db *MongoDatabase) InitLendingBulk()

func (*MongoDatabase) IsEmptyKey

func (db *MongoDatabase) IsEmptyKey(key []byte) bool

func (*MongoDatabase) NewBatch

func (db *MongoDatabase) NewBatch() ethdb.Batch

func (*MongoDatabase) NewIterator

func (db *MongoDatabase) NewIterator(prefix []byte, start []byte) ethdb.Iterator

func (*MongoDatabase) Put

func (db *MongoDatabase) Put(key []byte, val []byte) error

func (*MongoDatabase) PutObject

func (db *MongoDatabase) PutObject(hash common.Hash, val interface{}) error

func (*MongoDatabase) Stat

func (db *MongoDatabase) Stat(property string) (string, error)

func (*MongoDatabase) Sync

func (db *MongoDatabase) Sync() error

Sync returns an error as we don't have a backing chain freezer.

func (*MongoDatabase) TruncateAncients

func (db *MongoDatabase) TruncateAncients(items uint64) error

TruncateAncients returns an error as we don't have a backing chain freezer.

type SdxXDAO

type SdxXDAO interface {
	// for both leveldb and mongodb
	IsEmptyKey(key []byte) bool
	Close() error

	// mongodb methods
	HasObject(hash common.Hash, val interface{}) (bool, error)
	GetObject(hash common.Hash, val interface{}) (interface{}, error)
	PutObject(hash common.Hash, val interface{}) error
	DeleteObject(hash common.Hash, val interface{}) error // won't return error if key not found
	GetListItemByTxHash(txhash common.Hash, val interface{}) interface{}
	GetListItemByHashes(hashes []string, val interface{}) interface{}
	DeleteItemByTxHash(txhash common.Hash, val interface{})

	// basic sdxx
	InitBulk()
	CommitBulk() error

	// sdxx lending
	InitLendingBulk()
	CommitLendingBulk() error

	// leveldb methods
	Put(key []byte, value []byte) error
	Get(key []byte) ([]byte, error)
	Has(key []byte) (bool, error)
	Delete(key []byte) error
	NewBatch() ethdb.Batch
	HasAncient(kind string, number uint64) (bool, error)
	Ancient(kind string, number uint64) ([]byte, error)
	Ancients() (uint64, error)
	AncientSize(kind string) (uint64, error)
	AppendAncient(number uint64, hash, header, body, receipt, td []byte) error
	TruncateAncients(n uint64) error
	Sync() error
	NewIterator(prefix []byte, start []byte) ethdb.Iterator

	Stat(property string) (string, error)
	Compact(start []byte, limit []byte) error
}

Jump to

Keyboard shortcuts

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