• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision027b55d0813d39974591c0bdcd803bf07834d7cd (tree)
Time2019-07-08 13:46:40
AuthorChengcheng Zhang <943420582@qq.c...>
CommiterChengcheng Zhang

Log Message

move db wallet store prefix

Change Summary

Incremental Difference

--- a/account/utxo_keeper_test.go
+++ b/account/utxo_keeper_test.go
@@ -1330,6 +1330,33 @@ var (
13301330 AccountIndexPrefix = append(accountStore, accountIndexPrefix, colon)
13311331 )
13321332
1333+const (
1334+ sutxoPrefix byte = iota //SUTXOPrefix is ContractUTXOKey prefix
1335+ accountAliasPrefix
1336+ txPrefix //TxPrefix is wallet database transactions prefix
1337+ txIndexPrefix //TxIndexPrefix is wallet database tx index prefix
1338+ unconfirmedTxPrefix //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
1339+ globalTxIndexPrefix //GlobalTxIndexPrefix is wallet database global tx index prefix
1340+ walletKey
1341+ miningAddressKey
1342+ coinbaseAbKey
1343+ recoveryKey //recoveryKey key for db store recovery info.
1344+)
1345+
1346+var (
1347+ walletStore = []byte("WS:")
1348+ SUTXOPrefix = append(walletStore, sutxoPrefix, colon)
1349+ AccountAliasPrefix = append(walletStore, accountAliasPrefix, colon)
1350+ TxPrefix = append(walletStore, txPrefix, colon) //TxPrefix is wallet database transactions prefix
1351+ TxIndexPrefix = append(walletStore, txIndexPrefix, colon) //TxIndexPrefix is wallet database tx index prefix
1352+ UnconfirmedTxPrefix = append(walletStore, unconfirmedTxPrefix, colon) //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
1353+ GlobalTxIndexPrefix = append(walletStore, globalTxIndexPrefix, colon) //GlobalTxIndexPrefix is wallet database global tx index prefix
1354+ WalletKey = append(walletStore, walletKey)
1355+ MiningAddressKey = append(walletStore, miningAddressKey)
1356+ CoinbaseAbKey = append(walletStore, coinbaseAbKey)
1357+ RecoveryKey = append(walletStore, recoveryKey)
1358+)
1359+
13331360 type mockAccountStore struct {
13341361 db dbm.DB
13351362 batch dbm.Batch
@@ -1350,7 +1377,7 @@ func StandardUTXOKey(id bc.Hash) []byte {
13501377
13511378 // ContractUTXOKey makes a smart contract unspent outputs key to store
13521379 func ContractUTXOKey(id bc.Hash) []byte {
1353- return append(dbm.SUTXOPrefix, id.Bytes()...)
1380+ return append(SUTXOPrefix, id.Bytes()...)
13541381 }
13551382
13561383 func (store *mockAccountStore) InitBatch() error { return nil }
--- a/database/account_store.go
+++ b/database/account_store.go
@@ -221,7 +221,7 @@ func (store *AccountStore) GetBip44ContractIndex(accountID string, change bool)
221221
222222 // GetCoinbaseArbitrary get coinbase arbitrary
223223 func (store *AccountStore) GetCoinbaseArbitrary() []byte {
224- return store.db.Get(dbm.CoinbaseAbKey)
224+ return store.db.Get(CoinbaseAbKey)
225225 }
226226
227227 // GetContractIndex get contract index
@@ -250,7 +250,7 @@ func (store *AccountStore) GetControlProgram(hash bc.Hash) (*acc.CtrlProgram, er
250250
251251 // GetMiningAddress get mining address
252252 func (store *AccountStore) GetMiningAddress() (*acc.CtrlProgram, error) {
253- rawCP := store.db.Get(dbm.MiningAddressKey)
253+ rawCP := store.db.Get(MiningAddressKey)
254254 if rawCP == nil {
255255 return nil, acc.ErrFindMiningAddress
256256 }
@@ -373,9 +373,9 @@ func (store *AccountStore) SetBip44ContractIndex(accountID string, change bool,
373373 // SetCoinbaseArbitrary set coinbase arbitrary
374374 func (store *AccountStore) SetCoinbaseArbitrary(arbitrary []byte) {
375375 if store.batch == nil {
376- store.db.Set(dbm.CoinbaseAbKey, arbitrary)
376+ store.db.Set(CoinbaseAbKey, arbitrary)
377377 } else {
378- store.batch.Set(dbm.CoinbaseAbKey, arbitrary)
378+ store.batch.Set(CoinbaseAbKey, arbitrary)
379379 }
380380 }
381381
@@ -410,9 +410,9 @@ func (store *AccountStore) SetMiningAddress(program *acc.CtrlProgram) error {
410410 }
411411
412412 if store.batch == nil {
413- store.db.Set(dbm.MiningAddressKey, rawProgram)
413+ store.db.Set(MiningAddressKey, rawProgram)
414414 } else {
415- store.batch.Set(dbm.MiningAddressKey, rawProgram)
415+ store.batch.Set(MiningAddressKey, rawProgram)
416416 }
417417 return nil
418418 }
--- a/database/leveldb/db.go
+++ b/database/leveldb/db.go
@@ -39,34 +39,6 @@ type Iterator interface {
3939 //-----------------------------------------------------------------------------
4040
4141 const (
42- sutxoPrefix byte = iota //SUTXOPrefix is ContractUTXOKey prefix
43- accountAliasPrefix
44- txPrefix //TxPrefix is wallet database transactions prefix
45- txIndexPrefix //TxIndexPrefix is wallet database tx index prefix
46- unconfirmedTxPrefix //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
47- globalTxIndexPrefix //GlobalTxIndexPrefix is wallet database global tx index prefix
48- walletKey
49- miningAddressKey
50- coinbaseAbKey
51- recoveryKey //recoveryKey key for db store recovery info.
52-)
53-
54-var (
55- colon byte = 0x3a
56- walletStore = []byte("WS:")
57- SUTXOPrefix = append(walletStore, sutxoPrefix, colon)
58- AccountAliasPrefix = append(walletStore, accountAliasPrefix, colon)
59- TxPrefix = append(walletStore, txPrefix, colon) //TxPrefix is wallet database transactions prefix
60- TxIndexPrefix = append(walletStore, txIndexPrefix, colon) //TxIndexPrefix is wallet database tx index prefix
61- UnconfirmedTxPrefix = append(walletStore, unconfirmedTxPrefix, colon) //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
62- GlobalTxIndexPrefix = append(walletStore, globalTxIndexPrefix, colon) //GlobalTxIndexPrefix is wallet database global tx index prefix
63- WalletKey = append(walletStore, walletKey)
64- MiningAddressKey = append(walletStore, miningAddressKey)
65- CoinbaseAbKey = append(walletStore, coinbaseAbKey)
66- RecoveryKey = append(walletStore, recoveryKey)
67-)
68-
69-const (
7042 LevelDBBackendStr = "leveldb" // legacy, defaults to goleveldb.
7143 CLevelDBBackendStr = "cleveldb"
7244 GoLevelDBBackendStr = "goleveldb"
--- a/database/wallet_store.go
+++ b/database/wallet_store.go
@@ -17,6 +17,33 @@ import (
1717 "github.com/vapor/wallet"
1818 )
1919
20+const (
21+ sutxoPrefix byte = iota //SUTXOPrefix is ContractUTXOKey prefix
22+ accountAliasPrefix
23+ txPrefix //TxPrefix is wallet database transactions prefix
24+ txIndexPrefix //TxIndexPrefix is wallet database tx index prefix
25+ unconfirmedTxPrefix //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
26+ globalTxIndexPrefix //GlobalTxIndexPrefix is wallet database global tx index prefix
27+ walletKey
28+ miningAddressKey
29+ coinbaseAbKey
30+ recoveryKey //recoveryKey key for db store recovery info.
31+)
32+
33+var (
34+ walletStore = []byte("WS:")
35+ SUTXOPrefix = append(walletStore, sutxoPrefix, colon)
36+ AccountAliasPrefix = append(walletStore, accountAliasPrefix, colon)
37+ TxPrefix = append(walletStore, txPrefix, colon) //TxPrefix is wallet database transactions prefix
38+ TxIndexPrefix = append(walletStore, txIndexPrefix, colon) //TxIndexPrefix is wallet database tx index prefix
39+ UnconfirmedTxPrefix = append(walletStore, unconfirmedTxPrefix, colon) //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
40+ GlobalTxIndexPrefix = append(walletStore, globalTxIndexPrefix, colon) //GlobalTxIndexPrefix is wallet database global tx index prefix
41+ WalletKey = append(walletStore, walletKey)
42+ MiningAddressKey = append(walletStore, miningAddressKey)
43+ CoinbaseAbKey = append(walletStore, coinbaseAbKey)
44+ RecoveryKey = append(walletStore, recoveryKey)
45+)
46+
2047 // errors
2148 var (
2249 errAccntTxIDNotFound = errors.New("account TXID not found")
@@ -25,27 +52,27 @@ var (
2552
2653 // ContractUTXOKey makes a smart contract unspent outputs key to store
2754 func ContractUTXOKey(id bc.Hash) []byte {
28- return append(dbm.SUTXOPrefix, id.Bytes()...)
55+ return append(SUTXOPrefix, id.Bytes()...)
2956 }
3057
3158 func calcDeleteKey(blockHeight uint64) []byte {
32- return []byte(fmt.Sprintf("%s%016x", dbm.TxPrefix, blockHeight))
59+ return []byte(fmt.Sprintf("%s%016x", TxPrefix, blockHeight))
3360 }
3461
3562 func calcTxIndexKey(txID string) []byte {
36- return append(dbm.TxIndexPrefix, []byte(txID)...)
63+ return append(TxIndexPrefix, []byte(txID)...)
3764 }
3865
3966 func calcAnnotatedKey(formatKey string) []byte {
40- return append(dbm.TxPrefix, []byte(formatKey)...)
67+ return append(TxPrefix, []byte(formatKey)...)
4168 }
4269
4370 func calcUnconfirmedTxKey(formatKey string) []byte {
44- return append(dbm.UnconfirmedTxPrefix, []byte(formatKey)...)
71+ return append(UnconfirmedTxPrefix, []byte(formatKey)...)
4572 }
4673
4774 func CalcGlobalTxIndexKey(txID string) []byte {
48- return append(dbm.GlobalTxIndexPrefix, []byte(txID)...)
75+ return append(GlobalTxIndexPrefix, []byte(txID)...)
4976 }
5077
5178 func CalcGlobalTxIndex(blockHash *bc.Hash, position uint64) []byte {
@@ -64,7 +91,7 @@ func contractIndexKey(accountID string) []byte {
6491 }
6592
6693 func accountAliasKey(name string) []byte {
67- return append(dbm.AccountAliasPrefix, []byte(name)...)
94+ return append(AccountAliasPrefix, []byte(name)...)
6895 }
6996
7097 // WalletStore store wallet using leveldb
@@ -114,9 +141,9 @@ func (store *WalletStore) DeleteContractUTXO(outputID bc.Hash) {
114141 // DeleteRecoveryStatus delete recovery status
115142 func (store *WalletStore) DeleteRecoveryStatus() {
116143 if store.batch == nil {
117- store.db.Delete(dbm.RecoveryKey)
144+ store.db.Delete(RecoveryKey)
118145 } else {
119- store.batch.Delete(dbm.RecoveryKey)
146+ store.batch.Delete(RecoveryKey)
120147 }
121148 }
122149
@@ -158,14 +185,14 @@ func (store *WalletStore) DeleteWalletTransactions() {
158185 if store.batch != nil {
159186 batch = store.batch
160187 }
161- txIter := store.db.IteratorPrefix(dbm.TxPrefix)
188+ txIter := store.db.IteratorPrefix(TxPrefix)
162189 defer txIter.Release()
163190
164191 for txIter.Next() {
165192 batch.Delete(txIter.Key())
166193 }
167194
168- txIndexIter := store.db.IteratorPrefix(dbm.TxIndexPrefix)
195+ txIndexIter := store.db.IteratorPrefix(TxIndexPrefix)
169196 defer txIndexIter.Release()
170197
171198 for txIndexIter.Next() {
@@ -190,7 +217,7 @@ func (store *WalletStore) DeleteWalletUTXOs() {
190217 batch.Delete(ruIter.Key())
191218 }
192219
193- suIter := store.db.IteratorPrefix(dbm.SUTXOPrefix)
220+ suIter := store.db.IteratorPrefix(SUTXOPrefix)
194221 defer suIter.Release()
195222
196223 for suIter.Next() {
@@ -276,7 +303,7 @@ func (store *WalletStore) GetUnconfirmedTransaction(txID string) (*query.Annotat
276303
277304 // GetRecoveryStatus delete recovery status
278305 func (store *WalletStore) GetRecoveryStatus() (*wallet.RecoveryState, error) {
279- rawStatus := store.db.Get(dbm.RecoveryKey)
306+ rawStatus := store.db.Get(RecoveryKey)
280307 if rawStatus == nil {
281308 return nil, wallet.ErrGetRecoveryStatus
282309 }
@@ -291,7 +318,7 @@ func (store *WalletStore) GetRecoveryStatus() (*wallet.RecoveryState, error) {
291318
292319 // GetWalletInfo get wallet information
293320 func (store *WalletStore) GetWalletInfo() (*wallet.StatusInfo, error) {
294- rawStatus := store.db.Get(dbm.WalletKey)
321+ rawStatus := store.db.Get(WalletKey)
295322 if rawStatus == nil {
296323 return nil, wallet.ErrGetWalletStatusInfo
297324 }
@@ -308,7 +335,7 @@ func (store *WalletStore) GetWalletInfo() (*wallet.StatusInfo, error) {
308335 func (store *WalletStore) ListAccountUTXOs(id string, isSmartContract bool) ([]*acc.UTXO, error) {
309336 prefix := UTXOPrefix
310337 if isSmartContract {
311- prefix = dbm.SUTXOPrefix
338+ prefix = SUTXOPrefix
312339 }
313340
314341 idBytes, err := hex.DecodeString(id)
@@ -334,7 +361,7 @@ func (store *WalletStore) ListAccountUTXOs(id string, isSmartContract bool) ([]*
334361 func (store *WalletStore) ListTransactions(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error) {
335362 annotatedTxs := []*query.AnnotatedTx{}
336363 var startKey []byte
337- preFix := dbm.TxPrefix
364+ preFix := TxPrefix
338365
339366 if StartTxID != "" {
340367 if unconfirmed {
@@ -350,7 +377,7 @@ func (store *WalletStore) ListTransactions(accountID string, StartTxID string, c
350377 }
351378
352379 if unconfirmed {
353- preFix = dbm.UnconfirmedTxPrefix
380+ preFix = UnconfirmedTxPrefix
354381 }
355382
356383 itr := store.db.IteratorPrefixWithStart(preFix, startKey, true)
@@ -371,7 +398,7 @@ func (store *WalletStore) ListTransactions(accountID string, StartTxID string, c
371398 // ListUnconfirmedTransactions get all unconfirmed txs
372399 func (store *WalletStore) ListUnconfirmedTransactions() ([]*query.AnnotatedTx, error) {
373400 annotatedTxs := []*query.AnnotatedTx{}
374- txIter := store.db.IteratorPrefix(dbm.UnconfirmedTxPrefix)
401+ txIter := store.db.IteratorPrefix(UnconfirmedTxPrefix)
375402 defer txIter.Release()
376403
377404 for txIter.Next() {
@@ -426,9 +453,9 @@ func (store *WalletStore) SetRecoveryStatus(recoveryState *wallet.RecoveryState)
426453 }
427454
428455 if store.batch == nil {
429- store.db.Set(dbm.RecoveryKey, rawStatus)
456+ store.db.Set(RecoveryKey, rawStatus)
430457 } else {
431- store.batch.Set(dbm.RecoveryKey, rawStatus)
458+ store.batch.Set(RecoveryKey, rawStatus)
432459 }
433460 return nil
434461 }
@@ -477,9 +504,9 @@ func (store *WalletStore) SetWalletInfo(status *wallet.StatusInfo) error {
477504 }
478505
479506 if store.batch == nil {
480- store.db.Set(dbm.WalletKey, rawWallet)
507+ store.db.Set(WalletKey, rawWallet)
481508 } else {
482- store.batch.Set(dbm.WalletKey, rawWallet)
509+ store.batch.Set(WalletKey, rawWallet)
483510 }
484511 return nil
485512 }
--- a/wallet/wallet_test.go
+++ b/wallet/wallet_test.go
@@ -186,6 +186,33 @@ var (
186186 AccountIndexPrefix = append(accountStore, accountIndexPrefix, colon)
187187 )
188188
189+const (
190+ sutxoPrefix byte = iota //SUTXOPrefix is ContractUTXOKey prefix
191+ accountAliasPrefix
192+ txPrefix //TxPrefix is wallet database transactions prefix
193+ txIndexPrefix //TxIndexPrefix is wallet database tx index prefix
194+ unconfirmedTxPrefix //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
195+ globalTxIndexPrefix //GlobalTxIndexPrefix is wallet database global tx index prefix
196+ walletKey
197+ miningAddressKey
198+ coinbaseAbKey
199+ recoveryKey //recoveryKey key for db store recovery info.
200+)
201+
202+var (
203+ walletStore = []byte("WS:")
204+ SUTXOPrefix = append(walletStore, sutxoPrefix, colon)
205+ AccountAliasPrefix = append(walletStore, accountAliasPrefix, colon)
206+ TxPrefix = append(walletStore, txPrefix, colon) //TxPrefix is wallet database transactions prefix
207+ TxIndexPrefix = append(walletStore, txIndexPrefix, colon) //TxIndexPrefix is wallet database tx index prefix
208+ UnconfirmedTxPrefix = append(walletStore, unconfirmedTxPrefix, colon) //UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
209+ GlobalTxIndexPrefix = append(walletStore, globalTxIndexPrefix, colon) //GlobalTxIndexPrefix is wallet database global tx index prefix
210+ WalletKey = append(walletStore, walletKey)
211+ MiningAddressKey = append(walletStore, miningAddressKey)
212+ CoinbaseAbKey = append(walletStore, coinbaseAbKey)
213+ RecoveryKey = append(walletStore, recoveryKey)
214+)
215+
189216 func accountIndexKey(xpubs []chainkd.XPub) []byte {
190217 var hash [32]byte
191218 var xPubs []byte
@@ -223,27 +250,27 @@ func StandardUTXOKey(id bc.Hash) []byte {
223250
224251 // ContractUTXOKey makes a smart contract unspent outputs key to store
225252 func ContractUTXOKey(id bc.Hash) []byte {
226- return append(dbm.SUTXOPrefix, id.Bytes()...)
253+ return append(SUTXOPrefix, id.Bytes()...)
227254 }
228255
229256 func calcDeleteKey(blockHeight uint64) []byte {
230- return []byte(fmt.Sprintf("%s%016x", dbm.TxPrefix, blockHeight))
257+ return []byte(fmt.Sprintf("%s%016x", TxPrefix, blockHeight))
231258 }
232259
233260 func calcTxIndexKey(txID string) []byte {
234- return append(dbm.TxIndexPrefix, []byte(txID)...)
261+ return append(TxIndexPrefix, []byte(txID)...)
235262 }
236263
237264 func calcAnnotatedKey(formatKey string) []byte {
238- return append(dbm.TxPrefix, []byte(formatKey)...)
265+ return append(TxPrefix, []byte(formatKey)...)
239266 }
240267
241268 func calcUnconfirmedTxKey(formatKey string) []byte {
242- return append(dbm.UnconfirmedTxPrefix, []byte(formatKey)...)
269+ return append(UnconfirmedTxPrefix, []byte(formatKey)...)
243270 }
244271
245272 func CalcGlobalTxIndexKey(txID string) []byte {
246- return append(dbm.GlobalTxIndexPrefix, []byte(txID)...)
273+ return append(GlobalTxIndexPrefix, []byte(txID)...)
247274 }
248275
249276 func CalcGlobalTxIndex(blockHash *bc.Hash, position uint64) []byte {
@@ -262,7 +289,7 @@ func contractIndexKey(accountID string) []byte {
262289 }
263290
264291 func accountAliasKey(name string) []byte {
265- return append([]byte(dbm.AccountAliasPrefix), []byte(name)...)
292+ return append([]byte(AccountAliasPrefix), []byte(name)...)
266293 }
267294
268295 // MockWalletStore store wallet using leveldb
@@ -310,9 +337,9 @@ func (store *MockWalletStore) DeleteContractUTXO(outputID bc.Hash) {
310337 // DeleteRecoveryStatus delete recovery status
311338 func (store *MockWalletStore) DeleteRecoveryStatus() {
312339 if store.batch == nil {
313- store.db.Delete(dbm.RecoveryKey)
340+ store.db.Delete(RecoveryKey)
314341 } else {
315- store.batch.Delete(dbm.RecoveryKey)
342+ store.batch.Delete(RecoveryKey)
316343 }
317344 }
318345
@@ -352,14 +379,14 @@ func (store *MockWalletStore) DeleteWalletTransactions() {
352379 if store.batch != nil {
353380 batch = store.batch
354381 }
355- txIter := store.db.IteratorPrefix([]byte(dbm.TxPrefix))
382+ txIter := store.db.IteratorPrefix([]byte(TxPrefix))
356383 defer txIter.Release()
357384
358385 for txIter.Next() {
359386 batch.Delete(txIter.Key())
360387 }
361388
362- txIndexIter := store.db.IteratorPrefix([]byte(dbm.TxIndexPrefix))
389+ txIndexIter := store.db.IteratorPrefix([]byte(TxIndexPrefix))
363390 defer txIndexIter.Release()
364391
365392 for txIndexIter.Next() {
@@ -382,7 +409,7 @@ func (store *MockWalletStore) DeleteWalletUTXOs() {
382409 batch.Delete(ruIter.Key())
383410 }
384411
385- suIter := store.db.IteratorPrefix([]byte(dbm.SUTXOPrefix))
412+ suIter := store.db.IteratorPrefix([]byte(SUTXOPrefix))
386413 defer suIter.Release()
387414 for suIter.Next() {
388415 batch.Delete(suIter.Key())
@@ -459,7 +486,7 @@ func (store *MockWalletStore) GetUnconfirmedTransaction(txID string) (*query.Ann
459486
460487 // GetRecoveryStatus delete recovery status
461488 func (store *MockWalletStore) GetRecoveryStatus() (*RecoveryState, error) {
462- rawStatus := store.db.Get(dbm.RecoveryKey)
489+ rawStatus := store.db.Get(RecoveryKey)
463490 if rawStatus == nil {
464491 return nil, ErrGetRecoveryStatus
465492 }
@@ -472,7 +499,7 @@ func (store *MockWalletStore) GetRecoveryStatus() (*RecoveryState, error) {
472499
473500 // GetWalletInfo get wallet information
474501 func (store *MockWalletStore) GetWalletInfo() (*StatusInfo, error) {
475- rawStatus := store.db.Get([]byte(dbm.WalletKey))
502+ rawStatus := store.db.Get([]byte(WalletKey))
476503 if rawStatus == nil {
477504 return nil, fmt.Errorf("failed get wallet info")
478505 }
@@ -487,7 +514,7 @@ func (store *MockWalletStore) GetWalletInfo() (*StatusInfo, error) {
487514 func (store *MockWalletStore) ListAccountUTXOs(id string, isSmartContract bool) ([]*acc.UTXO, error) {
488515 prefix := UTXOPrefix
489516 if isSmartContract {
490- prefix = dbm.SUTXOPrefix
517+ prefix = SUTXOPrefix
491518 }
492519
493520 idBytes, err := hex.DecodeString(id)
@@ -513,7 +540,7 @@ func (store *MockWalletStore) ListAccountUTXOs(id string, isSmartContract bool)
513540 func (store *MockWalletStore) ListTransactions(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error) {
514541 annotatedTxs := []*query.AnnotatedTx{}
515542 var startKey []byte
516- preFix := dbm.TxPrefix
543+ preFix := TxPrefix
517544
518545 if StartTxID != "" {
519546 if unconfirmed {
@@ -528,7 +555,7 @@ func (store *MockWalletStore) ListTransactions(accountID string, StartTxID strin
528555 }
529556
530557 if unconfirmed {
531- preFix = dbm.UnconfirmedTxPrefix
558+ preFix = UnconfirmedTxPrefix
532559 }
533560
534561 itr := store.db.IteratorPrefixWithStart([]byte(preFix), startKey, true)
@@ -548,7 +575,7 @@ func (store *MockWalletStore) ListTransactions(accountID string, StartTxID strin
548575 // ListUnconfirmedTransactions get all unconfirmed txs
549576 func (store *MockWalletStore) ListUnconfirmedTransactions() ([]*query.AnnotatedTx, error) {
550577 annotatedTxs := []*query.AnnotatedTx{}
551- txIter := store.db.IteratorPrefix([]byte(dbm.UnconfirmedTxPrefix))
578+ txIter := store.db.IteratorPrefix([]byte(UnconfirmedTxPrefix))
552579 defer txIter.Release()
553580
554581 for txIter.Next() {
@@ -600,9 +627,9 @@ func (store *MockWalletStore) SetRecoveryStatus(recoveryState *RecoveryState) er
600627 return err
601628 }
602629 if store.batch == nil {
603- store.db.Set(dbm.RecoveryKey, rawStatus)
630+ store.db.Set(RecoveryKey, rawStatus)
604631 } else {
605- store.batch.Set(dbm.RecoveryKey, rawStatus)
632+ store.batch.Set(RecoveryKey, rawStatus)
606633 }
607634 return nil
608635 }
@@ -649,9 +676,9 @@ func (store *MockWalletStore) SetWalletInfo(status *StatusInfo) error {
649676 }
650677
651678 if store.batch == nil {
652- store.db.Set([]byte(dbm.WalletKey), rawWallet)
679+ store.db.Set([]byte(WalletKey), rawWallet)
653680 } else {
654- store.batch.Set([]byte(dbm.WalletKey), rawWallet)
681+ store.batch.Set([]byte(WalletKey), rawWallet)
655682 }
656683 return nil
657684 }
@@ -806,7 +833,7 @@ func (store *MockAccountStore) GetBip44ContractIndex(accountID string, change bo
806833
807834 // GetCoinbaseArbitrary get coinbase arbitrary
808835 func (store *MockAccountStore) GetCoinbaseArbitrary() []byte {
809- return store.db.Get([]byte(dbm.CoinbaseAbKey))
836+ return store.db.Get([]byte(CoinbaseAbKey))
810837 }
811838
812839 // GetContractIndex get contract index
@@ -833,7 +860,7 @@ func (store *MockAccountStore) GetControlProgram(hash bc.Hash) (*acc.CtrlProgram
833860
834861 // GetMiningAddress get mining address
835862 func (store *MockAccountStore) GetMiningAddress() (*acc.CtrlProgram, error) {
836- rawCP := store.db.Get([]byte(dbm.MiningAddressKey))
863+ rawCP := store.db.Get([]byte(MiningAddressKey))
837864 if rawCP == nil {
838865 return nil, acc.ErrFindMiningAddress
839866 }
@@ -949,9 +976,9 @@ func (store *MockAccountStore) SetBip44ContractIndex(accountID string, change bo
949976 // SetCoinbaseArbitrary set coinbase arbitrary
950977 func (store *MockAccountStore) SetCoinbaseArbitrary(arbitrary []byte) {
951978 if store.batch == nil {
952- store.db.Set([]byte(dbm.CoinbaseAbKey), arbitrary)
979+ store.db.Set([]byte(CoinbaseAbKey), arbitrary)
953980 } else {
954- store.batch.Set([]byte(dbm.CoinbaseAbKey), arbitrary)
981+ store.batch.Set([]byte(CoinbaseAbKey), arbitrary)
955982 }
956983 }
957984
@@ -986,9 +1013,9 @@ func (store *MockAccountStore) SetMiningAddress(program *acc.CtrlProgram) error
9861013 }
9871014
9881015 if store.batch == nil {
989- store.db.Set([]byte(dbm.MiningAddressKey), rawProgram)
1016+ store.db.Set([]byte(MiningAddressKey), rawProgram)
9901017 } else {
991- store.batch.Set([]byte(dbm.MiningAddressKey), rawProgram)
1018+ store.batch.Set([]byte(MiningAddressKey), rawProgram)
9921019 }
9931020 return nil
9941021 }
Show on old repository browser