diff --git a/router/peer.go b/router/peer.go index 5525caee..bd27573e 100644 --- a/router/peer.go +++ b/router/peer.go @@ -5,8 +5,19 @@ import ( "log" "net" "sort" + "sync" ) +type Peer struct { + sync.RWMutex + Name PeerName + NameByte []byte + UID uint64 + version uint64 + localRefCount uint64 + connections map[PeerName]Connection +} + func NewPeer(name PeerName, uid uint64, version uint64) *Peer { if uid == 0 { uid = randUint64() @@ -144,6 +155,17 @@ func (peer *Peer) Routes(stopAt *Peer, symmetric bool) (bool, map[PeerName]PeerN return false, routes } +type LocalPeer struct { + *Peer + Router *Router + queryChan chan<- *PeerInteraction +} + +type PeerInteraction struct { + Interaction + payload interface{} +} + func StartLocalPeer(name PeerName, router *Router) *LocalPeer { peer := &LocalPeer{Peer: NewPeer(name, 0, 0), Router: router} queryChan := make(chan *PeerInteraction, ChannelSize) diff --git a/router/types.go b/router/types.go index 97d27dc5..e6acb90b 100644 --- a/router/types.go +++ b/router/types.go @@ -25,27 +25,6 @@ type Router struct { LogFrame func(string, []byte, *layers.Ethernet) } -type Peer struct { - sync.RWMutex - Name PeerName - NameByte []byte - UID uint64 - version uint64 - localRefCount uint64 - connections map[PeerName]Connection -} - -type LocalPeer struct { - *Peer - Router *Router - queryChan chan<- *PeerInteraction -} - -type PeerInteraction struct { - Interaction - payload interface{} -} - type Connection interface { Local() *Peer Remote() *Peer