Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphman command for clearing the call cache for a given chain #4066

Merged
merged 14 commits into from
Oct 31, 2022
Next Next commit
wip
Signed-off-by: poonai <[email protected]>
  • Loading branch information
poonai committed Oct 23, 2022
commit 23cc4ce7f19c3bd25ebc3258f1a2bed91895ccc8
24 changes: 24 additions & 0 deletions node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,29 @@ pub enum ChainCommand {
#[clap(long, short)]
force: bool,
},

/// Execute operations on call cache.
CallCache {
#[clap(subcommand)]
method: CallCacheCommand,
/// Chain name (must be an existing chain, see 'chain list')
#[clap(empty_values = false)]
chain_name: String,
},
}

#[derive(Clone, Debug, Subcommand)]
pub enum CallCacheCommand {
/// Remove call cache of a specified chain
///
/// If block pointers of from and to is not mentioned, then all the call cache will be
/// removed.
Remove {
/// Starting block pointer
from: Option<i32>,
/// Ending block pointer
to: Option<i32>,
},
}

#[derive(Clone, Debug, Subcommand)]
Expand Down Expand Up @@ -1088,6 +1111,7 @@ async fn main() -> anyhow::Result<()> {
let chain_store = ctx.chain_store(&chain_name)?;
truncate(chain_store, force)
}
CallCache { method, chain_name } => {}
}
}
Stats(cmd) => {
Expand Down
3 changes: 3 additions & 0 deletions node/src/manager/commands/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,6 @@ pub fn remove(primary: ConnectionPool, store: Arc<BlockStore>, name: String) ->

Ok(())
}


pub async fn call_cache_remove(){}
26 changes: 26 additions & 0 deletions store/postgres/src/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,32 @@ mod data {
.collect())
}

pub(super) fn clear_call_cache(
&self,
conn: &PgConnection,
from: Option<i32>,
to: Option<i32>,
) -> Result<(), Error> {
match self {
Storage::Shared => {
use public::eth_call_cache as cache;

let stmt = cache::table.select((cache::id, cache::return_value, cache::contract_address));
if let Some(from) = from{
stmt.filter(cache::block_number.ge(from));
}
if let Some(to) = to {
stmt.filter(cache::block_number.le(to));
}

},
Storage::Private(Schema{call_cache, ..}) => {

}
}
Ok(())
}

pub(super) fn update_accessed_at(
&self,
conn: &PgConnection,
Expand Down