AcceptSolution accepts solutions from miners and construct corresponding shares to add into current active claim. It returns true when the share is successfully added, false otherwise. A share can only be added when it's counter is greater than the maximum counter of the last verified claim
(s smartpool.Solution)
| 84 | // A share can only be added when it's counter is greater than the maximum |
| 85 | // counter of the last verified claim |
| 86 | func (sp *SmartPool) AcceptSolution(s smartpool.Solution) bool { |
| 87 | share := sp.ShareReceiver.AcceptSolution(s) |
| 88 | sp.counterMu.RLock() |
| 89 | defer sp.counterMu.RUnlock() |
| 90 | if share.FullSolution() { |
| 91 | smartpool.Output.Printf("-->Yay! We found potential block!<--\n") |
| 92 | sp.NetworkClient.SubmitSolution(s) |
| 93 | } |
| 94 | if share.Counter().Cmp(sp.LatestCounter) <= 0 { |
| 95 | smartpool.Output.Printf("Share's counter (0x%s) is lower than last claim max counter (0x%s)\n", share.Counter().Text(16), sp.LatestCounter.Text(16)) |
| 96 | } |
| 97 | if share == nil || share.Counter().Cmp(sp.LatestCounter) <= 0 { |
| 98 | smartpool.Output.Printf("Share is discarded.\n") |
| 99 | return false |
| 100 | } |
| 101 | sp.ClaimRepo.AddShare(share) |
| 102 | smartpool.Output.Printf(".") |
| 103 | return true |
| 104 | } |
| 105 | |
| 106 | // GetCurrentClaim returns new claim containing unsubmitted shares. If there |
| 107 | // is no new shares, it returns nil. |
nothing calls this directly
no test coverage detected