forked from FactomProject/FactomCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.go
More file actions
127 lines (78 loc) · 4.76 KB
/
db.go
File metadata and controls
127 lines (78 loc) · 4.76 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package database
import (
"github.com/FactomProject/FactomCode/notaryapi"
)
// AllShas is a special value that can be used as the final sha when requesting
// a range of shas by height to request them all.
const AllShas = int64(^uint64(0) >> 1)
// Db defines a generic interface that is used to request and insert data into db
type Db interface {
// Close cleanly shuts down the database and syncs all data.
Close() (err error)
// InsertEntry inserts an entry and put it on a process queue
InsertEntryAndQueue(entrySha *notaryapi.Hash, binaryEntry *[]byte, entry *notaryapi.Entry, chainID *[]byte) (err error)
// FetchEntry gets an entry by hash from the database.
FetchEntryByHash(entrySha *notaryapi.Hash) (entry *notaryapi.Entry, err error)
// FetchEBEntriesFromQueue gets all of the ebentries that have not been processed
FetchEBEntriesFromQueue(chainID *[]byte, startTime *[]byte) (ebentries []*notaryapi.EBEntry, err error)
// ProcessEBlockBatche inserts the EBlock and update all it's ebentries in DB
ProcessEBlockBatch(eblock *notaryapi.EBlock) error
// FetchDBEntriesFromQueue gets all of the dbentries that have not been processed
FetchDBEntriesFromQueue(startTime *[]byte) (dbentries []*notaryapi.DBEntry, err error)
// ProcessDBlockBatche inserts the EBlock and update all it's ebentries in DB
ProcessDBlockBatch(block *notaryapi.DBlock) error
// InsertChain inserts the newly created chain into db
InsertChain(chain *notaryapi.EChain) (err error)
// FetchEBInfoByHash gets a chain by chainID
FetchChainByHash(chainID *notaryapi.Hash) (chain *notaryapi.EChain, err error)
// FetchChainByName gets a chain by chain name
FetchChainByName(chainName [][]byte) (chain *notaryapi.EChain, err error)
// RollbackClose discards the recent database changes to the previously
// saved data at last Sync and closes the database.
RollbackClose() (err error)
// Sync verifies that the database is coherent on disk and no
// outstanding transactions are in flight.
Sync() (err error)
// FetchAllChainByName gets all of the chains under the path - name
FetchAllChainsByName(chainName [][]byte) (chains *[]notaryapi.EChain, err error)
// Insert the Factom Block meta data into db
//InsertFBInfo(fbHash *notaryapi.Hash, fbInfo *notaryapi.FBInfo) (err error)
// Insert the Directory Block meta data into db
InsertDBBatch(fbBatch *notaryapi.DBBatch) (err error)
// FetchEBInfoByHash gets an EBInfo obj
FetchEBInfoByHash(ebHash *notaryapi.Hash) (ebInfo *notaryapi.EBInfo, err error)
// FetchFBInfoByHash gets an FBInfo obj
//FetchFBInfoByHash(fbHash *notaryapi.Hash) (fbInfo *notaryapi.FBInfo, err error)
// FetchDBBatchByHash gets an FBBatch obj
FetchDBBatchByHash(fbHash *notaryapi.Hash) (fbBatch *notaryapi.DBBatch, err error)
// FetchEntryInfoBranchByHash gets an EntryInfo obj
FetchEntryInfoByHash(entryHash *notaryapi.Hash) (entryInfo *notaryapi.EntryInfo, err error)
// FetchEntryInfoBranchByHash gets an EntryInfoBranch obj
FetchEntryInfoBranchByHash(entryHash *notaryapi.Hash) (entryInfoBranch *notaryapi.EntryInfoBranch, err error)
// FetchEntryBlock gets an entry by hash from the database.
FetchEBlockByHash(eBlockHash *notaryapi.Hash) (eBlock *notaryapi.EBlock, err error)
// FetchEBlockByMR gets an entry block by merkle root from the database.
FetchEBlockByMR(eBMR *notaryapi.Hash) (eBlock *notaryapi.EBlock, err error)
// FetchEBHashByMR gets an entry by hash from the database.
FetchEBHashByMR(eBMR *notaryapi.Hash) (eBlockHash *notaryapi.Hash, err error)
// FetchAllEBlocksByChain gets all of the blocks by chain id
FetchAllEBlocksByChain(chainID *notaryapi.Hash) (eBlocks *[]notaryapi.EBlock, err error)
// FetchAllEBInfosByChain gets all of the entry block infos by chain id
FetchAllEBInfosByChain(chainID *notaryapi.Hash) (eBInfos *[]notaryapi.EBInfo, err error)
// FetchDBlock gets an entry by hash from the database.
FetchDBlockByHash(dBlockHash *notaryapi.Hash) (dBlock *notaryapi.DBlock, err error)
// FetchAllFBInfo gets all of the fbInfo
FetchAllDBlocks() (fBlocks []notaryapi.DBlock, err error)
// FetchDBInfoByHash gets all db records related to a directory block
FetchAllDBRecordsByDBHash(dbHash *notaryapi.Hash) (ldbMap map[string]string, err error)
// InsertAllDBRecords inserts all key value pairs from map into db
InsertAllDBRecords(ldbMap map[string]string) (err error)
// FetchSupportDBRecords gets support db records
FetchSupportDBRecords() (ldbMap map[string]string, err error)
//---------------------------
Put(key []byte, value []byte) error
Get(key []byte) ([]byte, error)
Delete(key []byte) error
LastKnownTD() []byte
Print()
}