diff --git a/cli/src/main.rs b/cli/src/main.rs index d4ac14f..3280556 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -101,6 +101,9 @@ async fn main() { "claim_seeker" => { claim_seeker(&rpc, &payer).await.unwrap(); } + "participating_miners" => { + participating_miners(&rpc).await.unwrap(); + } "keys" => { keys().await.unwrap(); } @@ -108,6 +111,16 @@ async fn main() { }; } +async fn participating_miners(rpc: &RpcClient) -> Result<(), anyhow::Error> { + let round_id = std::env::var("ID").expect("Missing ID env var"); + let round_id = u64::from_str(&round_id).expect("Invalid ID"); + let miners = get_miners_participating(rpc, round_id).await?; + for (i, (address, miner)) in miners.iter().enumerate() { + println!("{}: {}", i, miner.authority); + } + Ok(()) +} + // Dmy2fqxpkUocwvkALMDwfCRFeYfkdGqgB5PLfmZW5ASR // Az9Xia5f6EXU9MGHuuMCKyHMy3MfNnsoyTbh7HTuFw5G // 5muLAbcjsAMcP8438KPfo2Jqw2vgAtuSDvMFNWb6Bexi @@ -629,6 +642,15 @@ async fn get_miners_old(rpc: &RpcClient) -> Result, anyh Ok(miners) } +async fn get_miners_participating( + rpc: &RpcClient, + round_id: u64, +) -> Result, anyhow::Error> { + let filter = RpcFilterType::Memcmp(Memcmp::new_base58_encoded(472, &round_id.to_le_bytes())); + let miners = get_program_accounts::(rpc, ore_api::ID, vec![filter]).await?; + Ok(miners) +} + fn get_winning_square(slot_hash: &[u8]) -> u64 { // Use slot hash to generate a random u64 let r1 = u64::from_le_bytes(slot_hash[0..8].try_into().unwrap()); diff --git a/program/src/deploy.rs b/program/src/deploy.rs index 155207f..5940478 100644 --- a/program/src/deploy.rs +++ b/program/src/deploy.rs @@ -39,6 +39,13 @@ pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul return Err(trace("Not authorized", OreError::NotAuthorized.into())); } + // Wait until first deploy to start round. + if board.end_slot == u64::MAX { + board.start_slot = clock.slot; + board.end_slot = board.start_slot + 150; + round.expires_at = board.end_slot + ONE_WEEK_SLOTS; + } + // Check if signer is the automation executor. let automation = if !automation_info.data_is_empty() { let automation = automation_info diff --git a/program/src/reset.rs b/program/src/reset.rs index 45a05dc..d6ae765 100644 --- a/program/src/reset.rs +++ b/program/src/reset.rs @@ -47,7 +47,7 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul round_next.deployed = [0; 25]; round_next.slot_hash = [0; 32]; round_next.count = [0; 25]; - round_next.expires_at = clock.slot + 150 + ONE_WEEK_SLOTS; + round_next.expires_at = u64::MAX; // clock.slot + 150 + ONE_WEEK_SLOTS; round_next.rent_payer = *signer_info.key; round_next.motherlode = 0; round_next.top_miner = Pubkey::default(); @@ -109,7 +109,7 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul // Update board board.round_id += 1; board.start_slot = clock.slot + 1; - board.end_slot = board.start_slot + 150; + board.end_slot = u64::MAX; // board.start_slot + 150; // Do SOL transfers. round_info.send(total_admin_fee, &fee_collector_info); @@ -220,7 +220,7 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul // Reset board. board.round_id += 1; board.start_slot = clock.slot + 1; - board.end_slot = board.start_slot + 150; + board.end_slot = u64::MAX; // board.start_slot + 150; // Do SOL transfers. round_info.send(total_admin_fee, &fee_collector_info);