diff --git a/bchain/coins/blockchain.go b/bchain/coins/blockchain.go index c90332ae..7e068e67 100644 --- a/bchain/coins/blockchain.go +++ b/bchain/coins/blockchain.go @@ -149,10 +149,6 @@ func (c *blockChainWithMetrics) GetMempoolTransactions(address string) (v []stri return c.b.GetMempoolTransactions(address) } -func (c *blockChainWithMetrics) GetMempoolSpentOutput(outputTxid string, vout uint32) (v string) { - return c.b.GetMempoolSpentOutput(outputTxid, vout) -} - func (c *blockChainWithMetrics) GetMempoolEntry(txid string) (v *bchain.MempoolEntry, err error) { defer func(s time.Time) { c.observeRPCLatency("GetMempoolEntry", s, err) }(time.Now()) return c.b.GetMempoolEntry(txid) diff --git a/bchain/coins/btc/bitcoinrpc.go b/bchain/coins/btc/bitcoinrpc.go index cb894517..686efcf2 100644 --- a/bchain/coins/btc/bitcoinrpc.go +++ b/bchain/coins/btc/bitcoinrpc.go @@ -575,11 +575,6 @@ func (b *BitcoinRPC) GetMempoolTransactions(address string) ([]string, error) { return b.Mempool.GetTransactions(address) } -// GetMempoolSpentOutput returns transaction in mempool which spends given outpoint -func (b *BitcoinRPC) GetMempoolSpentOutput(outputTxid string, vout uint32) string { - return b.Mempool.GetSpentOutput(outputTxid, vout) -} - // EstimateSmartFee returns fee estimation. func (b *BitcoinRPC) EstimateSmartFee(blocks int, conservative bool) (float64, error) { glog.V(1).Info("rpc: estimatesmartfee ", blocks) diff --git a/bchain/coins/eth/ethrpc.go b/bchain/coins/eth/ethrpc.go index 26c844bc..9193a9d8 100644 --- a/bchain/coins/eth/ethrpc.go +++ b/bchain/coins/eth/ethrpc.go @@ -486,10 +486,6 @@ func (b *EthereumRPC) GetMempoolTransactions(address string) ([]string, error) { return b.Mempool.GetTransactions(address) } -func (b *EthereumRPC) GetMempoolSpentOutput(outputTxid string, vout uint32) string { - return "" -} - func (b *EthereumRPC) GetMempoolEntry(txid string) (*bchain.MempoolEntry, error) { return nil, errors.New("GetMempoolEntry: not implemented") } diff --git a/bchain/mempool_nonutxo.go b/bchain/mempool_nonutxo.go index d30149f6..7a18ca4a 100644 --- a/bchain/mempool_nonutxo.go +++ b/bchain/mempool_nonutxo.go @@ -22,13 +22,13 @@ func NewNonUTXOMempool(chain BlockChain) *NonUTXOMempool { // GetTransactions returns slice of mempool transactions for given address func (m *NonUTXOMempool) GetTransactions(address string) ([]string, error) { - m.mux.Lock() - defer m.mux.Unlock() parser := m.chain.GetChainParser() addrID, err := parser.GetAddrIDFromAddress(address) if err != nil { return nil, err } + m.mux.Lock() + defer m.mux.Unlock() outpoints := m.addrIDToTx[string(addrID)] txs := make([]string, 0, len(outpoints)) for _, o := range outpoints { diff --git a/bchain/mempool_utxo.go b/bchain/mempool_utxo.go index fbd73724..d653e0a9 100644 --- a/bchain/mempool_utxo.go +++ b/bchain/mempool_utxo.go @@ -7,7 +7,7 @@ import ( "github.com/golang/glog" ) -// addrIndex and outpoint are used also in nonutxo mempool +// addrIndex and outpoint are used also in non utxo mempool type addrIndex struct { addrID string n int32 @@ -39,13 +39,13 @@ func NewUTXOMempool(chain BlockChain) *UTXOMempool { // GetTransactions returns slice of mempool transactions for given address func (m *UTXOMempool) GetTransactions(address string) ([]string, error) { - m.mux.Lock() - defer m.mux.Unlock() parser := m.chain.GetChainParser() addrID, err := parser.GetAddrIDFromAddress(address) if err != nil { return nil, err } + m.mux.Lock() + defer m.mux.Unlock() outpoints := m.addrIDToTx[string(addrID)] txs := make([]string, 0, len(outpoints)+len(outpoints)/2) for _, o := range outpoints { diff --git a/bchain/types.go b/bchain/types.go index 73b2b56b..c5a88630 100644 --- a/bchain/types.go +++ b/bchain/types.go @@ -141,7 +141,6 @@ type BlockChain interface { // mempool ResyncMempool(onNewTxAddr func(txid string, addr string)) error GetMempoolTransactions(address string) ([]string, error) - GetMempoolSpentOutput(outputTxid string, vout uint32) string GetMempoolEntry(txid string) (*MempoolEntry, error) // parser GetChainParser() BlockChainParser diff --git a/server/https.go b/server/https.go index cf073e9e..62232f68 100644 --- a/server/https.go +++ b/server/https.go @@ -196,12 +196,6 @@ func (s *HTTPServer) transactions(w http.ResponseWriter, r *http.Request) { txList := transactionList{} err = s.db.GetTransactions(address, lower, higher, func(txid string, vout uint32, isOutput bool) error { txList.Txid = append(txList.Txid, txid) - if isOutput { - input := s.chain.GetMempoolSpentOutput(txid, vout) - if input != "" { - txList.Txid = append(txList.Txid, txid) - } - } return nil }) if err != nil { diff --git a/server/socketio.go b/server/socketio.go index 98465a2f..a654122c 100644 --- a/server/socketio.go +++ b/server/socketio.go @@ -127,7 +127,6 @@ func (s *SocketIoServer) txRedirect(w http.ResponseWriter, r *http.Request) { type addrOpts struct { Start int `json:"start"` End int `json:"end"` - QueryMempol bool `json:"queryMempol"` QueryMempoolOnly bool `json:"queryMempoolOnly"` From int `json:"from"` To int `json:"to"` @@ -276,27 +275,17 @@ func (s *SocketIoServer) getAddressTxids(addr []string, opts *addrOpts) (res res if !opts.QueryMempoolOnly { err = s.db.GetTransactions(address, lower, higher, func(txid string, vout uint32, isOutput bool) error { txids = append(txids, txid) - if isOutput && opts.QueryMempol { - input := s.chain.GetMempoolSpentOutput(txid, vout) - if input != "" { - txids = append(txids, txid) - } - } return nil }) if err != nil { return res, err } - } - if opts.QueryMempoolOnly || opts.QueryMempol { - mtxids, err := s.chain.GetMempoolTransactions(address) + } else { + m, err := s.chain.GetMempoolTransactions(address) if err != nil { return res, err } - txids = append(txids, mtxids...) - } - if err != nil { - return res, err + txids = append(txids, m...) } } res.Result = uniqueTxidsInReverse(txids)