func RunDialRound(client *vrpc.Client, round uint32, onions [][]byte) error { spans := concurrency.Spans(len(onions), 4000) calls := make([]*vrpc.Call, len(spans)) concurrency.ParallelFor(len(calls), func(p *concurrency.P) { for i, ok := p.Next(); ok; i, ok = p.Next() { span := spans[i] calls[i] = &vrpc.Call{ Method: "DialService.Add", Args: &DialAddArgs{ Round: round, Onions: onions[span.Start : span.Start+span.Count], }, Reply: nil, } } }) if err := client.CallMany(calls); err != nil { return fmt.Errorf("Add: %s", err) } if err := client.Call("DialService.Close", round, nil); err != nil { return fmt.Errorf("Close: %s", err) } return nil }
func RunConvoRound(client *vrpc.Client, round uint32, onions [][]byte) ([][]byte, error) { openArgs := &ConvoOpenArgs{ Round: round, NumIncoming: len(onions), } if err := client.Call("ConvoService.Open", openArgs, nil); err != nil { return nil, fmt.Errorf("Open: %s", err) } spans := concurrency.Spans(len(onions), 4000) calls := make([]*vrpc.Call, len(spans)) concurrency.ParallelFor(len(calls), func(p *concurrency.P) { for i, ok := p.Next(); ok; i, ok = p.Next() { span := spans[i] calls[i] = &vrpc.Call{ Method: "ConvoService.Add", Args: &ConvoAddArgs{ Round: round, Offset: span.Start, Onions: onions[span.Start : span.Start+span.Count], }, Reply: nil, } } }) if err := client.CallMany(calls); err != nil { return nil, fmt.Errorf("Add: %s", err) } if err := client.Call("ConvoService.Close", round, nil); err != nil { return nil, fmt.Errorf("Close: %s", err) } concurrency.ParallelFor(len(calls), func(p *concurrency.P) { for i, ok := p.Next(); ok; i, ok = p.Next() { span := spans[i] calls[i] = &vrpc.Call{ Method: "ConvoService.Get", Args: &ConvoGetArgs{ Round: round, Offset: span.Start, Count: span.Count, }, Reply: new(ConvoGetResult), } } }) if err := client.CallMany(calls); err != nil { return nil, fmt.Errorf("Get: %s", err) } replies := make([][]byte, len(onions)) concurrency.ParallelFor(len(calls), func(p *concurrency.P) { for i, ok := p.Next(); ok; i, ok = p.Next() { span := spans[i] copy(replies[span.Start:span.Start+span.Count], calls[i].Reply.(*ConvoGetResult).Onions) } }) if err := client.Call("ConvoService.Delete", round, nil); err != nil { return nil, fmt.Errorf("Delete: %s", err) } return replies, nil }
func NewDialRound(client *vrpc.Client, round uint32) error { return client.Call("DialService.NewRound", round, nil) }
func NewConvoRound(client *vrpc.Client, round uint32) error { return client.Call("ConvoService.NewRound", round, nil) }