Skip to content

Commit

Permalink
Create sssc_node.go
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 7, 2024
1 parent 6cc9e1b commit 77af82e
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions consensus/sssc/sssc_node.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package sssc

import (
"context"
"fmt"
"log"
"sync"

"github.com/KOSASIH/pi-nexus-autonomous-banking-network/consensus/sssc/pb"
"google.golang.org/grpc"
)

type SSSCNode struct {
pb.UnimplementedSSSCNodeServer
shardID string
nodes map[string]*grpc.ClientConn
}

func (n *SSSCNode) JoinShard(ctx context.Context, req *pb.JoinShardRequest) (*pb.JoinShardResponse, error) {
// TO DO: implement shard joining logic
log.Printf("Received join shard request from %s", req.NodeID)
n.nodes[req.NodeID] = req.Conn
return &pb.JoinShardResponse{Result: "success"}, nil
}

func (n *SSSCNode) ProposeBlock(ctx context.Context, req *pb.ProposeBlockRequest) (*pb.ProposeBlockResponse, error) {
// TO DO: implement block proposal logic
log.Printf("Received propose block request from %s", req.NodeID)
return &pb.ProposeBlockResponse{Result: "success"}, nil
}

func main() {
lis, err := net.Listen("tcp", ":50053")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}

srv := grpc.NewServer()
pb.RegisterSSSCNodeServer(srv, &SSSCNode{shardID: "shard-1", nodes: make(map[string]*grpc.ClientConn)})

log.Println("SSSC node listening on port 50053")
srv.Serve(lis)
}

0 comments on commit 77af82e

Please sign in to comment.