// SubmitWork tries to inject a pow solution into the remote agent, returning
// whether the solution was accepted or not (not can be both a bad pow as well as
// any other error, like no work pending).
SubmitWork tries to inject a pow solution into the remote agent, returning
whether the solution was accepted or not (not can be both a bad pow as well as
any other error, like no work pending).
// SubmitWork tries to inject a pow solution into the remote agent returning // whether the solution was accepted or not ( not can be both a bad pow as well as // any other error like no work pending ) .
func (a *RemoteAgent) SubmitWork(strnonce, strAIHah, strhash, strminerAddr string) bool {
	a.mu.Lock()
	defer a.mu.Unlock()
	log.Info("YYYYYYYYYYYYYYYYYYYY", "nonce", strnonce, "AIHah", strAIHah, "header hash", strhash, "addr", strminerAddr)
	if len(strhash) != 66 || len(strAIHah) != 66 {
		log.Error("SubmitWork", "SubmitWork err, hash length wrong. nonce", strnonce, "AIHah", strAIHah, "header hash", strhash)
		return false
	}
	if len(strnonce) > 10 {
		log.Error("SubmitWork", "SubmitWork err, nonce too long ", strnonce)
		return false
	}
	hash := common.HexToHash(strhash)
	AIHah := common.HexToHash(strAIHah)
	nonce, err := conversType(strnonce)
	if err != nil {
		log.Info("YYYYYYYYYYYYYYYYYYYY", "submitWork,recv nonce len less 8")
		return false
	}
	work := a.work[hash]
	if work == nil {
		log.Info("Work submitted but none pending", "hash", hash)
		return false
	}
	addr, err := base58.Base58DecodeToAddress(strminerAddr)
	if err != nil {
		log.Info("Work submitted but miner address", "err", err, "miner address", strminerAddr)
		return false
	}
	result := types.CopyHeader(work.header)
	result.Nonce = nonce
	result.AIHash = AIHah
	result.Coinbase = addr
	engine, exist := a.engine[string(result.Version)]
	if exist == false {
		log.Warn("SubmitWork err", "header version can't find engine", string(result.Version))
		return false
	}
	log.Info("test log", "verify header", result.Hash(), "number", result.Number)
	if err := engine.VerifySeal(a.chain, result); err != nil {
		log.Warn("Invalid proof-of-work submitted", "hash", hash, "err", err)
		return false
	}
	a.returnCh <- result
	delete(a.work, hash)
	return true
}
func ( a * RemoteAgent ) SubmitWork ( strnonce , strAIHah , strhash , strminerAddr string ) bool { a . mu . Lock ( ) defer a . mu . Unlock ( ) log . Info ( " " , " " , strnonce , " " , strAIHah , " " , strhash , " " , strminerAddr ) if len ( strhash ) != 66 || len ( strAIHah ) != 66 { log . Error ( " " , " " , strnonce , " " , strAIHah , " " , strhash ) return false } if len ( strnonce ) > 10 { log . Error ( " " , " " , strnonce ) return false } hash := common . HexToHash ( strhash ) AIHah := common . HexToHash ( strAIHah ) nonce , err := conversType ( strnonce ) if err != nil { log . Info ( " " , " " ) return false } work := a . work [ hash ] if work == nil { log . Info ( " " , " " , hash ) return false } addr , err := base58 . Base58DecodeToAddress ( strminerAddr ) if err != nil { log . Info ( " " , " " , err , " " , strminerAddr ) return false } result := types . CopyHeader ( work . header ) result . Nonce = nonce result . AIHash = AIHah result . Coinbase = addr engine , exist := a . engine [ string ( result . Version ) ] if exist == false { log . Warn ( " " , " " , string ( result . Version ) ) return false } log . Info ( " " , " " , result . Hash ( ) , " " , result . Number ) if err := engine . VerifySeal ( a . chain , result ) ; err != nil { log . Warn ( " " , " " , hash , " " , err ) return false } a . returnCh <- result delete ( a . work , hash ) return true }
SubmitWork tries to inject a pow solution into the remote agent, returning
whether the solution was accepted or not (not can be both a bad pow as well as
any other error, like no work pending).
SubmitWork tries to inject a pow solution into the remote agent returning whether the solution was accepted or not ( not can be both a bad pow as well as any other error like no work pending ) .
// Make sure the work submitted is present // Make sure the Engine solutions is indeed valid //block := work.Block.WithSeal(result) // Solutions seems to be valid, return to the miner and notify acceptance