github.com/annchain/OG@v0.0.9/node/node2.go (about) 1 package node 2 3 import ( 4 "fmt" 5 "github.com/annchain/OG/arefactor/common/utilfuncs" 6 "github.com/annchain/OG/core" 7 "github.com/annchain/OG/og/account" 8 "github.com/annchain/OG/plugin/community" 9 "github.com/latifrons/soccerdash" 10 "github.com/spf13/viper" 11 ) 12 13 // Node is the basic entrypoint for all modules to start. 14 type Node2 struct { 15 PrivateInfoProvider account.PrivateInfoProvider 16 PhysicalCommunicator community.LibP2pPhysicalCommunicator 17 components []Component 18 networkId uint32 19 } 20 21 func (n *Node2) InitDefault() { 22 n.components = []Component{} 23 } 24 25 func (n *Node2) Setup() { 26 n.PrivateInfoProvider = &core.LocalPrivateInfoProvider{} 27 28 hostname := utilfuncs.getHostname() 29 30 // load identity from config 31 reporter := &soccerdash.Reporter{ 32 Id: fmt.Sprintf(hostname), 33 TargetAddress: viper.GetString("report.url"), 34 } 35 36 n.components = append(n.components, reporter) 37 38 // Node must know who he is first 39 privateInfo := n.PrivateInfoProvider.PrivateInfo() 40 // Init peer to peer 41 42 PhysicalCommunicator 43 44 // network id is configured either in config.toml or env variable 45 n.networkId = viper.GetUint32("p2p.network_id") 46 if n.networkId == 0 { 47 n.networkId = defaultNetworkId 48 } 49 50 }