Skip to content

Commit

Permalink
Merge pull request #143 from s7techlab/16719-peer-endpoint-for-fetcher
Browse files Browse the repository at this point in the history
peer endpoint for fetcher
  • Loading branch information
criro1 committed Apr 2, 2024
2 parents ce40e10 + a1e8d07 commit 7394cac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions observer/channel_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ type (
}

PeerChannelsFetcher interface {
Uri() string
api.ChannelListGetter
api.ChainInfoGetter
}

PeerChannels interface {
Uri() string
Channels() map[string]*ChannelInfo
}

Expand Down Expand Up @@ -135,6 +137,10 @@ func (cp *ChannelPeer) Observe(ctx context.Context) {
}()
}

func (cp *ChannelPeer) Uri() string {
return cp.channelFetcher.Uri()
}

func (cp *ChannelPeer) Channels() map[string]*ChannelInfo {
cp.mu.Lock()
defer cp.mu.Unlock()
Expand Down
4 changes: 4 additions & 0 deletions observer/channel_peer_fetcher_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func NewChannelPeerFetcherMock(channels map[string]uint64) *ChannelPeerFetcherMo
}
}

func (c *ChannelPeerFetcherMock) Uri() string {
return "mock"
}

func (c *ChannelPeerFetcherMock) GetChannels(context.Context) (*peer.ChannelQueryResponse, error) {
var channels []*peer.ChannelInfo
for channelName := range c.channels {
Expand Down
4 changes: 4 additions & 0 deletions observer/channel_peer_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ type ChannelPeerMock struct {
channelsInfo map[string]*ChannelInfo
}

func (m *ChannelPeerMock) Uri() string {
return "mock"
}

func NewChannelPeerMock(channelsInfo ...*ChannelInfo) *ChannelPeerMock {
channels := make(map[string]*ChannelInfo, len(channelsInfo))
for _, channelInfo := range channelsInfo {
Expand Down

0 comments on commit 7394cac

Please sign in to comment.