regolith-labs / ore-cli

Command line interface for ORE cryptocurrency mining.
1.47k stars 669 forks source link

[feature] Add bloxroute #151

Open Lanikean opened 3 months ago

Lanikean commented 3 months ago

This PR adds a method called send_and_confirm_bx that handles transaction propegation, mirroring the logic in send_and_confirm as closely as possible along with some enhancements.

I've also in my testing process discovered a bug where the program will hang indefinitely if a mine cycle fails.

On a failure of the entire sending and confirming cycle, the on chain proof.last_hash_at will not update, and so will not be greater than the in memory last_hash_at below:

pub async fn get_updated_proof_with_authority(
    client: &RpcClient,
    authority: Pubkey,
    lash_hash_at: i64,
) -> Proof {
    loop {
        let proof = get_proof_with_authority(client, authority).await;
        if proof.last_hash_at.gt(&lash_hash_at) {
            return proof;
        }
        tokio::time::sleep(Duration::from_millis(1_000)).await;
    }
}

I've fixed this by updating last_hash_at in the mine function only if a transaction was succesfully sent, otherwise it will remain at the current difficultly.