forked from FactomProject/factomd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.go
42 lines (34 loc) · 1.08 KB
/
database.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2017 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package interfaces
type IDatabase interface {
Close() error
Put(bucket, key []byte, data BinaryMarshallable) error
Get(bucket, key []byte, destination BinaryMarshallable) (BinaryMarshallable, error)
Delete(bucket, key []byte) error
ListAllKeys(bucket []byte) ([][]byte, error)
GetAll(bucket []byte, sample BinaryMarshallableAndCopyable) ([]BinaryMarshallableAndCopyable, [][]byte, error)
Clear(bucket []byte) error
PutInBatch(records []Record) error
ListAllBuckets() ([][]byte, error)
Trim()
DoesKeyExist(bucket, key []byte) (bool, error)
}
type Record struct {
Bucket []byte
Key []byte
Data BinaryMarshallable
}
type DatabaseBatchable interface {
BinaryMarshallableAndCopyable
GetDatabaseHeight() uint32
DatabasePrimaryIndex() IHash //block.KeyMR()
DatabaseSecondaryIndex() IHash //block.GetHash()
GetChainID() IHash
}
type DatabaseBlockWithEntries interface {
DatabaseBatchable
GetEntryHashes() []IHash
GetEntrySigHashes() []IHash
}