chanfitness: refactor to store channels by peer
When dealing with online events, we actually need to track our events by peer, not by channel. All we need to track channels is to have a set of online events for a peer which at least contain those events. This change refactors chanfitness to track by peer.
This commit is contained in:
6 files changed
+358
-344
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package chanfitness
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
// peerMonitor is an interface implemented by entities that monitor our peers
|
||||
// online events and the channels we currently have open with them.
|
||||
type peerMonitor interface {
|
||||
// event adds an online or offline event.
|
||||
onlineEvent(online bool)
|
||||
|
||||
// addChannel adds a new channel.
|
||||
addChannel(channelPoint wire.OutPoint) error
|
||||
|
||||
// removeChannel removes a channel.
|
||||
removeChannel(channelPoint wire.OutPoint) error
|
||||
|
||||
// channelCount returns the number of channels that we currently have
|
||||
// with the peer.
|
||||
channelCount() int
|
||||
|
||||
// channelUptime looks up a channel and returns the amount of time that
|
||||
// the channel has been monitored for and its uptime over this period.
|
||||
channelUptime(channelPoint wire.OutPoint) (time.Duration,
|
||||
time.Duration, error)
|
||||
}
|
||||
Reference in new issue
Block a user