MCPcopy Create free account
hub / github.com/SmartPool/smartpool-client / AcceptSolution

Method AcceptSolution

ethereum/work_pool.go:22–44  ·  view source on GitHub ↗

AcceptSolution takes solution and find corresponding work and return associated share. It returns nil if the work is not found.

(s smartpool.Solution)

Source from the content-addressed store, hash-verified

20// associated share.
21// It returns nil if the work is not found.
22func (wp WorkPool) AcceptSolution(s smartpool.Solution) smartpool.Share {
23 work := wp[s.WorkID()]
24 if work == nil {
25 smartpool.Output.Printf("work (%v) doesn't exist in workpool (len: %d)\n", s, len(wp))
26 return nil
27 }
28 share := work.AcceptSolution(s).(*Share)
29 if share.SolutionState == FullBlockSolution {
30 delete(wp, s.WorkID())
31 }
32 if share.SolutionState == InvalidShare {
33 smartpool.Output.Printf("Solution (%v) is invalid\n", s)
34 return nil
35 } else {
36 // smartpool.Output.Printf(
37 // "Create share for work: ID: %s - createdAt: %s - timestamp: 0x%s\n",
38 // work.ID(),
39 // work.CreatedAt(),
40 // work.BlockHeader().Time.Text(16),
41 // )
42 return share
43 }
44}
45
46func (wp WorkPool) AddWork(w *Work) {
47 wp[w.ID()] = w

Callers 2

Calls 3

WorkIDMethod · 0.65
PrintfMethod · 0.65
AcceptSolutionMethod · 0.65

Tested by 2