From 24dd0355a34a40b1798c9b8bd97a7332a77e2556 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 18 Mar 2017 00:55:37 +0100 Subject: pow: fix Search with ethash test mode The cache/dataset methods crashed with a nil pointer error if cachesinmem/dagsinmem were zero. Fix it by skipping the eviction logic if there are no caches/datasets. Search always used the regular dataset size regardless of test mode. Fix it by removing the redundant size parameter of hashimotoFull. Fixes #3784 --- pow/ethash_algo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pow/ethash_algo.go') diff --git a/pow/ethash_algo.go b/pow/ethash_algo.go index 3737cc5d7..1e996785f 100644 --- a/pow/ethash_algo.go +++ b/pow/ethash_algo.go @@ -349,12 +349,12 @@ func hashimotoLight(size uint64, cache []uint32, hash []byte, nonce uint64) ([]b // hashimotoFull aggregates data from the full dataset (using the full in-memory // dataset) in order to produce our final value for a particular header hash and // nonce. -func hashimotoFull(size uint64, dataset []uint32, hash []byte, nonce uint64) ([]byte, []byte) { +func hashimotoFull(dataset []uint32, hash []byte, nonce uint64) ([]byte, []byte) { lookup := func(index uint32) []uint32 { offset := index * hashWords return dataset[offset : offset+hashWords] } - return hashimoto(hash, nonce, size, lookup) + return hashimoto(hash, nonce, uint64(len(dataset))*4, lookup) } // datasetSizes is a lookup table for the ethash dataset size for the first 2048 -- cgit v1.2.3