-
Notifications
You must be signed in to change notification settings - Fork 179
/
main.go
49 lines (42 loc) · 1.48 KB
/
main.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
package main
import (
"github.com/spf13/pflag"
"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/engine/ghost/engine"
"github.com/onflow/flow-go/module"
"github.com/onflow/flow-go/network"
"github.com/onflow/flow-go/network/validator"
"github.com/onflow/flow-go/utils/grpcutils"
)
func main() {
var (
rpcConf engine.Config
)
nodeBuilder := cmd.FlowNode("ghost")
nodeBuilder.ExtraFlags(func(flags *pflag.FlagSet) {
flags.StringVarP(&rpcConf.ListenAddr, "rpc-addr", "r", "localhost:9000", "the address the GRPC server listens on")
flags.UintVar(&rpcConf.MaxMsgSize, "rpc-max-message-size", grpcutils.DefaultMaxMsgSize, "the maximum message size in bytes for messages sent or received over grpc")
})
if err := nodeBuilder.Initialize(); err != nil {
nodeBuilder.Logger.Fatal().Err(err).Send()
}
nodeBuilder.
Module("message validators", func(node *cmd.NodeConfig) error {
validators := []network.MessageValidator{
// filter out messages sent by this node itself
validator.ValidateNotSender(node.Me.NodeID()),
// but retain all the 1-k messages even if they are not intended for this node
}
node.MsgValidators = validators
return nil
}).
Component("RPC engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
rpcEng, err := engine.New(node.Network, node.Logger, node.Me, node.State, rpcConf)
return rpcEng, err
})
node, err := nodeBuilder.Build()
if err != nil {
nodeBuilder.Logger.Fatal().Err(err).Send()
}
node.Run()
}