]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cmd/nncp-caller/main.go
On demand calling
[nncp.git] / src / cmd / nncp-caller / main.go
index 826033c334526166c530c1c8330226dac055080c..f7ab13c23299cc301608920776df84f417266042 100644 (file)
@@ -134,6 +134,25 @@ func main() {
                                                node.Busy = true
                                                node.Unlock()
 
+                                               if call.WhenTxExists && call.Xx != "TRx" {
+                                                       ctx.LogD("caller", sds, "checking tx existence")
+                                                       txExists := false
+                                                       for job := range ctx.Jobs(node.Id, nncp.TTx) {
+                                                               job.Fd.Close()
+                                                               if job.PktEnc.Nice > call.Nice {
+                                                                       continue
+                                                               }
+                                                               txExists = true
+                                                       }
+                                                       if !txExists {
+                                                               ctx.LogD("caller", sds, "no tx")
+                                                               node.Lock()
+                                                               node.Busy = false
+                                                               node.Unlock()
+                                                               continue
+                                                       }
+                                               }
+
                                                var autoTossFinish chan struct{}
                                                var autoTossBadCode chan bool
                                                if call.AutoToss {