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 (
16
16
"github.com/sirupsen/logrus"
17
17
)
18
18
19
+ var (
20
+ MaxArraySize int = 10
21
+ )
22
+
19
23
// Stores all the information related to a peer
20
24
type Peer struct {
21
25
@@ -202,13 +206,23 @@ func (pm *Peer) FetchConnectionsFromNewPeer(newPeer Peer) {
202
206
203
207
pm .ConnectionEvent (newConnectedDirection , time )
204
208
}
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
+
205
215
for _ , time := range newPeer .DisconnectionTimes {
206
216
pm .DisconnectionEvent (time )
207
217
}
208
218
209
219
for _ , errorTmp := range newPeer .Error {
210
220
pm .Error = append (pm .Error , errorTmp )
211
221
}
222
+ if len (pm .Error ) > MaxArraySize {
223
+ tmpError := pm .Error [len (pm .Error )- MaxArraySize - 1 : len (pm .Error )- 1 ]
224
+ pm .Error = tmpError
225
+ }
212
226
213
227
if newPeer .LastErrorTimestamp .After (pm .LastErrorTimestamp ) {
214
228
pm .LastErrorTimestamp = newPeer .LastErrorTimestamp
Original file line number Diff line number Diff line change @@ -614,6 +614,11 @@ func (c *PrunedPeer) NextConnection() time.Time {
614
614
if c .DelayObj .GetType () == Minus1DelayType { // in case of Minus1, this is new peer and we want it to connect as soon as possible
615
615
return time.Time {}
616
616
}
617
+
618
+ if c .DelayObj .CalculateDelay () > MaxDelayTime {
619
+ return c .BaseConnectionTimestamp .Add (MaxDelayTime )
620
+ }
621
+
617
622
// nextConnection should be from first event + the applied delay
618
623
return c .BaseConnectionTimestamp .Add (c .DelayObj .CalculateDelay ())
619
624
}
@@ -657,10 +662,7 @@ func (c *PrunedPeer) UpdateDelay(newDelayType string) {
657
662
c .BaseDeprecationTimestamp = time .Now ()
658
663
}
659
664
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 ()
664
666
}
665
667
666
668
// ErrorToDelayType:
You can’t perform that action at this time.
0 commit comments