Skip to content

Commit

Permalink
multi: Drop Headers func from Peer interface
Browse files Browse the repository at this point in the history
This is not used anywhere.
  • Loading branch information
matheusd committed Nov 17, 2023
1 parent 8afcdef commit 284762f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 34 deletions.
18 changes: 0 additions & 18 deletions spv/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,6 @@ func (s *Syncer) CFiltersV2(ctx context.Context, blockHashes []*chainhash.Hash)
}
}

// Headers implements the Headers method of the wallet.Peer interface.
func (s *Syncer) Headers(ctx context.Context, blockLocators []*chainhash.Hash, hashStop *chainhash.Hash) ([]*wire.BlockHeader, error) {
for {
if err := ctx.Err(); err != nil {
return nil, err
}
rp, err := s.pickRemote(pickAny)
if err != nil {
return nil, err
}
hs, err := rp.Headers(ctx, blockLocators, hashStop)
if err != nil {
continue
}
return hs, nil
}
}

func (s *Syncer) String() string {
// This method is part of the wallet.Peer interface and will typically
// specify the remote address of the peer. Since the syncer can encompass
Expand Down
12 changes: 0 additions & 12 deletions spv/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,18 +554,6 @@ func (s *Syncer) forRemotes(f func(rp *p2p.RemotePeer) error) error {
return nil
}

func (s *Syncer) pickRemote(pick func(*p2p.RemotePeer) bool) (*p2p.RemotePeer, error) {
defer s.remotesMu.Unlock()
s.remotesMu.Lock()

for _, rp := range s.remotes {
if pick(rp) {
return rp, nil
}
}
return nil, errors.E(errors.NoPeers)
}

// waitForAnyRemote blocks until there is one or more remote peers available or
// the context is canceled.
//
Expand Down
1 change: 0 additions & 1 deletion wallet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type FilterProof = struct {
type Peer interface {
Blocks(ctx context.Context, blockHashes []*chainhash.Hash) ([]*wire.MsgBlock, error)
CFiltersV2(ctx context.Context, blockHashes []*chainhash.Hash) ([]FilterProof, error)
Headers(ctx context.Context, blockLocators []*chainhash.Hash, hashStop *chainhash.Hash) ([]*wire.BlockHeader, error)
PublishTransactions(ctx context.Context, txs ...*wire.MsgTx) error
}

Expand Down
3 changes: 0 additions & 3 deletions wallet/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ func (mockNetwork) Blocks(ctx context.Context, blockHashes []*chainhash.Hash) ([
func (mockNetwork) CFiltersV2(ctx context.Context, blockHashes []*chainhash.Hash) ([]FilterProof, error) {
return nil, nil
}
func (mockNetwork) Headers(ctx context.Context, blockLocators []*chainhash.Hash, hashStop *chainhash.Hash) ([]*wire.BlockHeader, error) {
return nil, nil
}
func (mockNetwork) PublishTransactions(ctx context.Context, txs ...*wire.MsgTx) error { return nil }
func (mockNetwork) LoadTxFilter(ctx context.Context, reload bool, addrs []stdaddr.Address, outpoints []wire.OutPoint) error {
return nil
Expand Down

0 comments on commit 284762f

Please sign in to comment.