+
+func SPChecker(ctx *Ctx) {
+ for t := range spCheckerTasks {
+ pktName := Base32Codec.EncodeToString(t.hsh[:])
+ les := LEs{
+ {"XX", string(TRx)},
+ {"Node", t.nodeId},
+ {"Pkt", pktName},
+ }
+ SPCheckerWg.Add(1)
+ ctx.LogD("sp-checker", les, func(les LEs) string {
+ return fmt.Sprintf("Checksumming %s/rx/%s", ctx.NodeName(t.nodeId), pktName)
+ })
+ size, err := ctx.CheckNoCK(t.nodeId, t.hsh, t.mth)
+ les = append(les, LE{"Size", size})
+ if err != nil {
+ ctx.LogE("sp-checker", les, err, func(les LEs) string {
+ return fmt.Sprintf(
+ "Checksumming %s/rx/%s (%s)", ctx.NodeName(t.nodeId), pktName,
+ humanize.IBytes(uint64(size)),
+ )
+ })
+ SPCheckerWg.Done()
+ continue
+ }
+ ctx.LogI("sp-checker-done", les, func(les LEs) string {
+ return fmt.Sprintf(
+ "Packet %s is retreived (%s)",
+ pktName, humanize.IBytes(uint64(size)),
+ )
+ })
+ SPCheckerWg.Done()
+ go func(t SPCheckerTask) {
+ defer func() { recover() }()
+ t.done <- MarshalSP(SPTypeDone, SPDone{t.hsh})
+ }(t)
+ }
+}