Electroneum
Loading...
Searching...
No Matches
gen_block_invalid_nonce Struct Reference

#include <block_validation.h>

Inheritance diagram for gen_block_invalid_nonce:
Collaboration diagram for gen_block_invalid_nonce:

Public Member Functions

bool generate (std::vector< test_event_entry > &events) const
Public Member Functions inherited from gen_block_verification_base< 3 >
 gen_block_verification_base ()
bool check_block_verification_context (const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
bool check_block_purged (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
Public Member Functions inherited from test_chain_unit_base
void register_callback (const std::string &cb_name, verify_callback cb)
bool verify (const std::string &cb_name, cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_block_verification_context (const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
bool check_tx_verification_context (const cryptonote::tx_verification_context &tvc, bool, size_t, const cryptonote::transaction &)
bool check_tx_verification_context_array (const std::vector< cryptonote::tx_verification_context > &tvcs, size_t, size_t, const std::vector< cryptonote::transaction > &)

Additional Inherited Members

Public Types inherited from test_chain_unit_base
typedef boost::function< bool(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)> verify_callback
typedef std::map< std::string, verify_callbackcallbacks_map

Detailed Description

Definition at line 114 of file block_validation.h.

Member Function Documentation

◆ generate()

bool gen_block_invalid_nonce::generate ( std::vector< test_event_entry > & events) const

Definition at line 169 of file block_validation.cpp.

170{
172
173 std::vector<uint64_t> timestamps;
174 std::vector<difficulty_type> commulative_difficulties;
175 if (!lift_up_difficulty(events, timestamps, commulative_difficulties, generator, 2, blk_0, miner_account))
176 return false;
177
178 // Create invalid nonce
179 difficulty_type diffic = next_difficulty(timestamps, commulative_difficulties,DIFFICULTY_TARGET);
180 assert(1 < diffic);
181 const block& blk_last = boost::get<block>(events.back());
182 uint64_t timestamp = blk_last.timestamp;
183 block blk_3;
184 do
185 {
186 ++timestamp;
187 blk_3.miner_tx.set_null();
188 if (!generator.construct_block_manually(blk_3, blk_last, miner_account,
190 return false;
191 }
192 while (0 == blk_3.nonce);
193 --blk_3.nonce;
194 events.push_back(blk_3);
195
196 return true;
197}
#define BLOCK_VALIDATION_INIT_GENERATE()
#define DIFFICULTY_TARGET
POD_CLASS hash
Definition hash.h:50
boost::multiprecision::uint128_t difficulty_type
Definition difficulty.h:43
difficulty_type next_difficulty(std::vector< uint64_t > timestamps, std::vector< difficulty_type > cumulative_difficulties, size_t target_seconds, uint8_t version)
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:

The documentation for this struct was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/core_tests/block_validation.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/core_tests/block_validation.cpp