- state.ctx.LogD("sp-process", SdsAdd(sdsp, SDS{
- "hash": ToBase32(freq.Hash[:]),
- "offset": strconv.FormatInt(int64(freq.Offset), 10),
- }), "queueing")
- state.Lock()
- state.queueTheir = append(state.queueTheir, &freq)
- state.Unlock()
+ sdsp["hash"] = ToBase32(freq.Hash[:])
+ sdsp["offset"] = strconv.FormatInt(int64(freq.Offset), 10)
+ state.Ctx.LogD("sp-process", sdsp, "queueing")
+ nice, exists := state.infosOurSeen[*freq.Hash]
+ if exists {
+ if state.onlyPkts == nil || !state.onlyPkts[*freq.Hash] {
+ state.Lock()
+ insertIdx := 0
+ var freqWithNice *FreqWithNice
+ for insertIdx, freqWithNice = range state.queueTheir {
+ if freqWithNice.nice > nice {
+ break
+ }
+ }
+ state.queueTheir = append(state.queueTheir, nil)
+ copy(state.queueTheir[insertIdx+1:], state.queueTheir[insertIdx:])
+ state.queueTheir[insertIdx] = &FreqWithNice{&freq, nice}
+ state.Unlock()
+ } else {
+ state.Ctx.LogD("sp-process", sdsp, "skipping")
+ }
+ } else {
+ state.Ctx.LogD("sp-process", sdsp, "unknown")
+ }