transactions := []*query.AnnotatedTx{}
var err error
- transactions, err = a.wallet.GetUnconfirmedTxsByAccountID(filter.AccountID)
+ transactions, err = a.wallet.GetUnconfirmedTxs(filter.AccountID)
if err != nil {
log.Errorf("listTransactions: %v", err)
return NewErrorResponse(err)
getTransactionCmd.Name(),
listTransactionsCmd.Name(),
+
+ getUnconfirmedTransactionCmd.Name(),
+ listUnconfirmedTransactionsCmd.Name(),
+
listUnspentOutputsCmd.Name(),
listBalancesCmd.Name(),
}
os.Exit(exitCode)
}
- printJSON(data)
+ printJSONList(data)
},
}
maxtxsPending = 32768
maxQuitReq = 256
- // txChanSize is the size of channel listening to Txpool newTxCh.
- maxTxChanSize = 1000
+ maxTxChanSize = 1000 // txChanSize is the size of channel listening to Txpool newTxCh
)
var (
return annotatedTx, nil
}
-// GetUnconfirmedTxsByAccountID get account unconfirmed txs by account ID
-func (w *Wallet) GetUnconfirmedTxsByAccountID(accountID string) ([]*query.AnnotatedTx, error) {
+// GetUnconfirmedTxs get account unconfirmed transactions, filter transactions by accountID when accountID is not empty
+func (w *Wallet) GetUnconfirmedTxs(accountID string) ([]*query.AnnotatedTx, error) {
annotatedTxs := []*query.AnnotatedTx{}
+ annotatedAccTxs := []*query.AnnotatedTx{}
txIter := w.DB.IteratorPrefix([]byte(unconfirmedTxPrefix))
defer txIter.Release()
return nil, err
}
- if accountID == "" {
- annotatedTxs = append(annotatedTxs, annotatedTx)
- continue
- }
-
- if findTransactionsByAccount(annotatedTx, accountID) {
- annotatedTxs = append(annotatedTxs, annotatedTx)
+ annotatedTxs = append(annotatedTxs, annotatedTx)
+ if accountID != "" && findTransactionsByAccount(annotatedTx, accountID) {
+ annotatedAccTxs = append(annotatedAccTxs, annotatedTx)
}
}
+ if accountID != "" {
+ return annotatedAccTxs, nil
+ }
return annotatedTxs, nil
}
//SINGLE single sign
SINGLE = 1
- // txChanSize is the size of channel listening to Txpool newTxCh.
- maxTxChanSize = 1000
+ maxTxChanSize = 1000 // txChanSize is the size of channel listening to Txpool newTxCh
)
var walletKey = []byte("walletInfo")
w.status.WorkHash = bc.Hash{}
w.AttachBlock(block)
default:
- //return
+ return
}
}
+//SetTxCh set wallet txCh
+func (w *Wallet) SetTxCh(txCh *types.Tx) {
+ w.txCh <- txCh
+}
+
func (w *Wallet) walletTxPoolUpdater() {
for {
// rescan txpool transaction and delete unconfirmed transactions from database
}
return nil
}
-
-//SetTxCh set wallet txCh
-func (w *Wallet) SetTxCh(txCh *types.Tx) {
- w.txCh <- txCh
-}