taoxDAO

package
v0.0.0-...-b4cfd71 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2019 The Tao Authors This file is part of the Core Tao infrastructure https://tao.network Package taoxDAO provides an interface to work with taox 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) Close

func (db *BatchDatabase) Close()

func (*BatchDatabase) CommitBulk

func (db *BatchDatabase) CommitBulk() error

func (*BatchDatabase) CommitLendingBulk

func (db *BatchDatabase) CommitLendingBulk() 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) 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) Put

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

func (*BatchDatabase) PutObject

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

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) Close

func (db *MongoDatabase) Close()

func (*MongoDatabase) CommitBulk

func (db *MongoDatabase) CommitBulk() error

func (*MongoDatabase) CommitLendingBulk

func (db *MongoDatabase) CommitLendingBulk() 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) 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) Put

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

func (*MongoDatabase) PutObject

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

type TaoXDAO

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

	// 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 taox
	InitBulk()
	CommitBulk() error

	// taox 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
}

Jump to

Keyboard shortcuts

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