Skip to content

Commit

Permalink
cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
antiyro committed Oct 7, 2023
1 parent cd8c1ce commit e47db87
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
2 changes: 1 addition & 1 deletion crates/client/block-proposer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ where
let spawn_handle = self.spawn_handle.clone();
let txs = self.transaction_pool.ready().count() > 0;

// If there are no transactions, return an error or handle it appropriately.
// If there are no transactions, return an error (we want to avoid empty blocks)
if !txs {
return async { Err(sp_blockchain::Error::Application("No transactions in pool".into())) }.boxed();
}
Expand Down
33 changes: 0 additions & 33 deletions crates/client/data-availability/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,4 @@ pub fn is_valid_ws_endpoint(endpoint: &str) -> bool {

pub fn is_valid_http_endpoint(endpoint: &str) -> bool {
if let Ok(url) = get_valid_url(endpoint) { matches!(url.scheme(), "http" | "https") } else { false }
}

async fn create_block(rpc_port: u16) -> Result<StatusCode, reqwest::Error> {
let client = reqwest::Client::new();
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, "application/json ".parse().unwrap());

let url = format!("http://localhost:{}/", rpc_port);
let payload = json!({
"id": 1,
"jsonrpc": "2.0",
"method": "engine_createBlock",
"params": [true, true, null]
});

let response = client.post(url)
.headers(headers.clone())
.json(&payload)
.send().await?;

Ok(response.status())
}


/// Check for digest for the last block and create block if it has at least x txs
pub async fn check_block(rpc_port: u16) -> Result<(), reqwest::Error> {
let mut status = create_block(rpc_port).await?;

while status != StatusCode::OK {
status = create_block(rpc_port).await?;
}

Ok(())
}

0 comments on commit e47db87

Please sign in to comment.