mirror of
				https://source.quilibrium.com/quilibrium/ceremonyclient.git
				synced 2025-04-04 19:36:54 +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 UNCOOPERATIVE_PEER_INFO_TTL = 60 * 60 * 1000 | ||||
| const UNCOOPERATIVE_PEER_INFO_TTL = 5 * 60 * 1000 | ||||
| 
 | ||||
| type InclusionMap = map[curves.PairingPoint]*protobufs.InclusionCommitment | ||||
| type PolynomialMap = map[curves.PairingPoint][]curves.PairingScalar | ||||
|  | ||||
| @ -4,6 +4,7 @@ import ( | ||||
| 	"bytes" | ||||
| 	"encoding/hex" | ||||
| 	"math/big" | ||||
| 	"sort" | ||||
| 	"sync" | ||||
| 
 | ||||
| 	lru "github.com/hashicorp/golang-lru/v2" | ||||
| @ -462,7 +463,23 @@ func (d *DataTimeReel) processPending( | ||||
| 	frame *protobufs.ClockFrame, | ||||
| ) { | ||||
| 	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( | ||||
| 			"checking frame set", | ||||
| 			zap.Uint64("pending_frame_number", f), | ||||
| @ -498,7 +515,9 @@ func (d *DataTimeReel) processPending( | ||||
| 				go func() { | ||||
| 					d.frames <- nextFrame | ||||
| 				}() | ||||
| 				limit-- | ||||
| 			} | ||||
| 
 | ||||
| 			if len(d.pending[f]) == 0 { | ||||
| 				d.logger.Debug("last next processing, clear list") | ||||
| 				delete(d.pending, f) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Cassandra Heart
						Cassandra Heart