added more debug info
This commit is contained in:
parent
204601b2d5
commit
a2c74d88cc
4 changed files with 43 additions and 11 deletions
10
binding.gyp
10
binding.gyp
|
|
@ -18,9 +18,15 @@
|
|||
"src/contrib/ethereum/libethash/ethash.cpp",
|
||||
"src/contrib/ethereum/libethash/keccak.c",
|
||||
"src/contrib/ethereum/libethash/keccakf800.c",
|
||||
"src/contrib/ethereum/libethash/keccakf800.c",
|
||||
"src/contrib/ethereum/libethash/progpow.cpp",
|
||||
"src/contrib/ethereum/libethash/managed.cpp"
|
||||
"src/contrib/ethereum/libethash/managed.cpp",
|
||||
"src/currency_core/currency_format_utils_transactions.cpp",
|
||||
"src/currency_core/genesis.cpp",
|
||||
"src/currency_core/genesis_acc.cpp",
|
||||
"src/crypto/random.c",
|
||||
"src/contrib/ethereum/libethash/keccakf1600.c",
|
||||
"src/contrib/ethereum/libethash/managed.cpp",
|
||||
"src/contrib/ethereum/libethash/primes.c"
|
||||
],
|
||||
"include_dirs": [
|
||||
"src",
|
||||
|
|
|
|||
|
|
@ -47,16 +47,24 @@ namespace currency
|
|||
return result;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
crypto::hash get_block_longhash(uint64_t height, const crypto::hash& block_long_ash, uint64_t nonce)
|
||||
crypto::hash get_block_longhash(uint64_t height, const crypto::hash& block_header_hash, uint64_t nonce)
|
||||
{
|
||||
int epoch = ethash_height_to_epoch(height);
|
||||
const auto& context = progpow::get_global_epoch_context_full(static_cast<int>(epoch));
|
||||
auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_long_ash, nonce);
|
||||
auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_header_hash, nonce);
|
||||
crypto::hash result = currency::null_hash;
|
||||
memcpy(&result.data, &res_eth.final_hash, sizeof(res_eth.final_hash));
|
||||
return result;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
crypto::hash get_block_header_mining_hash(const block& b)
|
||||
{
|
||||
blobdata bd = get_block_hashing_blob(b);
|
||||
|
||||
access_nonce_in_block_blob(bd) = 0;
|
||||
return crypto::cn_fast_hash(bd.data(), bd.size());
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
void get_block_longhash(const block& b, crypto::hash& res)
|
||||
{
|
||||
/*
|
||||
|
|
@ -65,11 +73,7 @@ namespace currency
|
|||
To achieve the same effect we make blob of data from block in normal way, but then set to zerro nonce
|
||||
inside serialized buffer, and then pass this nonce to ethash algo as a second argument, as it expected.
|
||||
*/
|
||||
blobdata bd = get_block_hashing_blob(b);
|
||||
|
||||
access_nonce_in_block_blob(bd) = 0;
|
||||
crypto::hash bl_hash = crypto::cn_fast_hash(bd.data(), bd.size());
|
||||
|
||||
crypto::hash bl_hash = get_block_header_mining_hash(b);
|
||||
res = get_block_longhash(get_block_height(b), bl_hash, b.nonce);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ namespace currency
|
|||
{
|
||||
int ethash_height_to_epoch(uint64_t height);
|
||||
crypto::hash ethash_epoch_to_seed(int epoch);
|
||||
crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_long_ash, uint64_t nonce);
|
||||
crypto::hash get_block_header_mining_hash(const block& b);
|
||||
crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_header_hash, uint64_t nonce);
|
||||
void get_block_longhash(const block& b, crypto::hash& res);
|
||||
crypto::hash get_block_longhash(const block& b);
|
||||
|
||||
|
|
|
|||
23
src/main.cc
23
src/main.cc
|
|
@ -199,8 +199,18 @@ void get_hash_from_block_template_with_extra(const Nan::FunctionCallbackInfo<v8:
|
|||
|
||||
if (extra.size())
|
||||
b.miner_tx.extra.push_back(extra);
|
||||
|
||||
|
||||
crypto::hash h = currency::get_block_hash(b);
|
||||
//@#@ debug output
|
||||
std::cout << "[get_hash_from_block_template_with_extra]: " << ENDL
|
||||
<< "blob: [" << epee::string_tools::buff_to_hex_nodelimer(blob) << "]" << ENDL
|
||||
<< "extra: [" << epee::string_tools::buff_to_hex_nodelimer(extra) << "]" << ENDL
|
||||
<< "nonce(0?): [" << b.nonce << "]" << ENDL
|
||||
<< "header_mining_hash: [" << currency::get_block_header_mining_hash(b) << "]" << ENDL
|
||||
<< "blob(with extra): [" << epee::string_tools::buff_to_hex_nodelimer(get_block_hashing_blob(b)) << "]" << ENDL
|
||||
<< "result: [" << h << "]" << ENDL;
|
||||
//@#@
|
||||
|
||||
SET_BUFFER_RETURN((const char*)&h, 32);
|
||||
}
|
||||
|
||||
|
|
@ -255,6 +265,17 @@ void get_blob_from_block_template(const Nan::FunctionCallbackInfo<v8::Value>& ar
|
|||
|
||||
crypto::hash h = currency::get_block_hash(b);
|
||||
|
||||
|
||||
//@#@ debug output
|
||||
std::cout << "[get_blob_from_block_template]: " << ENDL
|
||||
<< "blob: [" << epee::string_tools::buff_to_hex_nodelimer(blob) << "]" << ENDL
|
||||
<< "extra: [" << epee::string_tools::buff_to_hex_nodelimer(extra) << "]" << ENDL
|
||||
<< "nonce: [" << *nonce_ptr << "]" << ENDL
|
||||
<< "header_mining_hash: [" << currency::get_block_header_mining_hash(b) << "]" << ENDL
|
||||
<< "res blob: [" << epee::string_tools::buff_to_hex_nodelimer(result_blob) << "]" << ENDL;
|
||||
//@#@
|
||||
|
||||
|
||||
SET_BUFFER_RETURN(result_blob.data(), result_blob.size());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue