|
|
@@ -18,6 +18,7 @@ package ethash
|
|
|
|
|
|
import (
|
|
|
"bytes"
|
|
|
+ "encoding/binary"
|
|
|
"io/ioutil"
|
|
|
"math/big"
|
|
|
"os"
|
|
|
@@ -30,6 +31,15 @@ import (
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
)
|
|
|
|
|
|
+// prepare converts an ethash cache or dataset from a byte stream into the internal
|
|
|
+// int representation. All ethash methods work with ints to avoid constant byte to
|
|
|
+// int conversions as well as to handle both little and big endian systems.
|
|
|
+func prepare(dest []uint32, src []byte) {
|
|
|
+ for i := 0; i < len(dest); i++ {
|
|
|
+ dest[i] = binary.LittleEndian.Uint32(src[i*4:])
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// Tests whether the dataset size calculator works correctly by cross checking the
|
|
|
// hard coded lookup table with the value generated by it.
|
|
|
func TestSizeCalculations(t *testing.T) {
|