Skip to content

Cleanup repair-trie metrics task spawning #20157

@mattsse

Description

@mattsse

Describe the feature

we currently do:

// Create a single-threaded tokio runtime
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("Failed to create tokio runtime for metrics server");
let handle = runtime.handle().clone();
runtime.block_on(async move {

this is a bit verbose and we don't need this really if we change the db command to accept clicontext

/// Execute `db` command
pub async fn execute<N: CliNodeTypes<ChainSpec = C::ChainSpec>>(self) -> eyre::Result<()> {

Commands::Db(command) => runner.run_blocking_until_ctrl_c(command.execute::<N>()),

we can introduce run_blocking_command_until_exit

pub fn run_command_until_exit<F, E>(

for this

and forward the clicontext to the command, this way the repair trie command gets access to the TaskExecutor it needs for

let handle = std::thread::Builder::new().name("metrics-server".to_string()).spawn(
move || {

let task_manager = reth_tasks::TaskManager::new(handle.clone());

maybe @figtracer ?

Additional context

No response

Metadata

Metadata

Assignees

Labels

A-cliRelated to the reth CLIC-debtA clean up/refactor of existing codeC-enhancementNew feature or request

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions