From 3f21d94df17c4c6afd9412c95c0c6d8cb2051064 Mon Sep 17 00:00:00 2001 From: alan-bartczak Date: Tue, 15 Jan 2019 13:02:29 +0100 Subject: [PATCH 1/3] v2 for litecoin and dogecoin testing --- scratch/bitcoin-test.cc | 10 ++++------ src/applications/model/bitcoin-miner.cc | 15 ++++++--------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/scratch/bitcoin-test.cc b/scratch/bitcoin-test.cc index 65f7ec7..a013cb9 100644 --- a/scratch/bitcoin-test.cc +++ b/scratch/bitcoin-test.cc @@ -159,8 +159,7 @@ main (int argc, char *argv[]) if (litecoin) { - averageBlockGenIntervalMinutes = 2.5; - totalNoNodes = 1000; + totalNoNodes = 24; cryptocurrency = LITECOIN; noMiners = sizeof(litecoinMinersHash)/sizeof(double); @@ -175,13 +174,12 @@ main (int argc, char *argv[]) } else if (dogecoin) { - averageBlockGenIntervalMinutes = 1; - totalNoNodes = 650; + totalNoNodes = 24; cryptocurrency = DOGECOIN; noMiners = sizeof(dogecoinMinersHash)/sizeof(double); minersHash = new double[noMiners]; - minersRegions = new enum BitcoinRegion[noMiners]; + minersRegions = new enum BitcoinRegion[noMiners]; for(int i = 0; i < noMiners; i++) { @@ -192,7 +190,7 @@ main (int argc, char *argv[]) else { minersHash = new double[noMiners]; - minersRegions = new enum BitcoinRegion[noMiners]; + minersRegions = new enum BitcoinRegion[noMiners]; for(int i = 0; i < noMiners/16; i++) { diff --git a/src/applications/model/bitcoin-miner.cc b/src/applications/model/bitcoin-miner.cc index 212d407..4e93879 100644 --- a/src/applications/model/bitcoin-miner.cc +++ b/src/applications/model/bitcoin-miner.cc @@ -453,15 +453,12 @@ BitcoinMiner::MineBlock (void) { m_nextBlockSize = m_blockSizeDistribution(m_generator) * 1000; // *1000 because the m_blockSizeDistribution returns KBytes - if (m_cryptocurrency == BITCOIN) - { - // The block size is linearly dependent on the averageBlockGenIntervalSeconds - if(m_nextBlockSize < m_maxBlockSize - m_headersSizeBytes) - m_nextBlockSize = m_nextBlockSize*m_averageBlockGenIntervalSeconds / m_realAverageBlockGenIntervalSeconds - + m_headersSizeBytes; - else - m_nextBlockSize = m_nextBlockSize*m_averageBlockGenIntervalSeconds / m_realAverageBlockGenIntervalSeconds; - } + // The block size is linearly dependent on the averageBlockGenIntervalSeconds + if(m_nextBlockSize < m_maxBlockSize - m_headersSizeBytes) + m_nextBlockSize = m_nextBlockSize*m_averageBlockGenIntervalSeconds / m_realAverageBlockGenIntervalSeconds + + m_headersSizeBytes; + else + m_nextBlockSize = m_nextBlockSize*m_averageBlockGenIntervalSeconds / m_realAverageBlockGenIntervalSeconds; } if (m_nextBlockSize < m_averageTransactionSize) From e8510afc435ed9adc4dffcd517c29fcfe0c095e7 Mon Sep 17 00:00:00 2001 From: alan-bartczak Date: Tue, 22 Jan 2019 09:43:52 +0100 Subject: [PATCH 2/3] number of miners fix --- scratch/bitcoin-test.cc | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/scratch/bitcoin-test.cc b/scratch/bitcoin-test.cc index a013cb9..6901682 100644 --- a/scratch/bitcoin-test.cc +++ b/scratch/bitcoin-test.cc @@ -144,12 +144,6 @@ main (int argc, char *argv[]) cmd.AddValue ("spv", "Enable the spv mechanism", spv); cmd.Parse(argc, argv); - - if (noMiners % 16 != 0) - { - std::cout << "The number of miners must be multiple of 16" << std::endl; - return 0; - } if (litecoin && dogecoin) { @@ -159,33 +153,35 @@ main (int argc, char *argv[]) if (litecoin) { - totalNoNodes = 24; + totalNoNodes = 256; cryptocurrency = LITECOIN; - noMiners = sizeof(litecoinMinersHash)/sizeof(double); minersHash = new double[noMiners]; - minersRegions = new enum BitcoinRegion[noMiners]; + minersRegions = new enum BitcoinRegion[noMiners]; - for(int i = 0; i < noMiners; i++) - { - minersHash[i] = litecoinMinersHash[i]; - minersRegions[i] = litecoinMinersRegions[i]; - } + for(int i = 0; i < noMiners/12; i++) { + for(int j = 0; j < 12; j++) + { + minersHash[i*12 + j] = litecoinMinersHash[i]*12/noMiners; + minersRegions[i*12 + j] = litecoinMinersRegions[i]; + } + } } else if (dogecoin) { - totalNoNodes = 24; + totalNoNodes = 256; cryptocurrency = DOGECOIN; - noMiners = sizeof(dogecoinMinersHash)/sizeof(double); minersHash = new double[noMiners]; minersRegions = new enum BitcoinRegion[noMiners]; - for(int i = 0; i < noMiners; i++) - { - minersHash[i] = dogecoinMinersHash[i]; - minersRegions[i] = dogecoinMinersRegions[i]; - } + for(int i = 0; i < noMiners/12; i++) { + for(int j = 0; j < 12; j++) + { + minersHash[i*12 + j] = dogecoinMinersHash[i]*12/noMiners; + minersRegions[i*12 + j] = dogecoinMinersRegions[i]; + } + } } else { From 7dac3ab54626eb1216dbef8c2a8a29ec2f7228b5 Mon Sep 17 00:00:00 2001 From: alan-bartczak Date: Tue, 22 Jan 2019 18:19:11 +0100 Subject: [PATCH 3/3] code fix --- scratch/bitcoin-test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scratch/bitcoin-test.cc b/scratch/bitcoin-test.cc index 6901682..4b86941 100644 --- a/scratch/bitcoin-test.cc +++ b/scratch/bitcoin-test.cc @@ -162,8 +162,8 @@ main (int argc, char *argv[]) for(int i = 0; i < noMiners/12; i++) { for(int j = 0; j < 12; j++) { - minersHash[i*12 + j] = litecoinMinersHash[i]*12/noMiners; - minersRegions[i*12 + j] = litecoinMinersRegions[i]; + minersHash[i*12 + j] = litecoinMinersHash[j]*12/noMiners; + minersRegions[i*12 + j] = litecoinMinersRegions[j]; } } } @@ -178,8 +178,8 @@ main (int argc, char *argv[]) for(int i = 0; i < noMiners/12; i++) { for(int j = 0; j < 12; j++) { - minersHash[i*12 + j] = dogecoinMinersHash[i]*12/noMiners; - minersRegions[i*12 + j] = dogecoinMinersRegions[i]; + minersHash[i*12 + j] = dogecoinMinersHash[j]*12/noMiners; + minersRegions[i*12 + j] = dogecoinMinersRegions[j]; } } }