MCPcopy Create free account
hub / github.com/DOSNetwork/core / Start

Method Start

dosnode/dosnode.go:135–213  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133}
134
135func (d *DosNode) Start() {
136 d.logger.Event("peersUpdate", map[string]interface{}{"numOfPeers": 0})
137 d.state = "Working"
138 var wg sync.WaitGroup
139 wg.Add(5)
140 go func() {
141 defer wg.Done()
142 d.startRESTServer()
143 d.logger.Info("[DOS] End RESTServer")
144 d.End()
145 }()
146 t := time.Now().Add(60 * time.Second)
147 if err := d.chain.Connect(d.config.ChainNodePool, t); err != nil {
148 d.logger.Error(err)
149 return
150 }
151 go func() {
152 defer wg.Done()
153 d.onchainLoop()
154 d.logger.Info("[DOS] End ONCHAIN Loop")
155 d.End()
156 }()
157 go func() {
158 defer wg.Done()
159 d.p.Listen()
160 d.logger.Info("[DOS] End P2P Loop")
161 d.End()
162 }()
163 go func() {
164 defer wg.Done()
165 d.queryLoop()
166 d.logger.Info("[DOS] End Query Loop")
167 d.End()
168 }()
169 go func() {
170 defer wg.Done()
171 d.dkg.Loop()
172 d.logger.Info("[DOS] End DKG Loop")
173
174 d.End()
175 }()
176
177 retry, num := 0, 0
178 var err error
179 for {
180 //Bootstrap p2p network
181 if d.chain.BootStrapUrl() != "" {
182 d.logger.Info(fmt.Sprintf("BootStrapUrl : %s", d.chain.BootStrapUrl()))
183
184 ips := getBootIps(d.chain.BootStrapUrl())
185 if len(ips) != 0 {
186 d.bootStrapIPs = append(d.bootStrapIPs, ips...)
187 d.bootStrapIPs = unique(d.bootStrapIPs)
188 }
189 }
190
191 d.logger.Info("Bootstraping ...")
192 num, err = d.p.Join(d.bootStrapIPs)

Callers 2

actionStartFunction · 0.95
buildComponentsFunction · 0.80

Calls 15

startRESTServerMethod · 0.95
EndMethod · 0.95
onchainLoopMethod · 0.95
queryLoopMethod · 0.95
getBootIpsFunction · 0.85
uniqueFunction · 0.85
UpdateConfigMethod · 0.80
EventMethod · 0.65
InfoMethod · 0.65
ConnectMethod · 0.65
ErrorMethod · 0.65
ListenMethod · 0.65

Tested by 1

buildComponentsFunction · 0.64