Fix build error

This commit is contained in:
Neil Alexander 2021-11-04 16:30:49 +00:00
parent e7f7050163
commit 832f78ddf9
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -170,7 +170,8 @@ func Send(
// the transaction is still being worked on. The new client can wait // the transaction is still being worked on. The new client can wait
// for it to complete rather than creating more work. // for it to complete rather than creating more work.
index := string(request.Origin()) + "\000" + string(txnID) index := string(request.Origin()) + "\000" + string(txnID)
ch, ok := inFlightTxnsPerOrigin.LoadOrStore(index, make(chan util.JSONResponse, 1)) v, ok := inFlightTxnsPerOrigin.LoadOrStore(index, make(chan util.JSONResponse, 1))
ch := v.(chan util.JSONResponse)
if ok { if ok {
// This origin already submitted this txn ID to us, and the work // This origin already submitted this txn ID to us, and the work
// is still taking place, so we'll just wait for it to finish. // is still taking place, so we'll just wait for it to finish.
@ -181,7 +182,7 @@ func Send(
// If the caller gives up then return straight away. We don't // If the caller gives up then return straight away. We don't
// want to attempt to process what they sent us any further. // want to attempt to process what they sent us any further.
return util.JSONResponse{Code: http.StatusRequestTimeout} return util.JSONResponse{Code: http.StatusRequestTimeout}
case res := <-ch.(chan util.JSONResponse): case res := <-ch:
// The original task just finished processing so let's return // The original task just finished processing so let's return
// the result of it. // the result of it.
if res.Code == 0 { if res.Code == 0 {
@ -192,7 +193,7 @@ func Send(
} }
// Otherwise, store that we're currently working on this txn from // Otherwise, store that we're currently working on this txn from
// this origin. When we're done processing, close the channel. // this origin. When we're done processing, close the channel.
defer close(ch.(chan util.JSONResponse)) defer close(ch)
defer inFlightTxnsPerOrigin.Delete(index) defer inFlightTxnsPerOrigin.Delete(index)
t := txnReq{ t := txnReq{