File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ import (
1616 "github.com/sirupsen/logrus"
1717)
1818
19+ var (
20+ MaxArraySize int = 10
21+ )
22+
1923// Stores all the information related to a peer
2024type Peer struct {
2125
@@ -202,13 +206,23 @@ func (pm *Peer) FetchConnectionsFromNewPeer(newPeer Peer) {
202206
203207 pm .ConnectionEvent (newConnectedDirection , time )
204208 }
209+
210+ if len (pm .ConnectedDirection ) > MaxArraySize {
211+ tmpConnDirection := pm .ConnectedDirection [len (pm .ConnectedDirection )- MaxArraySize - 1 : len (pm .ConnectedDirection )- 1 ]
212+ pm .ConnectedDirection = tmpConnDirection
213+ }
214+
205215 for _ , time := range newPeer .DisconnectionTimes {
206216 pm .DisconnectionEvent (time )
207217 }
208218
209219 for _ , errorTmp := range newPeer .Error {
210220 pm .Error = append (pm .Error , errorTmp )
211221 }
222+ if len (pm .Error ) > MaxArraySize {
223+ tmpError := pm .Error [len (pm .Error )- MaxArraySize - 1 : len (pm .Error )- 1 ]
224+ pm .Error = tmpError
225+ }
212226
213227 if newPeer .LastErrorTimestamp .After (pm .LastErrorTimestamp ) {
214228 pm .LastErrorTimestamp = newPeer .LastErrorTimestamp
Original file line number Diff line number Diff line change @@ -614,6 +614,11 @@ func (c *PrunedPeer) NextConnection() time.Time {
614614 if c .DelayObj .GetType () == Minus1DelayType { // in case of Minus1, this is new peer and we want it to connect as soon as possible
615615 return time.Time {}
616616 }
617+
618+ if c .DelayObj .CalculateDelay () > MaxDelayTime {
619+ return c .BaseConnectionTimestamp .Add (MaxDelayTime )
620+ }
621+
617622 // nextConnection should be from first event + the applied delay
618623 return c .BaseConnectionTimestamp .Add (c .DelayObj .CalculateDelay ())
619624}
@@ -657,10 +662,7 @@ func (c *PrunedPeer) UpdateDelay(newDelayType string) {
657662 c .BaseDeprecationTimestamp = time .Now ()
658663 }
659664
660- // only add degree in case we have not exceeded the MaxDelay allowed
661- if c .DelayObj .CalculateDelay () < MaxDelayTime {
662- c .DelayObj .AddDegree ()
663- }
665+ c .DelayObj .AddDegree ()
664666}
665667
666668// ErrorToDelayType:
You can’t perform that action at this time.
0 commit comments