mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-11-10 18:25:17 +00:00
fix: memory leak accumulation in pending frame processing (#59)
This commit is contained in:
parent
5405452f3e
commit
9fc46fff2f
@ -30,7 +30,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const PEER_INFO_TTL = 60 * 60 * 1000
|
const PEER_INFO_TTL = 60 * 60 * 1000
|
||||||
const UNCOOPERATIVE_PEER_INFO_TTL = 60 * 60 * 1000
|
const UNCOOPERATIVE_PEER_INFO_TTL = 5 * 60 * 1000
|
||||||
|
|
||||||
type InclusionMap = map[curves.PairingPoint]*protobufs.InclusionCommitment
|
type InclusionMap = map[curves.PairingPoint]*protobufs.InclusionCommitment
|
||||||
type PolynomialMap = map[curves.PairingPoint][]curves.PairingScalar
|
type PolynomialMap = map[curves.PairingPoint][]curves.PairingScalar
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
lru "github.com/hashicorp/golang-lru/v2"
|
lru "github.com/hashicorp/golang-lru/v2"
|
||||||
@ -462,7 +463,23 @@ func (d *DataTimeReel) processPending(
|
|||||||
frame *protobufs.ClockFrame,
|
frame *protobufs.ClockFrame,
|
||||||
) {
|
) {
|
||||||
d.logger.Debug("process pending")
|
d.logger.Debug("process pending")
|
||||||
for f, nextPending := range d.pending {
|
frameNumbers := []uint64{}
|
||||||
|
for f := range d.pending {
|
||||||
|
frameNumbers = append(frameNumbers, f)
|
||||||
|
}
|
||||||
|
sort.Slice(frameNumbers, func(i, j int) bool {
|
||||||
|
return frameNumbers[i] < frameNumbers[j]
|
||||||
|
})
|
||||||
|
limit := 8
|
||||||
|
for _, f := range frameNumbers {
|
||||||
|
if f < d.head.FrameNumber {
|
||||||
|
delete(d.pending, f)
|
||||||
|
}
|
||||||
|
if limit <= 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
nextPending := d.pending[f]
|
||||||
d.logger.Debug(
|
d.logger.Debug(
|
||||||
"checking frame set",
|
"checking frame set",
|
||||||
zap.Uint64("pending_frame_number", f),
|
zap.Uint64("pending_frame_number", f),
|
||||||
@ -498,7 +515,9 @@ func (d *DataTimeReel) processPending(
|
|||||||
go func() {
|
go func() {
|
||||||
d.frames <- nextFrame
|
d.frames <- nextFrame
|
||||||
}()
|
}()
|
||||||
|
limit--
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(d.pending[f]) == 0 {
|
if len(d.pending[f]) == 0 {
|
||||||
d.logger.Debug("last next processing, clear list")
|
d.logger.Debug("last next processing, clear list")
|
||||||
delete(d.pending, f)
|
delete(d.pending, f)
|
||||||
|
Loading…
Reference in New Issue
Block a user