MCPcopy Index your code
hub / github.com/SmartPool/smartpool-client / Run

Method Run

protocol/smartpool.go:212–243  ·  view source on GitHub ↗

Run can be called at most once to start a loop to submit and verify claims after an interval. If the loop has not been started, it starts the loop and return true, it return false otherwise.

()

Source from the content-addressed store, hash-verified

210// If the loop has not been started, it starts the loop and return true, it
211// return false otherwise.
212func (sp *SmartPool) Run() bool {
213 sp.runMu.Lock()
214 defer sp.runMu.Unlock()
215 if sp.Register(sp.MinerAddress) {
216 if sp.loopStarted {
217 smartpool.Output.Printf("Warning: calling Run() multiple times\n")
218 return false
219 }
220 err := sp.NetworkClient.Configure(
221 sp.ContractAddress,
222 sp.ExtraData,
223 )
224 if err != nil {
225 return false
226 }
227 for {
228 if sp.NetworkClient.ReadyToMine() {
229 smartpool.Output.Printf("The network is ready for mining.\n")
230 sp.ticker = time.Tick(sp.SubmitInterval)
231 go sp.actOnTick()
232 break
233 }
234 smartpool.Output.Printf("The network is not ready for mining yet. Retry in 10s...\n")
235 time.Sleep(10 * time.Second)
236 }
237 sp.loopStarted = true
238 smartpool.Output.Printf("Share collector is running...")
239 return true
240 } else {
241 return false
242 }
243}
244
245func NewSmartPool(
246 pm smartpool.PoolMonitor, sr smartpool.ShareReceiver,

Callers 7

mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
StartMethod · 0.80

Calls 5

RegisterMethod · 0.95
actOnTickMethod · 0.95
PrintfMethod · 0.65
ConfigureMethod · 0.65
ReadyToMineMethod · 0.65