-
Notifications
You must be signed in to change notification settings - Fork 16
/
database.go
85 lines (83 loc) · 3.3 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
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
package model
import (
"github.com/Qitmeer/qng/common/hash"
"github.com/Qitmeer/qng/core/types"
"github.com/Qitmeer/qng/database/common"
)
type DataBase interface {
Name() string
Init() error
Close()
Rebuild(mgr IndexManager) error
GetInfo() (*common.DatabaseInfo, error)
PutInfo(di *common.DatabaseInfo) error
GetSpendJournal(bh *hash.Hash) ([]byte, error)
PutSpendJournal(bh *hash.Hash, data []byte) error
DeleteSpendJournal(bh *hash.Hash) error
GetUtxo(key []byte) ([]byte, error)
PutUtxo(key []byte, data []byte) error
DeleteUtxo(key []byte) error
ForeachUtxo(fn func(key []byte, data []byte) error) error
UpdateUtxo(opts []*common.UtxoOpt) error
GetTokenState(blockID uint) ([]byte, error)
PutTokenState(blockID uint, data []byte) error
DeleteTokenState(blockID uint) error
GetBestChainState() ([]byte, error)
PutBestChainState(data []byte) error
GetBlock(hash *hash.Hash) (*types.SerializedBlock, error)
GetBlockBytes(hash *hash.Hash) ([]byte, error)
GetHeader(hash *hash.Hash) (*types.BlockHeader, error)
PutBlock(block *types.SerializedBlock) error
HasBlock(hash *hash.Hash) bool
GetDagInfo() ([]byte, error)
PutDagInfo(data []byte) error
GetDAGBlock(blockID uint) ([]byte, error)
PutDAGBlock(blockID uint, data []byte) error
DeleteDAGBlock(blockID uint) error
GetDAGBlockIdByHash(bh *hash.Hash) (uint, error)
PutDAGBlockIdByHash(bh *hash.Hash, id uint) error
DeleteDAGBlockIdByHash(bh *hash.Hash) error
PutMainChainBlock(blockID uint) error
HasMainChainBlock(blockID uint) bool
DeleteMainChainBlock(blockID uint) error
PutBlockIdByOrder(order uint, id uint) error
GetBlockIdByOrder(order uint) (uint, error)
PutDAGTip(id uint, isMain bool) error
GetDAGTips() ([]uint, error)
DeleteDAGTip(id uint) error
PutDiffAnticone(id uint) error
GetDiffAnticones() ([]uint, error)
DeleteDiffAnticone(id uint) error
Get(key []byte) ([]byte, error)
Put(key []byte, value []byte) error
PutTxIdxEntrys(sblock *types.SerializedBlock, block Block) error
GetTxIdxEntry(id *hash.Hash, verbose bool) (*types.Tx, *hash.Hash, error)
DeleteTxIdxEntrys(block *types.SerializedBlock) error
PutTxHashs(block *types.SerializedBlock) error
GetTxIdByHash(fullHash *hash.Hash) (*hash.Hash, error)
DeleteTxHashs(block *types.SerializedBlock) error
IsInvalidTxIdxEmpty() bool
GetInvalidTxIdxTip() (uint64, *hash.Hash, error)
PutInvalidTxIdxTip(order uint64, bh *hash.Hash) error
PutInvalidTxs(sblock *types.SerializedBlock, block Block) error
DeleteInvalidTxs(sblock *types.SerializedBlock, block Block) error
GetInvalidTx(id *hash.Hash) (*types.Transaction, error)
GetInvalidTxIdByHash(fullHash *hash.Hash) (*hash.Hash, error)
CleanInvalidTxIdx() error
GetAddrIdxTip() (*hash.Hash, uint, error)
PutAddrIdxTip(bh *hash.Hash, order uint) error
PutAddrIdx(sblock *types.SerializedBlock, block Block, stxos [][]byte) error
GetTxForAddress(addr types.Address, numToSkip, numRequested uint32, reverse bool) ([]*common.RetrievedTx, uint32, error)
DeleteAddrIdx(sblock *types.SerializedBlock, stxos [][]byte) error
CleanAddrIdx(finish bool) error
IsLegacy() bool
TryUpgrade(di *common.DatabaseInfo, interrupt <-chan struct{}) error
GetEstimateFee() ([]byte, error)
PutEstimateFee(data []byte) error
DeleteEstimateFee() error
Snapshot() error
SnapshotInfo() string
DBEngine() string
StartTrack(info string) error
StopTrack() error
}