From 4faefad7a51081d87c12cdd3ad5f6030dd77798a Mon Sep 17 00:00:00 2001 From: wit liu <765765346@qq.com> Date: Fri, 14 Nov 2025 18:59:39 +0800 Subject: [PATCH] p2p: remove unused ticketRefByWaitTime and nextTicketReg (#1709) --- p2p/discv5/ticket.go | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/p2p/discv5/ticket.go b/p2p/discv5/ticket.go index 164ea0690a..159920178f 100644 --- a/p2p/discv5/ticket.go +++ b/p2p/discv5/ticket.go @@ -23,7 +23,6 @@ import ( "fmt" "math" "math/rand" - "sort" "time" "github.com/XinFinOrg/XDPoSChain/common" @@ -140,7 +139,6 @@ type ticketStore struct { lastBucketFetched timeBucket nextTicketCached *ticketRef - nextTicketReg mclock.AbsTime searchTopicMap map[Topic]searchTopic nextTopicQueryCleanup mclock.AbsTime @@ -287,39 +285,6 @@ func (s *ticketStore) ticketsInWindow(topic Topic) []ticketRef { return tickets } -func (s *ticketStore) removeExcessTickets(t Topic) { - tickets := s.ticketsInWindow(t) - if len(tickets) <= wantTicketsInWindow { - return - } - sort.Sort(ticketRefByWaitTime(tickets)) - for _, r := range tickets[wantTicketsInWindow:] { - s.removeTicketRef(r) - } -} - -type ticketRefByWaitTime []ticketRef - -// Len is the number of elements in the collection. -func (s ticketRefByWaitTime) Len() int { - return len(s) -} - -func (ref ticketRef) waitTime() mclock.AbsTime { - return ref.t.regTime[ref.idx] - ref.t.issueTime -} - -// Less reports whether the element with -// index i should sort before the element with index j. -func (s ticketRefByWaitTime) Less(i, j int) bool { - return s[i].waitTime() < s[j].waitTime() -} - -// Swap swaps the elements with indexes i and j. -func (s ticketRefByWaitTime) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - func (s *ticketStore) addTicketRef(r ticketRef) { topic := r.t.topics[r.idx] tickets := s.tickets[topic]