Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
toxeus committed Jun 8, 2018
1 parent 292f1af commit 16b250f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
3 changes: 1 addition & 2 deletions examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ int bc::main(int argc, char* argv[])
#endif

// Extracting Satoshi's words from genesis block.
const auto block =
bc::chain::block::genesis_mainnet(libbitcoin::settings());
const auto block = bc::chain::block::genesis_mainnet(bc::settings());
const auto& coinbase = block.transactions().front();
const auto& input = coinbase.inputs().front();
BITCOIN_ASSERT_MSG(input.script().size() > 2u, "unexpected genesis");
Expand Down
12 changes: 8 additions & 4 deletions include/bitcoin/bitcoin/chain/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ class BC_API header
// Deserialization.
//-------------------------------------------------------------------------

static header factory(const data_chunk& data, const settings& settings, bool wire=true);
static header factory(std::istream& stream, const settings& settings, bool wire=true);
static header factory(reader& source, const settings& settings, bool wire=true);
static header factory(reader& source, hash_digest&& hash, const settings& settings, bool wire=true);
static header factory(const data_chunk& data, const settings& settings,
bool wire=true);
static header factory(std::istream& stream, const settings& settings,
bool wire=true);
static header factory(reader& source, const settings& settings,
bool wire=true);
static header factory(reader& source, hash_digest&& hash,
const settings& settings, bool wire=true);
static header factory(reader& source, const hash_digest& hash,
const settings& settings, bool wire=true);

Expand Down
6 changes: 4 additions & 2 deletions src/chain/chain_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,11 @@ uint32_t chain_state::work_required(const data& values, uint32_t forks,
return bits_high(values);
}

uint32_t chain_state::work_required_retarget(const data& values, const settings& settings)
uint32_t chain_state::work_required_retarget(const data& values,
const settings& settings)
{
static const uint256_t pow_limit(compact{ settings.retarget_proof_of_work_limit });
static const uint256_t pow_limit(
compact{ settings.retarget_proof_of_work_limit });

const compact bits(bits_high(values));
BITCOIN_ASSERT_MSG(!bits.is_overflowed(), "previous block has bad bits");
Expand Down
3 changes: 2 additions & 1 deletion src/chain/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ bool header::operator!=(const header& other) const
//-----------------------------------------------------------------------------

// static
header header::factory(const data_chunk& data, const settings& settings, bool wire)
header header::factory(const data_chunk& data, const settings& settings,
bool wire)
{
header instance(settings);
instance.from_data(data, wire);
Expand Down
3 changes: 2 additions & 1 deletion src/message/compact_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ bool compact_block::from_data(uint32_t version, std::istream& stream,
return from_data(version, source, settings);
}

bool compact_block::from_data(uint32_t version, reader& source, const settings& settings)
bool compact_block::from_data(uint32_t version, reader& source,
const settings& settings)
{
reset(settings);

Expand Down
3 changes: 2 additions & 1 deletion src/message/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ header::header(const settings& settings)
header::header(uint32_t version,
const hash_digest& previous_block_hash, const hash_digest& merkle,
uint32_t timestamp, uint32_t bits, uint32_t nonce, const settings& settings)
: chain::header(version, previous_block_hash, merkle, timestamp, bits, nonce, settings)
: chain::header(version, previous_block_hash, merkle, timestamp, bits, nonce,
settings)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ settings::settings()
timestamp_future_seconds(2 * 60 * 60),
target_timespan_seconds(2 * 7 * 24 * 60 * 60),
retarget_proof_of_work_limit(0x1d00ffff),
no_retarget_proof_of_work_limit(0x207fffff),
min_timespan(target_timespan_seconds / retargeting_factor_),
max_timespan(target_timespan_seconds * retargeting_factor_),
retargeting_interval(target_timespan_seconds / target_spacing_seconds_)
no_retarget_proof_of_work_limit(0x207fffff)
{
min_timespan = target_timespan_seconds / retargeting_factor_;
max_timespan = target_timespan_seconds * retargeting_factor_;
retargeting_interval = target_timespan_seconds / target_spacing_seconds_;
}

uint32_t settings::work_limit(bool retarget) const
Expand Down

0 comments on commit 16b250f

Please sign in to comment.