Skip to content

Commit

Permalink
Merge pull request #4443 from clemahieu/ledger_process_ptr
Browse files Browse the repository at this point in the history
Convert ledger::process to take a shared_ptr argument instead of a block reference.
  • Loading branch information
clemahieu authored Feb 23, 2024
2 parents e0a4fd8 + 8d08259 commit 2903a99
Show file tree
Hide file tree
Showing 45 changed files with 1,343 additions and 1,359 deletions.
138 changes: 69 additions & 69 deletions nano/core_test/active_transactions.cpp

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions nano/core_test/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ TEST (block, publish_req_serialization)
.balance (200)
.sign (nano::keypair ().prv, 2)
.work (3)
.build_shared ();
.build ();
nano::publish req{ nano::dev::network_params.network, block };
std::vector<uint8_t> bytes;
{
Expand Down Expand Up @@ -429,7 +429,7 @@ TEST (state_block, serialization)
.link (4)
.sign (key1.prv, key1.pub)
.work (5)
.build_shared ();
.build ();
ASSERT_EQ (key1.pub, block1->hashables.account);
ASSERT_EQ (nano::block_hash (1), block1->previous ());
ASSERT_EQ (key2.pub, block1->hashables.representative);
Expand Down Expand Up @@ -489,7 +489,7 @@ TEST (state_block, hashing)
.link (0)
.sign (key.prv, key.pub)
.work (0)
.build_shared ();
.build ();
auto hash (block->hash ());
ASSERT_EQ (hash, block->hash ()); // check cache works
block->hashables.account.bytes[0] ^= 0x1;
Expand Down Expand Up @@ -551,7 +551,7 @@ TEST (block_uniquer, single)
.link (0)
.sign (key.prv, key.pub)
.work (0)
.build_shared ();
.build ();
auto block2 (std::make_shared<nano::state_block> (*block1));
ASSERT_NE (block1, block2);
ASSERT_EQ (*block1, *block2);
Expand All @@ -578,7 +578,7 @@ TEST (block_uniquer, cleanup)
.link (0)
.sign (key.prv, key.pub)
.work (0)
.build_shared ();
.build ();
auto block2 = builder
.make_block ()
.account (0)
Expand All @@ -588,7 +588,7 @@ TEST (block_uniquer, cleanup)
.link (0)
.sign (key.prv, key.pub)
.work (1)
.build_shared ();
.build ();

nano::block_uniquer uniquer;
auto block3 = uniquer.unique (block1);
Expand Down Expand Up @@ -636,7 +636,7 @@ TEST (block_builder, zeroed_state_block)
.link (0)
.sign (key.prv, key.pub)
.work (0)
.build_shared ();
.build ();
auto zero_block_build = builder.state ().zero ().sign (key.prv, key.pub).build ();
ASSERT_EQ (zero_block_manual->hash (), zero_block_build->hash ());
ASSERT_FALSE (nano::validate_message (key.pub, zero_block_build->hash (), zero_block_build->signature));
Expand Down
24 changes: 12 additions & 12 deletions nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,23 +1021,23 @@ TEST (mdb_block_store, sideband_height)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (nano::dev::genesis->hash ()))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *send));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, send));
auto receive = builder
.receive ()
.previous (send->hash ())
.source (send->hash ())
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (send->hash ()))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *receive));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, receive));
auto change = builder
.change ()
.previous (receive->hash ())
.representative (0)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (receive->hash ()))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *change));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, change));
auto state_send1 = builder
.state ()
.account (nano::dev::genesis_key.pub)
Expand All @@ -1048,7 +1048,7 @@ TEST (mdb_block_store, sideband_height)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (change->hash ()))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *state_send1));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, state_send1));
auto state_send2 = builder
.state ()
.account (nano::dev::genesis_key.pub)
Expand All @@ -1059,7 +1059,7 @@ TEST (mdb_block_store, sideband_height)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (state_send1->hash ()))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *state_send2));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, state_send2));
auto state_send3 = builder
.state ()
.account (nano::dev::genesis_key.pub)
Expand All @@ -1070,7 +1070,7 @@ TEST (mdb_block_store, sideband_height)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (state_send2->hash ()))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *state_send3));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, state_send3));
auto state_open = builder
.state ()
.account (key1.pub)
Expand All @@ -1081,7 +1081,7 @@ TEST (mdb_block_store, sideband_height)
.sign (key1.prv, key1.pub)
.work (*pool.generate (key1.pub))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *state_open));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, state_open));
auto epoch = builder
.state ()
.account (key1.pub)
Expand All @@ -1092,7 +1092,7 @@ TEST (mdb_block_store, sideband_height)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (state_open->hash ()))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *epoch));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, epoch));
ASSERT_EQ (nano::epoch::epoch_1, ledger.version (*epoch));
auto epoch_open = builder
.state ()
Expand All @@ -1104,7 +1104,7 @@ TEST (mdb_block_store, sideband_height)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (key2.pub))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *epoch_open));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, epoch_open));
ASSERT_EQ (nano::epoch::epoch_1, ledger.version (*epoch_open));
auto state_receive = builder
.state ()
Expand All @@ -1116,7 +1116,7 @@ TEST (mdb_block_store, sideband_height)
.sign (key2.prv, key2.pub)
.work (*pool.generate (epoch_open->hash ()))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *state_receive));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, state_receive));
auto open = builder
.open ()
.source (state_send3->hash ())
Expand All @@ -1125,7 +1125,7 @@ TEST (mdb_block_store, sideband_height)
.sign (key3.prv, key3.pub)
.work (*pool.generate (key3.pub))
.build ();
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, *open));
ASSERT_EQ (nano::block_status::progress, ledger.process (transaction, open));
auto block1 (store.block.get (transaction, nano::dev::genesis->hash ()));
ASSERT_EQ (block1->sideband ().height, 1);
auto block2 (store.block.get (transaction, send->hash ()));
Expand Down Expand Up @@ -1673,7 +1673,7 @@ TEST (rocksdb_block_store, tombstone_count)
.balance (2)
.sign (nano::keypair ().prv, 4)
.work (5)
.build_shared ();
.build ();
// Enqueues a block to be saved in the database
nano::account account{ 1 };
store->account.put (store->tx_begin_write (), account, nano::account_info{});
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TEST (block_processor, broadcast_block_on_arrival)
.link (nano::dev::genesis_key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ()))
.build_shared ();
.build ();
// Adds a block to the first node. process_active() -> (calls) block_processor.add() -> add() ->
// awakes process_block() -> process_batch() -> process_one() -> process_live()
node1->process_active (send1);
Expand Down
Loading

0 comments on commit 2903a99

Please sign in to comment.