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

Method AcceptSolution

protocol/smartpool.go:86–104  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

84// A share can only be added when it's counter is greater than the maximum
85// counter of the last verified claim
86func (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.

Callers

nothing calls this directly

Calls 6

AcceptSolutionMethod · 0.65
FullSolutionMethod · 0.65
PrintfMethod · 0.65
SubmitSolutionMethod · 0.65
CounterMethod · 0.65
AddShareMethod · 0.65

Tested by

no test coverage detected