Skip to content

Commit ca23a23

Browse files
committed
Merge remote-tracking branch 'origin/main' into bugfix/rpc-race
2 parents 4eb0088 + 7975d94 commit ca23a23

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

tuktuk-crank-turner/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Cli {
102102
let solana_ws_url = solana_url
103103
.replace("http", "ws")
104104
.replace("https", "wss")
105-
.replace("127.0.0.1:8899", "127.0.0.1:8900");
105+
.replace("8899", "8900");
106106

107107
// Create a non-blocking RPC client
108108
// We can work off of processed accounts because we simulate the next tx before actually

tuktuk-sdk/src/tuktuk.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,34 @@ pub mod task_queue {
393393
compiled_transaction::next_available_task_ids_excluding_in_progress,
394394
};
395395

396+
/// Selects the 'n' next available task ids starting at a random offset
397+
///
398+
/// Returns an error if 'n' free task ids are not available
396399
pub fn next_available_task_ids(
397400
task_queue: &tuktuk::accounts::TaskQueueV0,
398401
n: u8,
402+
) -> Result<Vec<u16>, Error> {
403+
next_available_task_ids_from(
404+
task_queue,
405+
n,
406+
rand::random_range(0..task_queue.task_bitmap.len()),
407+
)
408+
}
409+
410+
/// Selects the 'n' next available task ids starting at a given offset
411+
///
412+
/// Returns an error if 'n' free task ids are not available
413+
pub fn next_available_task_ids_from(
414+
task_queue: &tuktuk::accounts::TaskQueueV0,
415+
n: u8,
416+
offset: usize,
399417
) -> Result<Vec<u16>, Error> {
400418
next_available_task_ids_excluding_in_progress(
401419
task_queue.capacity,
402420
&task_queue.task_bitmap,
403421
n,
404422
&Default::default(),
405-
rand::random_range(0..task_queue.task_bitmap.len()),
423+
offset,
406424
)
407425
}
408426

0 commit comments

Comments
 (0)