]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/jobs.go
Intermediate .nock packets step
[nncp.git] / src / jobs.go
index 3dc6bd431e3641439ae6d5f2c3b00df0f9052670..3e97b2ea52f89860a22b2c4c4081ff774cd1e8ac 100644 (file)
@@ -20,6 +20,7 @@ package nncp
 import (
        "os"
        "path/filepath"
+       "strings"
 
        xdr "github.com/davecgh/go-xdr/xdr2"
 )
@@ -38,7 +39,7 @@ type Job struct {
        HshValue *[32]byte
 }
 
-func (ctx *Ctx) Jobs(nodeId *NodeId, xx TRxTx) chan Job {
+func (ctx *Ctx) jobsFind(nodeId *NodeId, xx TRxTx, nock bool) chan Job {
        rxPath := filepath.Join(ctx.Spool, nodeId.String(), string(xx))
        jobs := make(chan Job, 16)
        go func() {
@@ -53,7 +54,17 @@ func (ctx *Ctx) Jobs(nodeId *NodeId, xx TRxTx) chan Job {
                        return
                }
                for _, fi := range fis {
-                       hshValue, err := Base32Codec.DecodeString(fi.Name())
+                       var hshValue []byte
+                       if nock {
+                               if !strings.HasSuffix(fi.Name(), NoCKSuffix) {
+                                       continue
+                               }
+                               hshValue, err = Base32Codec.DecodeString(
+                                       strings.TrimSuffix(fi.Name(), NoCKSuffix),
+                               )
+                       } else {
+                               hshValue, err = Base32Codec.DecodeString(fi.Name())
+                       }
                        if err != nil {
                                continue
                        }
@@ -87,3 +98,11 @@ func (ctx *Ctx) Jobs(nodeId *NodeId, xx TRxTx) chan Job {
        }()
        return jobs
 }
+
+func (ctx *Ctx) Jobs(nodeId *NodeId, xx TRxTx) chan Job {
+       return ctx.jobsFind(nodeId, xx, false)
+}
+
+func (ctx *Ctx) JobsNoCK(nodeId *NodeId) chan Job {
+       return ctx.jobsFind(nodeId, TRx, true)
+}