OSDN Git Service

remove deleteAccountControlPrograms
authorChengcheng Zhang <943420582@qq.com>
Mon, 1 Jul 2019 02:27:02 +0000 (10:27 +0800)
committerChengcheng Zhang <943420582@qq.com>
Mon, 1 Jul 2019 02:27:02 +0000 (10:27 +0800)
account/accounts.go
database/account_store.go

index 0cbf39e..18b6e73 100644 (file)
@@ -281,27 +281,6 @@ func (m *Manager) CreateBatchAddresses(accountID string, change bool, stopIndex
        return nil
 }
 
-// deleteAccountControlPrograms deletes control program matching accountID
-func (m *Manager) deleteAccountControlPrograms(accountID string) error {
-       cps, err := m.ListControlProgram()
-       if err != nil {
-               return err
-       }
-
-       var hash [32]byte
-       for _, cp := range cps {
-               if cp.AccountID == accountID {
-                       sha3pool.Sum256(hash[:], cp.ControlProgram)
-                       m.store.DeleteControlProgram(bc.NewHash(hash))
-               }
-       }
-
-       m.store.DeleteBip44ContractIndex(accountID)
-       m.store.DeleteContractIndex(accountID)
-
-       return nil
-}
-
 // DeleteAccount deletes the account's ID or alias matching account ID.
 func (m *Manager) DeleteAccount(accountID string) (err error) {
        m.accountMu.Lock()
@@ -312,10 +291,6 @@ func (m *Manager) DeleteAccount(accountID string) (err error) {
                return err
        }
 
-       // if err := m.deleteAccountControlPrograms(accountID); err != nil {
-       //      return err
-       // }
-
        m.cacheMu.Lock()
        m.aliasCache.Remove(account.Alias)
        m.cacheMu.Unlock()
index 982249b..e59d1ef 100644 (file)
@@ -50,15 +50,12 @@ func (store *AccountStore) CommitBatch() error {
 
 // DeleteAccount set account account ID, account alias and raw account.
 func (store *AccountStore) DeleteAccount(account *acc.Account) error {
-
-       // store.DeleteBip44ContractIndex(account.ID)
-       // store.DeleteContractIndex(account.ID)
-
        store.DeleteAccountUTXOs(account.ID)
        batch := store.accountDB.NewBatch()
        if store.batch != nil {
                batch = store.batch
        }
+
        // delete account control program
        cps, err := store.ListControlPrograms()
        if err != nil {
@@ -72,12 +69,15 @@ func (store *AccountStore) DeleteAccount(account *acc.Account) error {
                        batch.Delete(ContractKey(bc.NewHash(hash)))
                }
        }
+
        // delete bip44 contract index
        batch.Delete(Bip44ContractIndexKey(account.ID, false))
        batch.Delete(Bip44ContractIndexKey(account.ID, true))
+
        // delete contract index
        batch.Delete(contractIndexKey(account.ID))
 
+       // delete account id
        batch.Delete(AccountIDKey(account.ID))
        batch.Delete(accountAliasKey(account.Alias))
        if store.batch == nil {