Skip to content

Commit

Permalink
stash fix (DO NOT MERGE)
Browse files Browse the repository at this point in the history
temporally fixed golang wrapper
  • Loading branch information
hackmod committed Nov 25, 2018
1 parent ca6919c commit 86e2973
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions ethash.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ func freeCache(cache *cache) {
cache.ptr = nil
}

func (cache *cache) compute(dagSize uint64, hash common.Hash, nonce uint64) (ok bool, mixDigest, result common.Hash) {
ret := C.ethash_light_compute_internal(cache.ptr, C.uint64_t(dagSize), hashToH256(hash), C.uint64_t(nonce))
func (cache *cache) compute(dagSize uint64, hash common.Hash, nonce uint64, block_number uint64) (ok bool, mixDigest, result common.Hash) {
ret := C.progpow_light_compute_internal(cache.ptr, C.uint64_t(dagSize), hashToH256(hash), C.uint64_t(nonce), C.uint64_t(block_number))
// Make sure cache is live until after the C call.
// This is important because a GC might happen and execute
// the finalizer before the call completes.
Expand Down Expand Up @@ -151,7 +151,7 @@ func (l *Light) Verify(block Block) bool {
dagSize = dagSizeForTesting
}
// Recompute the hash using the cache.
ok, mixDigest, result := cache.compute(uint64(dagSize), block.HashNoNonce(), block.Nonce())
ok, mixDigest, result := cache.compute(uint64(dagSize), block.HashNoNonce(), block.Nonce(), blockNum)
if !ok {
return false
}
Expand Down
1 change: 1 addition & 0 deletions ethashc.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ package ethash
#cgo LDFLAGS: -lm
#include "src/libethash/internal.c"
#include "src/libethash/progpow-internal.c"
#include "src/libethash/sha3.c"
#include "src/libethash/io.c"
Expand Down
18 changes: 17 additions & 1 deletion src/libethash/ethash.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,23 @@ ethash_return_value_t ethash_full_compute(
);

/**
* Calculate the full client data
* Calculate the light client data of the ProgPow
*
* @param light The light client handler
* @param header_hash The header hash to pack into the mix
* @param nonce The nonce to pack into the mix
* @param block_number The block_number
* @return an object of ethash_return_value_t holding the return values
*/
ethash_return_value_t progpow_light_compute(
ethash_light_t light,
ethash_h256_t const header_hash,
uint64_t nonce,
uint64_t block_number
);

/**
* Calculate the full client data of the ProgPoW
*
* @param full The full client handler
* @param header_hash The header hash to pack into the mix
Expand Down
17 changes: 1 addition & 16 deletions src/libethash/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,7 @@ uint32_t progpowMath(uint32_t a, uint32_t b, uint32_t r);
void merge(uint32_t *a, uint32_t b, uint32_t r);

/**
* Calculate the light client data
*
* @param light The light client handler
* @param header_hash The header hash to pack into the mix
* @param nonce The nonce to pack into the mix
* @return an object of ethash_return_value_t holding the return values
*/
ethash_return_value_t progpow_light_compute(
ethash_light_t light,
ethash_h256_t const header_hash,
uint64_t nonce,
uint64_t block_number
);

/**
* Calculate the light client data. Internal version.
* Calculate the light client data of the ProgPow. Internal version.
*
* @param light The light client handler
* @param full_size The size of the full data in bytes.
Expand Down

0 comments on commit 86e2973

Please sign in to comment.