예제 #1
0
파일: dial.go 프로젝트: ak-67/vuvuzela
func RunDialRound(client *vrpc.Client, round uint32, onions [][]byte) error {
	spans := Spans(len(onions), 4000)
	calls := make([]*vrpc.Call, len(spans))

	ParallelFor(len(calls), func(p *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
}
예제 #2
0
파일: convo.go 프로젝트: ak-67/vuvuzela
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 := Spans(len(onions), 4000)
	calls := make([]*vrpc.Call, len(spans))

	ParallelFor(len(calls), func(p *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)
	}

	ParallelFor(len(calls), func(p *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))
	ParallelFor(len(calls), func(p *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
}
예제 #3
0
파일: dial.go 프로젝트: ak-67/vuvuzela
func NewDialRound(client *vrpc.Client, round uint32) error {
	return client.Call("DialService.NewRound", round, nil)
}
예제 #4
0
파일: convo.go 프로젝트: ak-67/vuvuzela
func NewConvoRound(client *vrpc.Client, round uint32) error {
	return client.Call("ConvoService.NewRound", round, nil)
}