check for nil ptrs

This commit is contained in:
obscuren 2015-03-22 15:44:00 +01:00
parent 82956df523
commit 8ed4f226d1

@ -55,7 +55,7 @@ out:
} }
func (a *Agent) GetWork() common.Hash { func (a *Agent) GetWork() common.Hash {
// XXX Wait here untill work != nil ? // XXX Wait here untill work != nil ?.
if a.work != nil { if a.work != nil {
return a.work.HashNoNonce() return a.work.HashNoNonce()
} }
@ -64,7 +64,7 @@ func (a *Agent) GetWork() common.Hash {
func (a *Agent) SetResult(nonce uint64, mixDigest, seedHash common.Hash) { func (a *Agent) SetResult(nonce uint64, mixDigest, seedHash common.Hash) {
// Make sure the external miner was working on the right hash // Make sure the external miner was working on the right hash
if a.currentWork.Hash() == a.work.Hash() { if a.currentWork != nil && a.work != nil && a.currentWork.Hash() == a.work.Hash() {
a.returnCh <- miner.Work{a.currentWork.Number().Uint64(), nonce, mixDigest.Bytes(), seedHash.Bytes()} a.returnCh <- miner.Work{a.currentWork.Number().Uint64(), nonce, mixDigest.Bytes(), seedHash.Bytes()}
} }
} }