rpcserver: Remove unused AddrIndexer interface.

This removes the AddrIndexer interface and related test infrastructure
since it is no longer used as of the removal of the address index code.

This is part of the overall removal of the deprecated address index.
This commit is contained in:
Dave Collins 2022-04-26 01:00:55 -05:00
parent 30db38e7d7
commit dca095f9ba
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2
4 changed files with 0 additions and 109 deletions

View File

@ -15,7 +15,6 @@ import (
"github.com/decred/dcrd/blockchain/v5"
"github.com/decred/dcrd/blockchain/v5/indexers"
"github.com/decred/dcrd/chaincfg/chainhash"
"github.com/decred/dcrd/database/v3"
"github.com/decred/dcrd/dcrutil/v4"
"github.com/decred/dcrd/gcs/v4"
"github.com/decred/dcrd/internal/mempool"
@ -608,39 +607,6 @@ type TxMempooler interface {
TSpendHashes() []chainhash.Hash
}
// AddrIndexer provides an interface for retrieving transactions for a given
// address.
//
// The interface contract requires that all of these methods are safe for
// concurrent access.
type AddrIndexer interface {
// Name returns the human-readable name of the index.
Name() string
// Tip returns the current index tip.
Tip() (int64, *chainhash.Hash, error)
// WaitForSync subscribes clients for the next index sync update.
WaitForSync() chan bool
// EntriesForAddress returns a slice of details which identify each transaction,
// including a block region, that involves the passed address according to the
// specified number to skip, number requested, and whether or not the results
// should be reversed. It also returns the number actually skipped since it
// could be less in the case where there are not enough entries.
//
// NOTE: These results only include transactions confirmed in blocks. See the
// UnconfirmedTxnsForAddress method for obtaining unconfirmed transactions
// that involve a given address.
EntriesForAddress(dbTx database.Tx, addr stdaddr.Address, numToSkip,
numRequested uint32, reverse bool) ([]indexers.TxIndexEntry, uint32, error)
// UnconfirmedTxnsForAddress returns all transactions currently in the
// unconfirmed (memory-only) address index that involve the passed address.
// Unsupported address types are ignored and will result in no results.
UnconfirmedTxnsForAddress(addr stdaddr.Address) []*dcrutil.Tx
}
// TxIndexer provides an interface for retrieving details for a given
// transaction hash.
//

View File

@ -5739,9 +5739,6 @@ type Config struct {
// use.
TxIndexer TxIndexer
// AddrIndexer defines the optional address indexer for the RPC server to use.
AddrIndexer AddrIndexer
// NetInfo defines a slice of the available networks.
NetInfo []types.NetworksResult

View File

@ -600,52 +600,6 @@ func (e *testExistsAddresser) ExistsAddresses(addrs []stdaddr.Address) ([]bool,
return e.existsAddresses, e.existsAddressesErr
}
// testAddrIndexer provides a mock address indexer by implementing the
// AddrIndexer interface.
type testAddrIndexer struct {
entriesForAddress []indexers.TxIndexEntry
entriesForAddressSkipped uint32
entriesForAddressErr error
unconfirmedTxnsForAddress []*dcrutil.Tx
tipHeight int64
tipHash *chainhash.Hash
tipErr error
signalOnWait bool
}
// Name returns the human-readable name of the index.
func (a *testAddrIndexer) Name() string {
return "testAddrIndexer"
}
// Tip returns the current index tip.
func (a *testAddrIndexer) Tip() (int64, *chainhash.Hash, error) {
return a.tipHeight, a.tipHash, a.tipErr
}
// WaitForSync subscribes clients for the next index sync update.
func (a *testAddrIndexer) WaitForSync() chan bool {
c := make(chan bool)
if a.signalOnWait {
close(c)
}
return c
}
// EntriesForAddress returns a mocked slice of indexers.TxIndexEntry that
// involve the given address.
func (a *testAddrIndexer) EntriesForAddress(dbTx database.Tx,
addr stdaddr.Address, numToSkip, numRequested uint32, reverse bool) (
[]indexers.TxIndexEntry, uint32, error) {
return a.entriesForAddress, a.entriesForAddressSkipped, a.entriesForAddressErr
}
// UnconfirmedTxnsForAddress returns a mocked slice of transactions that are
// currently in the unconfirmed (memory-only) address index.
func (a *testAddrIndexer) UnconfirmedTxnsForAddress(addr stdaddr.Address) []*dcrutil.Tx {
return a.unconfirmedTxnsForAddress
}
// testTxIndexer provides a mock transaction indexer by implementing the
// TxIndexer interface.
type testTxIndexer struct {
@ -1391,8 +1345,6 @@ type rpcTest struct {
mockSyncManager *testSyncManager
mockExistsAddresser *testExistsAddresser
setExistsAddresserNil bool
mockAddrIndexer *testAddrIndexer
setAddrIndexerNil bool
mockTxIndexer *testTxIndexer
setTxIndexerNil bool
mockDB *testDB
@ -1624,20 +1576,6 @@ func defaultMockExistsAddresser() *testExistsAddresser {
}
}
// defaultMockAddrIndexer provides a default mock address indexer to be
// used throughout the tests. Tests can override these defaults by calling
// defaultMockAddrIndexer, updating fields as necessary on the returned
// *testAddrIndexer, and then setting rpcTest.mockAddrIndexer as that
// *testAddrIndexer.
func defaultMockAddrIndexer() *testAddrIndexer {
bestHash := block432100.Header.BlockHash()
return &testAddrIndexer{
tipHeight: int64(block432100.Header.Height),
tipHash: &bestHash,
signalOnWait: true,
}
}
// defaultMockTxIndexer provides a default mock transaction indexer to be
// used throughout the tests. Tests can override these defaults by calling
// defaultMockTxIndexer, updating fields as necessary on the returned
@ -1824,7 +1762,6 @@ func defaultMockConfig(chainParams *chaincfg.Params) *Config {
FeeEstimator: defaultMockFeeEstimator(),
SyncMgr: defaultMockSyncManager(),
ExistsAddresser: defaultMockExistsAddresser(),
AddrIndexer: defaultMockAddrIndexer(),
TxIndexer: defaultMockTxIndexer(),
DB: defaultMockDB(),
ConnMgr: defaultMockConnManager(),
@ -7939,12 +7876,6 @@ func testRPCServerHandler(t *testing.T, tests []rpcTest) {
if test.setExistsAddresserNil {
rpcserverConfig.ExistsAddresser = nil
}
if test.mockAddrIndexer != nil {
rpcserverConfig.AddrIndexer = test.mockAddrIndexer
}
if test.setAddrIndexerNil {
rpcserverConfig.AddrIndexer = nil
}
if test.mockTxIndexer != nil {
rpcserverConfig.TxIndexer = test.mockTxIndexer
}

View File

@ -3868,9 +3868,6 @@ func newServer(ctx context.Context, listenAddrs []string, db database.DB,
if s.txIndex != nil {
rpcsConfig.TxIndexer = s.txIndex
}
if s.addrIndex != nil {
rpcsConfig.AddrIndexer = s.addrIndex
}
s.rpcServer, err = rpcserver.New(&rpcsConfig)
if err != nil {