pub(crate) fn should_migrate(
        &self,
        subgraph: &SubgraphDeploymentId,
        block_ptr: &EthereumBlockPointer,
    ) -> Result<bool, StoreError> {
        // How often to check whether a subgraph needs to be migrated (in
        // blocks) Doing it every 20 blocks translates to roughly once every
        // 5 minutes
        const MIGRATION_CHECK_FREQ: u64 = 20;

        if self.storage.needs_migrating() {
            // We determine whether it is time for us to check if we should
            // migrate in a way that tries to splay the checks for different
            // subgraphs, using the hash of the subgraph id as a somewhat
            // arbitrary indicator. We really just want the checks to be
            // distributed across all possible values mod MIGRATION_CHECK_FREQ
            // so that we don't have a mad dash to migrate every
            // MIGRATION_CHECK_FREQ blocks, which would happen if we checked
            // for `block_ptr.number % MIGRATION_CHECK_FREQ == 0`
            let mut hasher = DefaultHasher::new();
            subgraph.hash(&mut hasher);
            let hash = hasher.finish();
            Ok(hash % MIGRATION_CHECK_FREQ == block_ptr.number % MIGRATION_CHECK_FREQ)
        } else {
            Ok(false)
        }
    }
/// Check if the schema for `subgraph` needs to be migrated, and if so
/// if now (indicated by the block pointer) is the right time to do so.
/// We try to spread the actual database work associated with checking
/// if a subgraph should be migrated out as much as possible. This
/// function does not query the database, and the actual check for
/// migrating should only be done if this function returns `true`
Check if the schema for `subgraph` needs to be migrated, and if so
if now (indicated by the block pointer) is the right time to do so.
We try to spread the actual database work associated with checking
if a subgraph should be migrated out as much as possible. This
function does not query the database, and the actual check for
migrating should only be done if this function returns `true`
Check if the schema for ` subgraph ` needs to be migrated and if so if now ( indicated by the block pointer ) is the right time to do so . We try to spread the actual database work associated with checking if a subgraph should be migrated out as much as possible . This function does not query the database and the actual check for migrating should only be done if this function returns ` true `
pub(crate) fn should_migrate(
        &self,
        subgraph: &SubgraphDeploymentId,
        block_ptr: &EthereumBlockPointer,
    ) -> Result<bool, StoreError> {
        // How often to check whether a subgraph needs to be migrated (in
        // blocks) Doing it every 20 blocks translates to roughly once every
        // 5 minutes
        const MIGRATION_CHECK_FREQ: u64 = 20;
        if self.storage.needs_migrating() {
            // We determine whether it is time for us to check if we should
            // migrate in a way that tries to splay the checks for different
            // subgraphs, using the hash of the subgraph id as a somewhat
            // arbitrary indicator. We really just want the checks to be
            // distributed across all possible values mod MIGRATION_CHECK_FREQ
            // so that we don't have a mad dash to migrate every
            // MIGRATION_CHECK_FREQ blocks, which would happen if we checked
            // for `block_ptr.number % MIGRATION_CHECK_FREQ == 0`
            let mut hasher = DefaultHasher::new();
            subgraph.hash(&mut hasher);
            let hash = hasher.finish();
            Ok(hash % MIGRATION_CHECK_FREQ == block_ptr.number % MIGRATION_CHECK_FREQ)
        } else {
            Ok(false)
        }
    }
pub ( crate ) fn should_migrate ( & self , subgraph : & SubgraphDeploymentId , block_ptr : & EthereumBlockPointer , ) -> Result < bool , StoreError > { // How often to check whether a subgraph needs to be migrated (in // blocks) Doing it every 20 blocks translates to roughly once every // 5 minutes const MIGRATION_CHECK_FREQ : u64 = 20 ; if self . storage . needs_migrating ( ) { // We determine whether it is time for us to check if we should // migrate in a way that tries to splay the checks for different // subgraphs, using the hash of the subgraph id as a somewhat // arbitrary indicator. We really just want the checks to be // distributed across all possible values mod MIGRATION_CHECK_FREQ // so that we don't have a mad dash to migrate every // MIGRATION_CHECK_FREQ blocks, which would happen if we checked // for `block_ptr.number % MIGRATION_CHECK_FREQ == 0` let mut hasher = DefaultHasher :: new ( ) ; subgraph . hash ( & mut hasher ) ; let hash = hasher . finish ( ) ; Ok ( hash % MIGRATION_CHECK_FREQ == block_ptr . number % MIGRATION_CHECK_FREQ ) } else { Ok ( false ) } }
Check if the schema for `subgraph` needs to be migrated, and if so
if now (indicated by the block pointer) is the right time to do so.
Check if the schema for ` subgraph ` needs to be migrated and if so if now ( indicated by the block pointer ) is the right time to do so .
&self
subgraph
&SubgraphDeploymentId
block_ptr
&EthereumBlockPointer
&self
subgraph
&SubgraphDeploymentId
block_ptr
&EthereumBlockPointer