diff --git a/Cargo.lock b/Cargo.lock index 223214c53..938b47936 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2739,6 +2739,7 @@ dependencies = [ "kaspa-consensus-notify", "kaspa-consensusmanager", "kaspa-core", + "kaspa-hashes", "kaspa-index-core", "kaspa-math", "kaspa-mining", diff --git a/rpc/service/Cargo.toml b/rpc/service/Cargo.toml index 3a66d6fb3..9cc925599 100644 --- a/rpc/service/Cargo.toml +++ b/rpc/service/Cargo.toml @@ -26,6 +26,7 @@ kaspa-math.workspace = true kaspa-utxoindex.workspace = true kaspa-wrpc-core.workspace = true kaspa-perf-monitor.workspace = true +kaspa-hashes.workspace = true log.workspace = true async-trait.workspace = true diff --git a/rpc/service/src/service.rs b/rpc/service/src/service.rs index d38d2002b..7e7d6b5a6 100644 --- a/rpc/service/src/service.rs +++ b/rpc/service/src/service.rs @@ -556,12 +556,23 @@ impl RpcApi for RpcCoreService { if request.window_size as u64 > self.config.pruning_depth { return Err(RpcError::WindowSizeExceedingPruningDepth(request.window_size, self.config.pruning_depth)); } + + // In the previous golang implementation the convention for virtual was the following const. + // In the current implementation, consensus behaves the same when it gets a None instead. + const LEGACY_VIRTUAL: kaspa_hashes::Hash = kaspa_hashes::Hash::from_bytes([0xff; kaspa_hashes::HASH_SIZE]); + let mut start_hash = request.start_hash; + if let Some(start) = start_hash { + if start == LEGACY_VIRTUAL { + start_hash = None; + } + } + Ok(EstimateNetworkHashesPerSecondResponse::new( self.consensus_manager .consensus() .session() .await - .async_estimate_network_hashes_per_second(request.start_hash, request.window_size as usize) + .async_estimate_network_hashes_per_second(start_hash, request.window_size as usize) .await?, )) }