Documentation ¶
Index ¶
- Variables
- type Manager
- func (m *Manager) AddBucket(bucket string) bool
- func (m *Manager) AddLabel(label string) bool
- func (m *Manager) BeginBatch()
- func (m *Manager) Close()
- func (m Manager) Copy(AppID []byte) *Manager
- func (m *Manager) CurrentAppID() (appID []byte)
- func (m *Manager) EndBatch()
- func (m *Manager) Get(Bucket, Label string, key []byte) (value []byte)
- func (m *Manager) GetCount() int64
- func (m *Manager) GetIndex(element []byte) int64
- func (m *Manager) GetInt64(Bucket, Label string, key []byte) (value int64)
- func (m *Manager) GetKey(Bucket, Label string, key []byte) (DBKey [storage.KeyLength]byte)
- func (m *Manager) GetString(Bucket, Label string, key []byte) (value string)
- func (m *Manager) Init(databaseTag, filename string) error
- func (m *Manager) Put(Bucket, Label string, key []byte, value []byte) (err error)
- func (m *Manager) PutBatch(Bucket, Label string, key []byte, value []byte) error
- func (m *Manager) PutInt64(Bucket, Label string, key []byte, value int64) error
- func (m *Manager) PutString(Bucket, Label string, key []byte, value string) error
- func (m Manager) SetAppID(appID []byte)
- type TXList
Constants ¶
This section is empty.
Variables ¶
var AppIDMutex sync.Mutex // Creating new AppIDs has to be atomic
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { DB storage.KeyValueDB // Underlying database implementation AppID []byte // Allows apps to share a database Buckets map[string]byte // one byte to indicate a bucket Labels map[string]byte // one byte to indicate a label TXList TXList // Transaction List }
func NewDBManager ¶ added in v0.0.20
NewDBManager Create and initialize a new database manager
func (*Manager) AddBucket ¶
AddBucket Add a bucket to be used in the database. Initializing a database requires that buckets and labels be added in the correct order. Returns true if the bucket is added Returns false if the bucket exists Panics if the bucket limit is reached
func (*Manager) AddLabel ¶ added in v0.0.18
AddLabel Add a Label to be used in the database. Initializing a database requires that buckets and labels be added in the correct order.
func (*Manager) BeginBatch ¶ added in v0.0.14
func (m *Manager) BeginBatch()
BeginBatch initializes the batch list to empty. Note that we really only support one level of batch processing.
func (*Manager) Close ¶
func (m *Manager) Close()
Close Do any cleanup required to close the manager
func (Manager) Copy ¶ added in v0.0.20
Copy Create a copy of the manager that uses the given AppID. the AppID allows multiple Merkle Trees to be managed within the same database. All keys for a particular merkle tree are salted with their particular AppID. Note that maps are pointers, so Buckets and Labels are shared over copies of the Manager but not include elements from processes using their own AppID.
func (*Manager) CurrentAppID ¶ added in v0.0.24
CurrentAppID Return the current appID used by the MerkleManager
func (*Manager) EndBatch ¶ added in v0.0.14
func (m *Manager) EndBatch()
EndBatch Flush anything in the batch list to the database.
func (*Manager) Get ¶
Get Get a []byte value from the underlying database. Returns a nil if not found, or on an error
func (*Manager) GetCount ¶ added in v0.0.16
GetCount The number of elements as recorded in the Database. As a side effect, the any pending transactions in the batch process will be flushed to the database
func (*Manager) GetIndex ¶
GetIndex Return the int64 value tied to the element hash in the ElementIndex bucket
func (*Manager) GetInt64 ¶
GetInt64 Get a string value from the underlying database. Returns a MinInt64 if not found, or on an error
func (*Manager) GetKey ¶
GetKey Given a Bucket Name, a Label name, and a key, GetKey returns a single key to be used in a key/value database. Note that the use of the AppID means parallel managers for different Merkle Trees can still share a database.
func (*Manager) GetString ¶
GetString Get a string value from the underlying database. Returns a nil if not found, or on an error
func (*Manager) Init ¶
Init Initialize the Manager with a specified underlying database. databaseTag can currently be either badger or memory. The filename indicates where the database is persisted (ignored by memory).PendingChain
func (*Manager) PutBatch ¶ added in v0.0.14
PutBatch put the write of a key value into the pending batch. These will all be written to the database together.
func (Manager) SetAppID ¶ added in v0.0.24
SetAppID Set a AppID (possibly replacing an existing AppID) to this manager. This allows the use of the same database to be shared by applications/uses without overlap
Note the use of an AppID is managed in the database outside of manager. First the AppID must be cleared to access the AppID tracking key/values, i.e. the AppID bucket and its labels. Then the AppID can be set so the appropriate buckets can be accessed under the AppID