Avoid showing already confirmed txs as mempool txs
This commit is contained in:
parent
c2a581ea72
commit
210652328f
@ -678,18 +678,21 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option GetA
|
|||||||
for _, txid := range txm {
|
for _, txid := range txm {
|
||||||
tx, err := w.GetTransaction(txid, false, false)
|
tx, err := w.GetTransaction(txid, false, false)
|
||||||
// mempool transaction may fail
|
// mempool transaction may fail
|
||||||
if err != nil {
|
if err != nil || tx == nil {
|
||||||
glog.Error("GetTransaction in mempool ", tx, ": ", err)
|
glog.Warning("GetTransaction in mempool: ", err)
|
||||||
} else {
|
} else {
|
||||||
uBalSat.Add(&uBalSat, tx.getAddrVoutValue(addrDesc))
|
// skip already confirmed txs, mempool may be out of sync
|
||||||
uBalSat.Sub(&uBalSat, tx.getAddrVinValue(addrDesc))
|
if tx.Confirmations == 0 {
|
||||||
if page == 0 {
|
uBalSat.Add(&uBalSat, tx.getAddrVoutValue(addrDesc))
|
||||||
if option == TxidHistory {
|
uBalSat.Sub(&uBalSat, tx.getAddrVinValue(addrDesc))
|
||||||
txids[txi] = tx.Txid
|
if page == 0 {
|
||||||
} else {
|
if option == TxidHistory {
|
||||||
txs[txi] = tx
|
txids[txi] = tx.Txid
|
||||||
|
} else {
|
||||||
|
txs[txi] = tx
|
||||||
|
}
|
||||||
|
txi++
|
||||||
}
|
}
|
||||||
txi++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -519,7 +519,7 @@ func (b *EthereumRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error) {
|
|||||||
// It could be optimized for mempool, i.e. without block time and confirmations
|
// It could be optimized for mempool, i.e. without block time and confirmations
|
||||||
func (b *EthereumRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
|
func (b *EthereumRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
|
||||||
tx, err := b.GetTransaction(txid)
|
tx, err := b.GetTransaction(txid)
|
||||||
// it there is an error getting the tx or the tx is confirmed, remove it from pending transactions
|
// if there is an error getting the tx or the tx is confirmed, remove it from pending transactions
|
||||||
if err == bchain.ErrTxNotFound || (tx != nil && tx.Confirmations > 0) {
|
if err == bchain.ErrTxNotFound || (tx != nil && tx.Confirmations > 0) {
|
||||||
b.pendingTransactionsLock.Lock()
|
b.pendingTransactionsLock.Lock()
|
||||||
delete(b.pendingTransactions, txid)
|
delete(b.pendingTransactions, txid)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user