Skip to content

Commit

Permalink
pretty print event logs and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMct committed Apr 22, 2024
1 parent 264ad68 commit 22182db
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
3 changes: 1 addition & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ func (hc *HeliumClient) Register(ctx context.Context) (upstream *coordinator.Cha
}

ev := api.ToNodeEvent(apiEvent)
log.Printf("[client] received event: %s", ev)
eventsStream <- ev
log.Printf("[client] fwd event: %s", ev)
log.Printf("[client] new event: %s", ev)
}
}()

Expand Down
15 changes: 15 additions & 0 deletions node/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ func (ev Event) IsSetup() bool {
return ev.SetupEvent != nil
}

func (ev Event) String() string {
switch {
case ev.SetupEvent != nil:
return fmt.Sprintf("SETUP PROTOCOL %s", ev.SetupEvent.String())
case ev.ComputeEvent != nil:
switch {
case ev.ComputeEvent.CircuitEvent != nil:
return fmt.Sprintf("COMPUTE CIRCUIT %s", ev.ComputeEvent.CircuitEvent.String())
case ev.ComputeEvent.ProtocolEvent != nil:
return fmt.Sprintf("COMPUTE PROTOCOL %s", ev.ComputeEvent.ProtocolEvent.String())
}
}
return "INVALID EVENT"
}

type Coordinator coordinator.Coordinator[Event]

type setupCoordinator struct {
Expand Down
8 changes: 4 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ func (node *Node) createNewSession(sessParams sessions.Parameters) (sess *sessio
return sess, nil
}

func (s *Node) PutOperand(opl circuits.OperandLabel, op *circuits.Operand) error {
return s.compute.PutOperand(opl, op)
func (node *Node) PutOperand(opl circuits.OperandLabel, op *circuits.Operand) error {
return node.compute.PutOperand(opl, op)
}

func (s *Node) GetOperand(opl circuits.OperandLabel) (*circuits.Operand, bool) {
return s.compute.GetOperand(opl)
func (node *Node) GetOperand(opl circuits.OperandLabel) (*circuits.Operand, bool) {
return node.compute.GetOperand(opl)
}

// func (node *Node) sendShares(ctx context.Context) {
Expand Down
8 changes: 4 additions & 4 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,12 @@ func (hsv *HeliumServer) PutCiphertext(inctx context.Context, apict *pb.Cipherte
return &pb.CiphertextID{CiphertextId: string(ct.ID)}, nil
}

func (s *HeliumServer) PutOperand(opl circuits.OperandLabel, op *circuits.Operand) error {
return s.helperNode.PutOperand(opl, op)
func (hsv *HeliumServer) PutOperand(opl circuits.OperandLabel, op *circuits.Operand) error {
return hsv.helperNode.PutOperand(opl, op)
}

func (s *HeliumServer) GetOperand(opl circuits.OperandLabel) (*circuits.Operand, bool) {
return s.helperNode.GetOperand(opl)
func (hsv *HeliumServer) GetOperand(opl circuits.OperandLabel) (*circuits.Operand, bool) {
return hsv.helperNode.GetOperand(opl)
}

func (hsv *HeliumServer) Logf(msg string, v ...any) {
Expand Down
2 changes: 1 addition & 1 deletion services/compute/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func (s *Service) sendCompletedPdToCircuit(pd protocols.Descriptor) error {
c, has := s.runningCircuits[cid]
s.runningCircuitsMu.RUnlock()
if !has {
panic(fmt.Errorf("circuit is not runnig: %s", cid))
panic(fmt.Errorf("circuit is not running: %s", cid))
}

return c.CompletedProtocol(pd)
Expand Down

0 comments on commit 22182db

Please sign in to comment.