From 06f399531ca1a23b7c27b49be7b1c2347de21016 Mon Sep 17 00:00:00 2001 From: Hans Moog <hm@mkjc.net> Date: Wed, 24 Jul 2019 11:43:25 +0200 Subject: [PATCH] Feat: started adding timestamps to peers (to clean up offline nodes) --- plugins/autopeering/types/peer/constants.go | 3 ++- plugins/autopeering/types/peer/peer.go | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/plugins/autopeering/types/peer/constants.go b/plugins/autopeering/types/peer/constants.go index 1abfe107..a29c567c 100644 --- a/plugins/autopeering/types/peer/constants.go +++ b/plugins/autopeering/types/peer/constants.go @@ -26,5 +26,6 @@ const ( MARSHALED_PEERING_PORT_SIZE = 2 MARSHALED_GOSSIP_PORT_SIZE = 2 MARSHALED_SALT_SIZE = salt.SALT_MARSHALED_SIZE - MARSHALED_TOTAL_SIZE = MARSHALED_SALT_END + + MARSHALED_TOTAL_SIZE = MARSHALED_SALT_END ) diff --git a/plugins/autopeering/types/peer/peer.go b/plugins/autopeering/types/peer/peer.go index 9bc8510c..1428ed80 100644 --- a/plugins/autopeering/types/peer/peer.go +++ b/plugins/autopeering/types/peer/peer.go @@ -5,6 +5,7 @@ import ( "net" "strconv" "sync" + "time" "github.com/iotaledger/goshimmer/packages/events" "github.com/iotaledger/goshimmer/packages/identity" @@ -15,13 +16,17 @@ import ( ) type Peer struct { - Identity *identity.Identity - Address net.IP - PeeringPort uint16 - GossipPort uint16 - Salt *salt.Salt - Conn *network.ManagedConnection - connectMutex sync.Mutex + Identity *identity.Identity + Address net.IP + PeeringPort uint16 + GossipPort uint16 + Salt *salt.Salt + Conn *network.ManagedConnection + connectMutex sync.Mutex + firstSeen time.Time + firstSeenMutex sync.RWMutex + lastSeen time.Time + lastSeenMutex sync.RWMutex } func Unmarshal(data []byte) (*Peer, error) { -- GitLab