Avoid showing already confirmed txs as mempool txs
parent
c2a581ea72
commit
210652328f
|
@ -678,18 +678,21 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, option GetA
|
|||
for _, txid := range txm {
|
||||
tx, err := w.GetTransaction(txid, false, false)
|
||||
// mempool transaction may fail
|
||||
if err != nil {
|
||||
glog.Error("GetTransaction in mempool ", tx, ": ", err)
|
||||
if err != nil || tx == nil {
|
||||
glog.Warning("GetTransaction in mempool: ", err)
|
||||
} else {
|
||||
uBalSat.Add(&uBalSat, tx.getAddrVoutValue(addrDesc))
|
||||
uBalSat.Sub(&uBalSat, tx.getAddrVinValue(addrDesc))
|
||||
if page == 0 {
|
||||
if option == TxidHistory {
|
||||
txids[txi] = tx.Txid
|
||||
} else {
|
||||
txs[txi] = tx
|
||||
// skip already confirmed txs, mempool may be out of sync
|
||||
if tx.Confirmations == 0 {
|
||||
uBalSat.Add(&uBalSat, tx.getAddrVoutValue(addrDesc))
|
||||
uBalSat.Sub(&uBalSat, tx.getAddrVinValue(addrDesc))
|
||||
if page == 0 {
|
||||
if option == TxidHistory {
|
||||
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
|
||||
func (b *EthereumRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) {
|
||||
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) {
|
||||
b.pendingTransactionsLock.Lock()
|
||||
delete(b.pendingTransactions, txid)
|
||||
|
|
Loading…
Reference in New Issue