Skip to content

Commit

Permalink
[Node][5/N]Add main function for DA node (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Jun 30, 2023
1 parent 8a28837 commit 4ce6193
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ require (
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/tools v0.10.1-0.20230622221742-0622ad2359a7 // indirect
google.golang.org/protobuf v1.30.0
google.golang.org/protobuf v1.31.0
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
64 changes: 64 additions & 0 deletions node/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package main

import (
"context"
"fmt"
"log"
"os"

"github.com/urfave/cli"

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/node"
"github.com/Layr-Labs/eigenda/node/flags"
"github.com/Layr-Labs/eigenda/node/grpc"
)

var (
Version = ""
GitCommit = ""
GitDate = ""
)

func main() {
app := cli.NewApp()
app.Flags = flags.Flags
app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate)
app.Name = "da-node"
app.Usage = "EigenDA Node"
app.Description = "Service for receiving and storing encoded blobs from disperser"

app.Action = NodeMain
err := app.Run(os.Args)
if err != nil {
log.Fatalln("Application failed.", "Message:", err)
}

select {}
}

func NodeMain(ctx *cli.Context) error {
log.Println("Initializing Node")
config, err := node.NewConfig(ctx)
if err != nil {
return err
}

// Create the node.
var logger common.Logger
node, err := node.NewNode(config, logger)
if err != nil {
return err
}

err = node.Start(context.Background())
if err != nil {
return err
}

// Creates the GRPC server.
server := grpc.NewServer(config, node, logger)
server.Start()

return nil
}
2 changes: 1 addition & 1 deletion node/grpc/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package grpc

import (
"context"
Expand Down

0 comments on commit 4ce6193

Please sign in to comment.