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 444dc4e commit 7af4ca4
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions consensus/sssc/advanced/sssc_node.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package sssc

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

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

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

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 (n *SSSCNode) VoteBlock(ctx context.Context, req *pb.VoteBlockRequest) (*pb.VoteBlockResponse, error) {
// TO DO: implement block voting logic
log.Printf("Received vote block request from %s", req.NodeID)
return &pb.VoteBlockResponse{Result: "success"}, nil
}

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

db, err := badger.Open("sssc.db")
if err != nil {
log

0 comments on commit 7af4ca4

Please sign in to comment.