Skip to content
Snippets Groups Projects
Commit 717859b2 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

started woprking on API

parent 26a65e1c
No related branches found
No related tags found
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
...@@ -66,6 +66,7 @@ func (r Request) String() string { ...@@ -66,6 +66,7 @@ func (r Request) String() string {
r.dhKey.Text(10), r.tag, r.maxParts) r.dhKey.Text(10), r.tag, r.maxParts)
} }
//
func (r Request) Respond(payload []byte, cmixParams cmix.CMIXParams, func (r Request) Respond(payload []byte, cmixParams cmix.CMIXParams,
timeout time.Duration) ([]id.Round, error) { timeout time.Duration) ([]id.Round, error) {
// make sure this has only been run once // make sure this has only been run once
...@@ -104,6 +105,8 @@ func (r Request) Respond(payload []byte, cmixParams cmix.CMIXParams, ...@@ -104,6 +105,8 @@ func (r Request) Respond(payload []byte, cmixParams cmix.CMIXParams,
Metadata: nil, Metadata: nil,
} }
failed := uint32(0)
for i := 0; i < len(parts); i++ { for i := 0; i < len(parts); i++ {
// fixme: handle the case where a send fails, also on failures, // fixme: handle the case where a send fails, also on failures,
// unset use // unset use
...@@ -114,6 +117,7 @@ func (r Request) Respond(payload []byte, cmixParams cmix.CMIXParams, ...@@ -114,6 +117,7 @@ func (r Request) Respond(payload []byte, cmixParams cmix.CMIXParams,
round, ephID, err := r.net.Send(r.sender, partFP, svc, ecrPart, mac, round, ephID, err := r.net.Send(r.sender, partFP, svc, ecrPart, mac,
cmixParams) cmixParams)
if err != nil { if err != nil {
atomic.AddUint32(&failed, 1)
jww.ERROR.Printf("Failed to send single-use response CMIX "+ jww.ERROR.Printf("Failed to send single-use response CMIX "+
"message part %d: %+v", j, err) "message part %d: %+v", j, err)
} }
...@@ -128,13 +132,21 @@ func (r Request) Respond(payload []byte, cmixParams cmix.CMIXParams, ...@@ -128,13 +132,21 @@ func (r Request) Respond(payload []byte, cmixParams cmix.CMIXParams,
// Wait for all go routines to finish // Wait for all go routines to finish
wg.Wait() wg.Wait()
if failed > 0 {
return nil, errors.Errorf("One or more send failed for the " +
"response, the response will be handleable and will timeout")
}
jww.DEBUG.Printf("Sent %d single-use response CMIX messages to %s.", jww.DEBUG.Printf("Sent %d single-use response CMIX messages to %s.",
len(parts), r.sender) len(parts), r.sender)
// Count the number of rounds // Count the number of rounds
roundMap := map[id.Round]struct{}{} roundMap := map[id.Round]struct{}{}
for _, roundID := range rounds { for _, roundID := range rounds {
roundMap[roundID] = struct{}{} if roundID != 0 {
roundMap[roundID] = struct{}{}
}
} }
// Wait until the result tracking responds // Wait until the result tracking responds
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment