|
24 | 24 | #include "process_launcher.h" |
25 | 25 | #include "rpc_connections.h" |
26 | 26 | #include "sig_term.h" |
27 | | -#include "snapshots/fetch.h" |
28 | | -#include "snapshots/snapshot_manager.h" |
| 27 | +#include "snapshots.h" |
29 | 28 | #include "ticker.h" |
30 | 29 | #include "time_updater.h" |
31 | 30 |
|
@@ -377,7 +376,7 @@ int main(int argc, char** argv) |
377 | 376 | config.ledger.read_only_directories); |
378 | 377 | ledger.register_message_handlers(bp.get_dispatcher()); |
379 | 378 |
|
380 | | - snapshots::SnapshotManager snapshots( |
| 379 | + asynchost::SnapshotManager snapshots( |
381 | 380 | config.snapshots.directory, |
382 | 381 | writer_factory, |
383 | 382 | config.snapshots.read_only_directory); |
@@ -508,6 +507,8 @@ int main(int argc, char** argv) |
508 | 507 |
|
509 | 508 | ccf::StartupConfig startup_config(config); |
510 | 509 |
|
| 510 | + startup_config.snapshot_tx_interval = config.snapshots.tx_count; |
| 511 | + |
511 | 512 | if (startup_config.attestation.snp_security_policy_file.has_value()) |
512 | 513 | { |
513 | 514 | auto security_policy_file = |
@@ -689,62 +690,22 @@ int main(int argc, char** argv) |
689 | 690 | config.command.type == StartType::Join || |
690 | 691 | config.command.type == StartType::Recover) |
691 | 692 | { |
692 | | - auto latest_local_snapshot = snapshots.find_latest_committed_snapshot(); |
693 | | - |
694 | | - if ( |
695 | | - config.command.type == StartType::Join && |
696 | | - config.command.join.fetch_recent_snapshot) |
| 693 | + auto latest_committed_snapshot = |
| 694 | + snapshots.find_latest_committed_snapshot(); |
| 695 | + if (latest_committed_snapshot.has_value()) |
697 | 696 | { |
698 | | - // Try to fetch a recent snapshot from peer |
699 | | - const size_t latest_local_idx = latest_local_snapshot.has_value() ? |
700 | | - snapshots::get_snapshot_idx_from_file_name( |
701 | | - latest_local_snapshot->second) : |
702 | | - 0; |
703 | | - auto latest_peer_snapshot = snapshots::fetch_from_peer( |
704 | | - config.command.join.target_rpc_address, |
705 | | - config.command.service_certificate_file, |
706 | | - latest_local_idx); |
707 | | - |
708 | | - if (latest_peer_snapshot.has_value()) |
709 | | - { |
710 | | - LOG_INFO_FMT( |
711 | | - "Received snapshot {} from peer (size: {}) - writing this to disk " |
712 | | - "and using for join startup", |
713 | | - latest_peer_snapshot->snapshot_name, |
714 | | - latest_peer_snapshot->snapshot_data.size()); |
715 | | - |
716 | | - const auto dst_path = fs::path(config.snapshots.directory) / |
717 | | - fs::path(latest_peer_snapshot->snapshot_name); |
718 | | - if (files::exists(dst_path)) |
719 | | - { |
720 | | - LOG_FATAL_FMT( |
721 | | - "Unable to write peer snapshot - already have a file at {}. " |
722 | | - "Exiting.", |
723 | | - dst_path); |
724 | | - return static_cast<int>(CLI::ExitCodes::FileError); |
725 | | - } |
726 | | - files::dump(latest_peer_snapshot->snapshot_data, dst_path); |
727 | | - startup_snapshot = latest_peer_snapshot->snapshot_data; |
728 | | - } |
729 | | - } |
| 697 | + auto& [snapshot_dir, snapshot_file] = latest_committed_snapshot.value(); |
| 698 | + startup_snapshot = files::slurp(snapshot_dir / snapshot_file); |
730 | 699 |
|
731 | | - if (startup_snapshot.empty()) |
| 700 | + LOG_INFO_FMT( |
| 701 | + "Found latest snapshot file: {} (size: {})", |
| 702 | + snapshot_dir / snapshot_file, |
| 703 | + startup_snapshot.size()); |
| 704 | + } |
| 705 | + else |
732 | 706 | { |
733 | | - if (latest_local_snapshot.has_value()) |
734 | | - { |
735 | | - auto& [snapshot_dir, snapshot_file] = latest_local_snapshot.value(); |
736 | | - startup_snapshot = files::slurp(snapshot_dir / snapshot_file); |
737 | | - |
738 | | - LOG_INFO_FMT( |
739 | | - "Found latest local snapshot file: {} (size: {})", |
740 | | - snapshot_dir / snapshot_file, |
741 | | - startup_snapshot.size()); |
742 | | - } |
743 | | - else |
744 | | - { |
745 | | - LOG_INFO_FMT( |
746 | | - "No snapshot found: Node will replay all historical transactions"); |
747 | | - } |
| 707 | + LOG_INFO_FMT( |
| 708 | + "No snapshot found: Node will replay all historical transactions"); |
748 | 709 | } |
749 | 710 | } |
750 | 711 |
|
|
0 commit comments