-
Notifications
You must be signed in to change notification settings - Fork 0
/
transport.go
63 lines (49 loc) · 1.69 KB
/
transport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package node
import (
"github.com/ChristianMct/helium"
"github.com/ChristianMct/helium/coordinator"
"github.com/ChristianMct/helium/protocols"
"golang.org/x/net/context"
)
type protocolTransport struct {
outshares, inshares chan protocols.Share
getAggregationOutput func(context.Context, protocols.Descriptor) (*protocols.AggregationOutput, error)
}
func (n *protocolTransport) IncomingShares() <-chan protocols.Share {
return n.inshares
}
func (n *protocolTransport) OutgoingShares() chan<- protocols.Share {
return n.outshares
}
func (n *protocolTransport) GetAggregationOutput(ctx context.Context, pd protocols.Descriptor) (*protocols.AggregationOutput, error) {
return n.getAggregationOutput(ctx, pd)
}
type computeTransport struct {
protocolTransport
putCiphertext func(ctx context.Context, ct helium.Ciphertext) error
getCiphertext func(ctx context.Context, ctID helium.CiphertextID) (*helium.Ciphertext, error)
}
func (n *computeTransport) PutCiphertext(ctx context.Context, ct helium.Ciphertext) error {
return n.putCiphertext(ctx, ct)
}
func (n *computeTransport) GetCiphertext(ctx context.Context, ctID helium.CiphertextID) (*helium.Ciphertext, error) {
return n.getCiphertext(ctx, ctID)
}
type protocolCoordinator struct {
incoming, outgoing chan protocols.Event
}
func (hcp *protocolCoordinator) Incoming() <-chan protocols.Event {
return hcp.incoming
}
func (hcp *protocolCoordinator) Outgoing() chan<- protocols.Event {
return hcp.outgoing
}
type coordinatorT struct {
incoming, outgoing chan coordinator.Event
}
func (hcp *coordinatorT) Incoming() <-chan coordinator.Event {
return hcp.incoming
}
func (hcp *coordinatorT) Outgoing() chan<- coordinator.Event {
return hcp.outgoing
}