예제 #1
0
void EthashSealEngine::generateSeal(BlockInfo const& _bi)
{
	m_sealing = Ethash::BlockHeader(_bi);
	m_farm.setWork(m_sealing);
	m_farm.start(m_sealer);
	m_farm.setWork(m_sealing);		// TODO: take out one before or one after...
	bytes shouldPrecompute = option("precomputeDAG");
	if (!shouldPrecompute.empty() && shouldPrecompute[0] == 1)
		Ethash::ensurePrecomputed((unsigned)_bi.number());
}
예제 #2
0
u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const
{
	const unsigned c_expDiffPeriod = 100000;

	if (!m_number)
		throw GenesisBlockCannotBeCalculated();
	u256 o = max<u256>(c_minimumDifficulty, m_timestamp >= _parent.m_timestamp + c_durationLimit ? _parent.m_difficulty - (_parent.m_difficulty / c_difficultyBoundDivisor) : (_parent.m_difficulty + (_parent.m_difficulty / c_difficultyBoundDivisor)));
	unsigned periodCount = unsigned(_parent.number() + 1) / c_expDiffPeriod;
	if (periodCount > 1)
		o = max<u256>(c_minimumDifficulty, o + (u256(1) << (periodCount - 2)));	// latter will eventually become huge, so ensure it's a bigint.
	return o;
}
예제 #3
0
static void badBlockInfo(BlockInfo const& _bi, string const& _err)
{
    string const c_line = EthReset EthOnMaroon + string(80, ' ') + EthReset;
    string const c_border = EthReset EthOnMaroon + string(2, ' ') + EthReset EthMaroonBold;
    string const c_space = c_border + string(76, ' ') + c_border + EthReset;
    stringstream ss;
    ss << c_line << endl;
    ss << c_space << endl;
    ss << c_border + "  Import Failure     " + _err + string(max<int>(0, 53 - _err.size()), ' ') + "  " + c_border << endl;
    ss << c_space << endl;
    string bin = toString(_bi.number());
    ss << c_border + ("                     Guru Meditation #" + string(max<int>(0, 8 - bin.size()), '0') + bin + "." + _bi.hash().abridged() + "                    ") + c_border << endl;
    ss << c_space << endl;
    ss << c_line;
    cwarn << "\n" + ss.str();
}
예제 #4
0
uint64_t EthashAux::cacheSize(BlockInfo const& _header)
{
	return ethash_get_cachesize((uint64_t)_header.number());
}