@cryptotaxi247 / kubo / commits / 1159abd83

cmds: can't call SetError after SetOutput

License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Jan 25, 2018 at 18:02 UTC 1159abd83e60a38037f2b68ea7fea56771a31d5e
1 file changed +12 -12
core/commands/dht.go
+12 -12
@@ -174,9 +174,6 @@ var findProvidersDhtCmd = &cmds.Command{
174 return
175 }
176
177 - outChan := make(chan interface{})
178 - res.SetOutput((<-chan interface{})(outChan))
179 -
177 events := make(chan *notif.QueryEvent)
178 ctx := notif.RegisterForQueryEvents(req.Context(), events)
179
@@ -186,6 +183,9 @@ var findProvidersDhtCmd = &cmds.Command{
183 return
184 }
185
186 + outChan := make(chan interface{})
187 + res.SetOutput((<-chan interface{})(outChan))
188 +
189 pchan := dht.FindProvidersAsync(ctx, c, numProviders)
190 go func() {
191 defer close(outChan)
@@ -535,18 +535,18 @@ Different key types can specify other 'best' rules.
535 return
536 }
537
538 - outChan := make(chan interface{})
539 - res.SetOutput((<-chan interface{})(outChan))
540 -
541 - events := make(chan *notif.QueryEvent)
542 - ctx := notif.RegisterForQueryEvents(req.Context(), events)
543 -
538 dhtkey, err := escapeDhtKey(req.Arguments()[0])
539 if err != nil {
540 res.SetError(err, cmdkit.ErrNormal)
541 return
542 }
543
544 + outChan := make(chan interface{})
545 + res.SetOutput((<-chan interface{})(outChan))
546 +
547 + events := make(chan *notif.QueryEvent)
548 + ctx := notif.RegisterForQueryEvents(req.Context(), events)
549 +
550 go func() {
551 defer close(outChan)
552 for e := range events {
@@ -650,9 +650,6 @@ NOTE: A value may not exceed 2048 bytes.
650 return
651 }
652
653 - outChan := make(chan interface{})
654 - res.SetOutput((<-chan interface{})(outChan))
655 -
653 events := make(chan *notif.QueryEvent)
654 ctx := notif.RegisterForQueryEvents(req.Context(), events)
655
@@ -662,6 +659,9 @@ NOTE: A value may not exceed 2048 bytes.
659 return
660 }
661
662 + outChan := make(chan interface{})
663 + res.SetOutput((<-chan interface{})(outChan))
664 +
665 data := req.Arguments()[1]
666
667 go func() {