Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number of miners #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions scratch/bitcoin-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -159,40 +153,40 @@ main (int argc, char *argv[])

if (litecoin)
{
averageBlockGenIntervalMinutes = 2.5;
totalNoNodes = 1000;
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[j]*12/noMiners;
minersRegions[i*12 + j] = litecoinMinersRegions[j];
}
}
}
else if (dogecoin)
{
averageBlockGenIntervalMinutes = 1;
totalNoNodes = 650;
totalNoNodes = 256;
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++)
{
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[j]*12/noMiners;
minersRegions[i*12 + j] = dogecoinMinersRegions[j];
}
}
}
else
{
minersHash = new double[noMiners];
minersRegions = new enum BitcoinRegion[noMiners];
minersRegions = new enum BitcoinRegion[noMiners];

for(int i = 0; i < noMiners/16; i++)
{
Expand Down
15 changes: 6 additions & 9 deletions src/applications/model/bitcoin-miner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down