github.com/koko1123/flow-go-1@v0.29.6/cmd/ghost/main.go (about) 1 package main 2 3 import ( 4 "github.com/spf13/pflag" 5 6 "github.com/koko1123/flow-go-1/cmd" 7 "github.com/koko1123/flow-go-1/engine/ghost/engine" 8 "github.com/koko1123/flow-go-1/module" 9 "github.com/koko1123/flow-go-1/network" 10 "github.com/koko1123/flow-go-1/network/validator" 11 ) 12 13 func main() { 14 var ( 15 rpcConf engine.Config 16 ) 17 18 nodeBuilder := cmd.FlowNode("ghost") 19 nodeBuilder.ExtraFlags(func(flags *pflag.FlagSet) { 20 flags.StringVarP(&rpcConf.ListenAddr, "rpc-addr", "r", "localhost:9000", "the address the GRPC server listens on") 21 }) 22 23 if err := nodeBuilder.Initialize(); err != nil { 24 nodeBuilder.Logger.Fatal().Err(err).Send() 25 } 26 27 nodeBuilder. 28 Module("message validators", func(node *cmd.NodeConfig) error { 29 validators := []network.MessageValidator{ 30 // filter out messages sent by this node itself 31 validator.ValidateNotSender(node.Me.NodeID()), 32 // but retain all the 1-k messages even if they are not intended for this node 33 } 34 node.MsgValidators = validators 35 return nil 36 }). 37 Component("RPC engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) { 38 rpcEng, err := engine.New(node.Network, node.Logger, node.Me, node.State, rpcConf) 39 return rpcEng, err 40 }) 41 42 node, err := nodeBuilder.Build() 43 if err != nil { 44 nodeBuilder.Logger.Fatal().Err(err).Send() 45 } 46 node.Run() 47 }