From 63406ddeb373ae962c2f42ba6797ad2bf6d3b766 Mon Sep 17 00:00:00 2001 From: Nick Garfield Date: Tue, 1 Mar 2022 15:41:02 -0700 Subject: [PATCH] Cleanup imports --- bot/sql/create_tables.sql | 9 --------- bot/src/bucket.rs | 11 +++++++---- bot/src/cache.rs | 9 +++++---- bot/src/exec.rs | 25 ++++++++++++++----------- bot/src/replicate.rs | 29 ++++++++++++++--------------- bot/src/utils/monitor_blocktime.rs | 24 ++++++++++-------------- bot/src/utils/sign_and_submit.rs | 7 ++----- 7 files changed, 52 insertions(+), 62 deletions(-) delete mode 100644 bot/sql/create_tables.sql diff --git a/bot/sql/create_tables.sql b/bot/sql/create_tables.sql deleted file mode 100644 index f5a5cccd4..000000000 --- a/bot/sql/create_tables.sql +++ /dev/null @@ -1,9 +0,0 @@ --- Create tasks table -CREATE TABLE IF NOT EXISTS tasks ( - pubkey TEXT NOT NULL, - daemon TEXT NOT NULL, - status TEXT NOT NULL, - exec_at BIGINT NOT NULL, - ix BYTEA NOT NULL, - PRIMARY KEY (pubkey) -); \ No newline at end of file diff --git a/bot/src/bucket.rs b/bot/src/bucket.rs index 68ba26f86..338325fdd 100644 --- a/bot/src/bucket.rs +++ b/bot/src/bucket.rs @@ -1,7 +1,10 @@ -use std::collections::HashMap; -use std::sync::{Arc, Mutex}; - -use solana_sdk::pubkey::Pubkey; +use { + solana_sdk::pubkey::Pubkey, + std::{ + collections::HashMap, + sync::{Arc, Mutex}, + }, +}; pub struct Bucket { locks: HashMap<(Pubkey, i64), Arc>>, diff --git a/bot/src/cache.rs b/bot/src/cache.rs index 5840c7776..e766e0abb 100644 --- a/bot/src/cache.rs +++ b/bot/src/cache.rs @@ -1,7 +1,8 @@ -use std::collections::{HashMap, HashSet}; - -use cronos_sdk::account::Task; -use solana_sdk::pubkey::Pubkey; +use { + cronos_sdk::account::Task, + solana_sdk::pubkey::Pubkey, + std::collections::{HashMap, HashSet}, +}; pub struct TaskCache { pub data: HashMap, diff --git a/bot/src/exec.rs b/bot/src/exec.rs index d477dcd9d..b10a8d102 100644 --- a/bot/src/exec.rs +++ b/bot/src/exec.rs @@ -1,14 +1,17 @@ -use cronos_sdk::account::*; -use solana_client_helpers::Client; -use solana_sdk::instruction::AccountMeta; -use solana_sdk::pubkey::Pubkey; - -use std::sync::{Arc, Mutex, RwLock}; -use std::thread::{self, JoinHandle}; - -use crate::bucket::Bucket; -use crate::utils::sign_and_submit; -use crate::{cache::TaskCache, utils::monitor_blocktime}; +use { + crate::{ + bucket::Bucket, + cache::TaskCache, + utils::{monitor_blocktime, sign_and_submit}, + }, + cronos_sdk::account::*, + solana_client_helpers::Client, + solana_sdk::{instruction::AccountMeta, pubkey::Pubkey}, + std::{ + sync::{Arc, Mutex, RwLock}, + thread::{self, JoinHandle}, + }, +}; const LOOKBACK_WINDOW: i64 = 120; // Number of seconds to lookback diff --git a/bot/src/replicate.rs b/bot/src/replicate.rs index 8edb57c45..561c41744 100644 --- a/bot/src/replicate.rs +++ b/bot/src/replicate.rs @@ -1,20 +1,19 @@ -// use anchor_lang::prelude::Pubkey; - -use cronos_sdk::account::*; -use solana_account_decoder::UiAccountEncoding; -use solana_client::{ - pubsub_client::PubsubClient, - rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, -}; -use solana_sdk::{account::Account, commitment_config::CommitmentConfig, pubkey::Pubkey}; -use std::{ - str::FromStr, - sync::{Arc, RwLock}, - thread, +use { + crate::{cache::TaskCache, env}, + cronos_sdk::account::*, + solana_account_decoder::UiAccountEncoding, + solana_client::{ + pubsub_client::PubsubClient, + rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, + }, + solana_sdk::{account::Account, commitment_config::CommitmentConfig, pubkey::Pubkey}, + std::{ + str::FromStr, + sync::{Arc, RwLock}, + thread, + }, }; -use crate::{cache::TaskCache, env}; - pub fn replicate_tasks(cache: Arc>) { thread::spawn(move || { // Websocket client diff --git a/bot/src/utils/monitor_blocktime.rs b/bot/src/utils/monitor_blocktime.rs index 00ab9c05c..d00b47779 100644 --- a/bot/src/utils/monitor_blocktime.rs +++ b/bot/src/utils/monitor_blocktime.rs @@ -1,24 +1,20 @@ use { - solana_client::pubsub_client::PubsubClient, + crate::env, + solana_account_decoder::UiAccountEncoding, + solana_client::{pubsub_client::PubsubClient, rpc_config::RpcAccountInfoConfig}, + solana_sdk::{ + account::Account, + clock::{Clock, Epoch, Slot, UnixTimestamp}, + commitment_config::CommitmentConfig, + pubkey::Pubkey, + }, std::{ + str::FromStr, sync::mpsc::{self, Receiver}, thread, }, }; -use std::str::FromStr; - -use solana_account_decoder::UiAccountEncoding; -use solana_client::{rpc_config::RpcAccountInfoConfig}; -use solana_sdk::{ - account::Account, - clock::{Clock, Epoch, Slot, UnixTimestamp}, - commitment_config::CommitmentConfig, - pubkey::Pubkey, -}; - -use crate::env; - pub fn monitor_blocktime() -> Receiver { let (blocktime_sender, blocktime_receiver) = mpsc::channel::(); thread::spawn(move || { diff --git a/bot/src/utils/sign_and_submit.rs b/bot/src/utils/sign_and_submit.rs index 641a21783..dee1b0301 100644 --- a/bot/src/utils/sign_and_submit.rs +++ b/bot/src/utils/sign_and_submit.rs @@ -1,9 +1,6 @@ -use solana_client_helpers::ClientResult; -use solana_sdk::signature::Signature; - use { - solana_client_helpers::Client, - solana_sdk::{instruction::Instruction, transaction::Transaction}, + solana_client_helpers::{Client, ClientResult}, + solana_sdk::{instruction::Instruction, signature::Signature, transaction::Transaction}, }; pub fn sign_and_submit(