-
Notifications
You must be signed in to change notification settings - Fork 179
/
main.go
47 lines (40 loc) · 1.27 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
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"
)
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")
})
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()
}