Adds hard-coded network tip height expection for getblocktemplate RPC method
This commit is contained in:
parent
777b2688af
commit
5e0a0386c1
|
@ -25,8 +25,9 @@ use zebra_consensus::{
|
||||||
use zebra_node_services::mempool;
|
use zebra_node_services::mempool;
|
||||||
use zebra_state::GetBlockTemplateChainInfo;
|
use zebra_state::GetBlockTemplateChainInfo;
|
||||||
|
|
||||||
use crate::methods::get_block_template_rpcs::types::{
|
use crate::methods::get_block_template_rpcs::{
|
||||||
default_roots::DefaultRoots, transaction::TransactionTemplate,
|
constants::NOT_SYNCED_ERROR_CODE,
|
||||||
|
types::{default_roots::DefaultRoots, transaction::TransactionTemplate},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use crate::methods::get_block_template_rpcs::types::get_block_template::*;
|
pub use crate::methods::get_block_template_rpcs::types::get_block_template::*;
|
||||||
|
@ -159,14 +160,28 @@ where
|
||||||
/// This error might be incorrect if the local clock is skewed.
|
/// This error might be incorrect if the local clock is skewed.
|
||||||
pub fn check_synced_to_tip<Tip, SyncStatus>(
|
pub fn check_synced_to_tip<Tip, SyncStatus>(
|
||||||
_network: &Network,
|
_network: &Network,
|
||||||
_latest_chain_tip: Tip,
|
latest_chain_tip: Tip,
|
||||||
_sync_status: SyncStatus,
|
_sync_status: SyncStatus,
|
||||||
) -> Result<()>
|
) -> Result<()>
|
||||||
where
|
where
|
||||||
Tip: ChainTip + Clone + Send + Sync + 'static,
|
Tip: ChainTip + Clone + Send + Sync + 'static,
|
||||||
SyncStatus: ChainSyncStatus + Clone + Send + Sync + 'static,
|
SyncStatus: ChainSyncStatus + Clone + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
|
let local_tip_height = latest_chain_tip.best_tip_height();
|
||||||
|
if local_tip_height > Some(Height(3001875)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(Error {
|
||||||
|
code: NOT_SYNCED_ERROR_CODE,
|
||||||
|
message: format!(
|
||||||
|
"Zebra has not synced to the chain tip, \
|
||||||
|
estimated network tip: 3001875, \
|
||||||
|
local tip: {local_tip_height:?}. \
|
||||||
|
Hint: check your network connection, clock, and time zone settings."
|
||||||
|
),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - State and mempool data fetches
|
// - State and mempool data fetches
|
||||||
|
|
Loading…
Reference in New Issue