mirror of
https://github.com/talaia-labs/rust-teos.git
synced 2026-08-13 12:33:22 +02:00
dropping last_known_blocks after using it
`last_known_blocks` was taking up ~300migs of memory (for 100 blocks) because it was not dropped in `main`. Co-authored-by: Sergi Delgado Segura <sergi.delgado.s@gmail.com>
This commit is contained in:
parent
8df58f99d1
commit
fad3ad1c08
1 changed files with 29 additions and 27 deletions
|
|
@ -257,16 +257,6 @@ async fn main() {
|
|||
any => any,
|
||||
};
|
||||
|
||||
let mut poller = ChainPoller::new(&mut derefed, Network::from_str(btc_network).unwrap());
|
||||
let last_n_blocks = get_last_n_blocks(&mut poller, tip, IRREVOCABLY_RESOLVED as usize)
|
||||
.await.unwrap_or_else(|e| {
|
||||
// I'm pretty sure this can only happen if we are pulling blocks from the target to the prune height, and by the time we get to
|
||||
// the end at least one has been pruned.
|
||||
log::error!("Couldn't load the latest {IRREVOCABLY_RESOLVED} blocks. Please try again (Error: {})", e.into_inner());
|
||||
std::process::exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
// Build components
|
||||
let gatekeeper = Arc::new(Gatekeeper::new(
|
||||
tip.height,
|
||||
|
|
@ -276,23 +266,35 @@ async fn main() {
|
|||
dbm.clone(),
|
||||
));
|
||||
|
||||
let carrier = Carrier::new(rpc, bitcoind_reachable.clone(), tip.height);
|
||||
let responder = Arc::new(Responder::new(
|
||||
&last_n_blocks,
|
||||
tip.height,
|
||||
carrier,
|
||||
gatekeeper.clone(),
|
||||
dbm.clone(),
|
||||
));
|
||||
let watcher = Arc::new(Watcher::new(
|
||||
gatekeeper.clone(),
|
||||
responder.clone(),
|
||||
&last_n_blocks[0..6],
|
||||
tip.height,
|
||||
tower_sk,
|
||||
TowerId(tower_pk),
|
||||
dbm.clone(),
|
||||
));
|
||||
let mut poller = ChainPoller::new(&mut derefed, Network::from_str(btc_network).unwrap());
|
||||
let (responder, watcher) = {
|
||||
let last_n_blocks = get_last_n_blocks(&mut poller, tip, IRREVOCABLY_RESOLVED as usize)
|
||||
.await.unwrap_or_else(|e| {
|
||||
// I'm pretty sure this can only happen if we are pulling blocks from the target to the prune height, and by the time we get to
|
||||
// the end at least one has been pruned.
|
||||
log::error!("Couldn't load the latest {IRREVOCABLY_RESOLVED} blocks. Please try again (Error: {})", e.into_inner());
|
||||
std::process::exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
let responder = Arc::new(Responder::new(
|
||||
&last_n_blocks,
|
||||
tip.height,
|
||||
Carrier::new(rpc, bitcoind_reachable.clone(), tip.height),
|
||||
gatekeeper.clone(),
|
||||
dbm.clone(),
|
||||
));
|
||||
let watcher = Arc::new(Watcher::new(
|
||||
gatekeeper.clone(),
|
||||
responder.clone(),
|
||||
&last_n_blocks[0..6],
|
||||
tip.height,
|
||||
tower_sk,
|
||||
TowerId(tower_pk),
|
||||
dbm.clone(),
|
||||
));
|
||||
(responder, watcher)
|
||||
};
|
||||
|
||||
if watcher.is_fresh() & responder.is_fresh() & gatekeeper.is_fresh() {
|
||||
log::info!("Fresh bootstrap");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue