Count xpub transactions regardless of filter
This commit is contained in:
parent
593247c364
commit
0546a2609d
23
api/xpub.go
23
api/xpub.go
@ -325,7 +325,7 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Get
|
|||||||
var (
|
var (
|
||||||
txc xpubTxids
|
txc xpubTxids
|
||||||
txmMap map[string]*Tx
|
txmMap map[string]*Tx
|
||||||
txcMap map[string]struct{}
|
txCount int
|
||||||
txs []*Tx
|
txs []*Tx
|
||||||
txids []string
|
txids []string
|
||||||
pg Paging
|
pg Paging
|
||||||
@ -397,18 +397,25 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Get
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txCount := int(data.txCountEstimate)
|
|
||||||
if option >= TxidHistory {
|
if option >= TxidHistory {
|
||||||
txcMap = make(map[string]struct{})
|
txcMap := make(map[string]bool)
|
||||||
txc = make(xpubTxids, 0, 32)
|
txc = make(xpubTxids, 0, 32)
|
||||||
for _, da := range [][]xpubAddress{data.addresses, data.changeAddresses} {
|
for _, da := range [][]xpubAddress{data.addresses, data.changeAddresses} {
|
||||||
for i := range da {
|
for i := range da {
|
||||||
ad := &da[i]
|
ad := &da[i]
|
||||||
for _, txid := range ad.txids {
|
for _, txid := range ad.txids {
|
||||||
_, foundTx := txcMap[txid.txid]
|
added, foundTx := txcMap[txid.txid]
|
||||||
if !foundTx && (useTxids == nil || useTxids(&txid, ad)) {
|
// count txs regardless of filter but only once
|
||||||
txcMap[txid.txid] = struct{}{}
|
if !foundTx {
|
||||||
txc = append(txc, txid)
|
txCount++
|
||||||
|
}
|
||||||
|
// add tx only once
|
||||||
|
if !added {
|
||||||
|
add := useTxids == nil || useTxids(&txid, ad)
|
||||||
|
txcMap[txid.txid] = add
|
||||||
|
if add {
|
||||||
|
txc = append(txc, txid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,6 +448,8 @@ func (w *Worker) GetXpubAddress(xpub string, page int, txsOnPage int, option Get
|
|||||||
txs = append(txs, tx)
|
txs = append(txs, tx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
txCount = int(data.txCountEstimate)
|
||||||
}
|
}
|
||||||
totalTokens := 0
|
totalTokens := 0
|
||||||
var tokens []Token
|
var tokens []Token
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user