From 3dbe8d3c6bd730982f1e1aaece856ae00f1adfd9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Nov 2022 13:43:10 -0500 Subject: [PATCH] indentation --- src/miner.cpp | 57 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1ff987e9b..97f093f1e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1132,36 +1132,37 @@ void static RandomXMiner() Mining_height = pindexPrev->GetHeight()+1; Mining_start = (uint32_t)time(NULL); } - char randomxHash[RANDOMX_HASH_SIZE]; - rxdebug("%s: created randomxHash of size %d\n", RANDOMX_HASH_SIZE); - char randomxKey[82]; // randomx spec says keysize of >60 bytes is implementation-specific - // initial randomx key is unique to every Hush Smart Chain, and has at least 9 bytes (2^9=128 bits) of entropy - // since magic is 4 bytes, rpc port is 4 bytes and smart chain symbol must be at least 1 character long - snprintf(randomxKey, 81, "%08x%s%08x", ASSETCHAINS_MAGIC, SMART_CHAIN_SYMBOL, ASSETCHAINS_RPCPORT); - - // With the defaults of 1024 and 64 - // the key block will change every ~21.3 hours with a 75s block time - // and every ~17 hours with the default 60s block time for HSCs - int randomxInterval = GetArg("-ac_randomx_interval",1024); - // This lag is 80 mins for 75s blocktime and 64 mins for 60s (default) blocktime for HSCs - int randomxBlockLag = GetArg("-ac_randomx_lag", 64); - - // fprintf(stderr,"RandomXMiner: using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag); - rxdebug("%s: using initial key, interval=%d, lag=%d, Mining_height=%u\n", randomxInterval, randomxBlockLag, Mining_height); - // Use the initial key at the start of the chain, until the first key block - if( (Mining_height) < randomxInterval + randomxBlockLag) { - randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey); - rxdebug("%s: initialized cache with initial key\n"); - } else { - rxdebug("%s: calculating keyHeight with randomxInterval=%d\n", randomxInterval); - // At heights between intervals, we use the same block key and wait randomxBlockLag blocks until changing - int keyHeight = ((Mining_height - randomxBlockLag) / randomxInterval) * randomxInterval; - uint256 randomxBlockKey = chainActive[keyHeight]->GetBlockHash(); - randomx_init_cache(randomxCache, &randomxBlockKey, sizeof randomxBlockKey); - rxdebug("%s: initialized cache with keyHeight=%d, randomxBlockKey=%s\n", keyHeight, randomxBlockKey.ToString().c_str()); + char randomxHash[RANDOMX_HASH_SIZE]; + rxdebug("%s: created randomxHash of size %d\n", RANDOMX_HASH_SIZE); + char randomxKey[82]; // randomx spec says keysize of >60 bytes is implementation-specific + // initial randomx key is unique to every Hush Smart Chain, and has at least 9 bytes (2^9=128 bits) of entropy + // since magic is 4 bytes, rpc port is 4 bytes and smart chain symbol must be at least 1 character long + snprintf(randomxKey, 81, "%08x%s%08x", ASSETCHAINS_MAGIC, SMART_CHAIN_SYMBOL, ASSETCHAINS_RPCPORT); + + // With the defaults of 1024 and 64 + // the key block will change every ~21.3 hours with a 75s block time + // and every ~17 hours with the default 60s block time for HSCs + int randomxInterval = GetArg("-ac_randomx_interval",1024); + // This lag is 80 mins for 75s blocktime and 64 mins for 60s (default) blocktime for HSCs + int randomxBlockLag = GetArg("-ac_randomx_lag", 64); + + // fprintf(stderr,"RandomXMiner: using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag); + rxdebug("%s: using initial key, interval=%d, lag=%d, Mining_height=%u\n", randomxInterval, randomxBlockLag, Mining_height); + // Use the initial key at the start of the chain, until the first key block + if( (Mining_height) < randomxInterval + randomxBlockLag) { + randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey); + rxdebug("%s: initialized cache with initial key\n"); + } else { + rxdebug("%s: calculating keyHeight with randomxInterval=%d\n", randomxInterval); + // At heights between intervals, we use the same block key and wait randomxBlockLag blocks until changing + int keyHeight = ((Mining_height - randomxBlockLag) / randomxInterval) * randomxInterval; + uint256 randomxBlockKey = chainActive[keyHeight]->GetBlockHash(); - } + randomx_init_cache(randomxCache, &randomxBlockKey, sizeof randomxBlockKey); + rxdebug("%s: initialized cache with keyHeight=%d, randomxBlockKey=%s\n", keyHeight, randomxBlockKey.ToString().c_str()); + + } auto datasetItemCount = randomx_dataset_item_count(); rxdebug("%s: dataset items=%lu\n", datasetItemCount);