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

Method Submit

protocol/smartpool.go:131–165  ·  view source on GitHub ↗

Submit does all the protocol that communicates with the contract to submit the claim then verify it. It returns true when the claim is fully verified and accepted by the contract. It returns false otherwise.

()

Source from the content-addressed store, hash-verified

129// It returns true when the claim is fully verified and accepted by the
130// contract. It returns false otherwise.
131func (sp *SmartPool) Submit() (bool, error) {
132 claim := sp.SealClaim()
133 if claim == nil {
134 return false, nil
135 }
136 if sp.PoolMonitor.RequireClientUpdate() {
137 return false, errors.New("client update required")
138 }
139 if sp.PoolMonitor.RequireContractUpdate() {
140 return false, errors.New("contract update required")
141 }
142 smartpool.Output.Printf("Submitting the claim with %d shares.\n", claim.NumShares().Int64())
143 subErr := sp.Contract.SubmitClaim(claim)
144 if subErr != nil {
145 smartpool.Output.Printf("Got error submitting claim to contract: %s\n", subErr)
146 return false, subErr
147 }
148 smartpool.Output.Printf("The claim is successfully submitted.\n")
149 smartpool.Output.Printf("Waiting for verification index...")
150 index := sp.GetVerificationIndex(claim)
151 smartpool.Output.Printf("Verification index of %d has been requested. Submitting claim verification.\n", index.Int64())
152 if sp.PoolMonitor.RequireClientUpdate() {
153 return false, errors.New("client update required")
154 }
155 if sp.PoolMonitor.RequireContractUpdate() {
156 return false, errors.New("contract update required")
157 }
158 verErr := sp.Contract.VerifyClaim(index, claim)
159 if verErr != nil {
160 smartpool.Output.Printf("%s\n", verErr)
161 return false, verErr
162 }
163 smartpool.Output.Printf("Claim is successfully verified.\n")
164 return true, nil
165}
166
167func (sp *SmartPool) shouldStop(err error) bool {
168 if err == nil {

Calls 8

SealClaimMethod · 0.95
GetVerificationIndexMethod · 0.95
RequireClientUpdateMethod · 0.65
RequireContractUpdateMethod · 0.65
PrintfMethod · 0.65
NumSharesMethod · 0.65
SubmitClaimMethod · 0.65
VerifyClaimMethod · 0.65