]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cypherpunks.ru/nncp/sp.go
Forbid any later GNU GPL versions autousage
[nncp.git] / src / cypherpunks.ru / nncp / sp.go
index bcdda79f5834add00ca0a1345f92cd00c06556aa..7e2f7c3be104029977f94fa6e1cdc7b52aa89273 100644 (file)
@@ -4,8 +4,7 @@ Copyright (C) 2016-2019 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, version 3 of the License.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -949,18 +948,22 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        state.Ctx.LogD("sp-process", sdsp, "queueing")
                        nice, exists := state.infosOurSeen[*freq.Hash]
                        if exists {
-                               state.Lock()
-                               insertIdx := 0
-                               var freqWithNice *FreqWithNice
-                               for insertIdx, freqWithNice = range state.queueTheir {
-                                       if freqWithNice.nice > nice {
-                                               break
+                               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")
                                }
-                               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, "unknown")
                        }