From 85fec838c6fb7b73f6a1a8d1d5169d3c8f2c036c Mon Sep 17 00:00:00 2001 From: Andrew Westberg Date: Tue, 2 Jan 2024 17:48:55 +0000 Subject: [PATCH] Move intersect db query outside of connection --- Cargo.lock | 162 +++++++++++++++++++---------------------- Cargo.toml | 16 ++-- src/nodeclient/sync.rs | 64 +++++++++------- 3 files changed, 122 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0f935d..13b1074 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", "once_cell", @@ -98,7 +98,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" dependencies = [ "concurrent-queue", - "event-listener 4.0.1", + "event-listener 4.0.2", "event-listener-strategy", "futures-core", "pin-project-lite", @@ -200,7 +200,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" dependencies = [ - "event-listener 4.0.1", + "event-listener 4.0.2", "event-listener-strategy", "pin-project-lite", ] @@ -422,9 +422,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e23185c0e21df6ed832a12e2bda87c7d1def6842881fb634a8511ced741b0d76" +checksum = "91d7b79e99bfaa0d47da0687c43aa3b7381938a62ad3a6498599039321f660b7" dependencies = [ "chrono", "chrono-tz-build", @@ -459,7 +459,7 @@ dependencies = [ [[package]] name = "cncli" -version = "6.0.0-alpha3" +version = "6.0.0-alpha4" dependencies = [ "async-std", "autotools", @@ -575,21 +575,20 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.16" +version = "0.9.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" +checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", ] [[package]] name = "crossbeam-utils" -version = "0.8.17" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" dependencies = [ "cfg-if", ] @@ -672,9 +671,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "4.0.1" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f2cdcf274580f2d63697192d744727b3198894b1bf02923643bf59e2c26712" +checksum = "218a870470cce1469024e9fb66b901aa983929d81304a1cdb299f28118e550d5" dependencies = [ "concurrent-queue", "parking", @@ -687,7 +686,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "event-listener 4.0.1", + "event-listener 4.0.2", "pin-project-lite", ] @@ -745,9 +744,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -760,9 +759,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -770,15 +769,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -787,9 +786,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -821,32 +820,32 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.46", ] [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -1066,9 +1065,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1135,13 +1134,13 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ "hermit-abi 0.3.3", "rustix 0.38.28", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1280,18 +1279,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "mime" @@ -1301,9 +1291,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minicbor" -version = "0.19.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7005aaf257a59ff4de471a9d5538ec868a21586534fff7f85dd97d4043a6139" +checksum = "9d15f4203d71fdf90903c2696e55426ac97a363c67b218488a73b534ce7aca10" dependencies = [ "half", "minicbor-derive", @@ -1404,9 +1394,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -1426,7 +1416,7 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pallas-addresses" version = "0.20.0" -source = "git+https://github.com/AndrewWestberg/pallas?rev=8b1364668062465dfaf44adeb067853cc4770624#8b1364668062465dfaf44adeb067853cc4770624" +source = "git+https://github.com/AndrewWestberg/pallas?rev=7c88a69d3129f22f604ae63e6f20477285cace09#7c88a69d3129f22f604ae63e6f20477285cace09" dependencies = [ "base58", "bech32", @@ -1441,7 +1431,7 @@ dependencies = [ [[package]] name = "pallas-codec" version = "0.20.0" -source = "git+https://github.com/AndrewWestberg/pallas?rev=8b1364668062465dfaf44adeb067853cc4770624#8b1364668062465dfaf44adeb067853cc4770624" +source = "git+https://github.com/AndrewWestberg/pallas?rev=7c88a69d3129f22f604ae63e6f20477285cace09#7c88a69d3129f22f604ae63e6f20477285cace09" dependencies = [ "hex", "minicbor", @@ -1452,7 +1442,7 @@ dependencies = [ [[package]] name = "pallas-crypto" version = "0.20.0" -source = "git+https://github.com/AndrewWestberg/pallas?rev=8b1364668062465dfaf44adeb067853cc4770624#8b1364668062465dfaf44adeb067853cc4770624" +source = "git+https://github.com/AndrewWestberg/pallas?rev=7c88a69d3129f22f604ae63e6f20477285cace09#7c88a69d3129f22f604ae63e6f20477285cace09" dependencies = [ "cryptoxide", "hex", @@ -1465,7 +1455,7 @@ dependencies = [ [[package]] name = "pallas-network" version = "0.20.0" -source = "git+https://github.com/AndrewWestberg/pallas?rev=8b1364668062465dfaf44adeb067853cc4770624#8b1364668062465dfaf44adeb067853cc4770624" +source = "git+https://github.com/AndrewWestberg/pallas?rev=7c88a69d3129f22f604ae63e6f20477285cace09#7c88a69d3129f22f604ae63e6f20477285cace09" dependencies = [ "byteorder", "hex", @@ -1482,7 +1472,7 @@ dependencies = [ [[package]] name = "pallas-primitives" version = "0.20.0" -source = "git+https://github.com/AndrewWestberg/pallas?rev=8b1364668062465dfaf44adeb067853cc4770624#8b1364668062465dfaf44adeb067853cc4770624" +source = "git+https://github.com/AndrewWestberg/pallas?rev=7c88a69d3129f22f604ae63e6f20477285cace09#7c88a69d3129f22f604ae63e6f20477285cace09" dependencies = [ "base58", "bech32", @@ -1497,7 +1487,7 @@ dependencies = [ [[package]] name = "pallas-traverse" version = "0.20.0" -source = "git+https://github.com/AndrewWestberg/pallas?rev=8b1364668062465dfaf44adeb067853cc4770624#8b1364668062465dfaf44adeb067853cc4770624" +source = "git+https://github.com/AndrewWestberg/pallas?rev=7c88a69d3129f22f604ae63e6f20477285cace09#7c88a69d3129f22f604ae63e6f20477285cace09" dependencies = [ "hex", "pallas-addresses", @@ -1675,18 +1665,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1922,9 +1912,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.194" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" dependencies = [ "serde_derive", ] @@ -1952,20 +1942,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.194" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.46", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "6fbd975230bada99c8bb618e0c365c2eefa219158d5c6c29610fd09ff1833257" dependencies = [ "itoa", "ryu", @@ -2093,9 +2083,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.42" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", @@ -2143,22 +2133,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.51" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.51" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.46", ] [[package]] @@ -2211,7 +2201,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.46", ] [[package]] @@ -2263,7 +2253,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.46", ] [[package]] @@ -2435,7 +2425,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.46", "wasm-bindgen-shared", ] @@ -2469,7 +2459,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.46", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2529,11 +2519,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -2695,5 +2685,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.42", + "syn 2.0.46", ] diff --git a/Cargo.toml b/Cargo.toml index a229f11..f1b2b59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cncli" -version = "6.0.0-alpha3" +version = "6.0.0-alpha4" authors = ["Andrew Westberg "] edition = "2018" build = "build.rs" @@ -15,29 +15,29 @@ num-bigint = "0.4.4" num-rational = "0.4.1" blake2b_simd = "1.0.2" byteorder = "1.5.0" -pallas-network = { git = "https://github.com/AndrewWestberg/pallas", rev="8b1364668062465dfaf44adeb067853cc4770624" } -pallas-traverse = { git = "https://github.com/AndrewWestberg/pallas", rev="8b1364668062465dfaf44adeb067853cc4770624" } +pallas-network = { git = "https://github.com/AndrewWestberg/pallas", rev="7c88a69d3129f22f604ae63e6f20477285cace09" } +pallas-traverse = { git = "https://github.com/AndrewWestberg/pallas", rev="7c88a69d3129f22f604ae63e6f20477285cace09" } #pallas-network = "0.20.0" #pallas-traverse = "0.20.0" chrono = "0.4.31" -chrono-tz = "0.8.4" -futures = "0.3.29" +chrono-tz = "0.8.5" +futures = "0.3.30" hex = "0.4.3" libc = "0.2.151" regex = "1.10.2" reqwest = { version = "0.11.22", default-features = false, features = ["blocking", "rustls-tls-webpki-roots", "rustls-tls", "json", "gzip", "deflate"] } rusqlite = { version = "0.30.0", features = ["bundled"] } -serde = { version = "1.0.193", features = ["derive"] } +serde = { version = "1.0.194", features = ["derive"] } serde-aux = "4.3.1" serde_cbor = "0.11.2" -serde_json = "1.0.108" +serde_json = "1.0.110" socket2 = "0.5.5" structopt = "0.3.26" rand = "0.8.5" rayon = "1.8.0" itertools = "0.12.0" tokio = { version = "1", features = ["rt", "net", "io-util", "time", "sync", "macros"] } -thiserror = "1.0.51" +thiserror = "1.0.56" tracing = "0.1.37" tracing-subscriber = "0.3.16" diff --git a/src/nodeclient/sync.rs b/src/nodeclient/sync.rs index c153dc5..fac289d 100644 --- a/src/nodeclient/sync.rs +++ b/src/nodeclient/sync.rs @@ -253,38 +253,25 @@ impl Observer for LoggingObserver { } } -async fn do_handshake( - channel: AgentChannel, - network_magic: u64, -) -> Result, handshake::Error> { - let versions = handshake::n2n::VersionTable::v7_and_above(network_magic); - let mut client = handshake::Client::new(channel); - client.handshake(versions).await -} +fn get_intersect_blocks(db: &Path) -> Result, Error> { + let start = Instant::now(); + debug!("get_intersect_blocks"); + let mut block_store = sqlite::SqLiteBlockStore::new(db).unwrap(); -async fn do_chainsync( - channel: AgentChannel, - skip_to_tip: bool, - exit_when_tip_reached: bool, - mut block_store: Option>, - shelley_genesis_hash: String, -) -> Result<(), Error> { let mut chain_blocks: Vec = vec![]; /* Classic sync: Use blocks from store if available. */ - if let Some(store) = block_store.as_mut() { - match (*store).load_blocks() { - None => {} - Some(blocks) => { - for (i, block) in blocks.iter().enumerate() { - // all powers of 2 including 0th element 0, 2, 4, 8, 16, 32 - if (i == 0) || ((i > 1) && (i & (i - 1) == 0)) { - chain_blocks.push(Point::Specific(block.0 as u64, block.1.clone())); - } + match block_store.load_blocks() { + None => {} + Some(blocks) => { + for (i, block) in blocks.iter().enumerate() { + // all powers of 2 including 0th element 0, 2, 4, 8, 16, 32 + if (i == 0) || ((i > 1) && (i & (i - 1) == 0)) { + chain_blocks.push(Point::Specific(block.0 as u64, block.1.clone())); } } } - } + }; // add known points chain_blocks.push( @@ -317,11 +304,33 @@ async fn do_chainsync( ); chain_blocks.push(Point::Origin); + info!("get_intersect_blocks took: {:?}", start.elapsed()); + + Ok(chain_blocks) +} + +async fn do_handshake( + channel: AgentChannel, + network_magic: u64, +) -> Result, handshake::Error> { + let versions = handshake::n2n::VersionTable::v7_and_above(network_magic); + let mut client = handshake::Client::new(channel); + client.handshake(versions).await +} + +async fn do_chainsync( + channel: AgentChannel, + skip_to_tip: bool, + exit_when_tip_reached: bool, + chain_blocks: Option>, + block_store: Option>, + shelley_genesis_hash: String, +) -> Result<(), Error> { let mut client = chainsync::N2NClient::new(channel); if skip_to_tip { client.intersect_tip().await?; } else { - client.find_intersect(chain_blocks).await?; + client.find_intersect(chain_blocks.unwrap()).await?; } let mut logging_observer = LoggingObserver { @@ -376,6 +385,7 @@ pub(crate) async fn sync( loop { // Retry to establish connection forever let block_store = sqlite::SqLiteBlockStore::new(db).unwrap(); + let chain_blocks = get_intersect_blocks(db).unwrap(); match Bearer::connect_tcp_timeout( &format!("{host}:{port}").to_socket_addrs().unwrap().next().unwrap(), FIVE_SECS, @@ -399,6 +409,7 @@ pub(crate) async fn sync( cs_channel, false, no_service, + Some(chain_blocks), Some(Box::new(block_store)), shelley_genesis_hash, )); @@ -477,6 +488,7 @@ pub(crate) async fn sendtip( cs_channel, true, false, + None, Some(Box::new(pooltool_notifier)), "1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81".to_string(), ));