Skip to content

Commit 4fc4d01

Browse files
author
David Himmelstrup
committed
initial draft for command-line tool for keeping the archival S3 bucket up-to-date
1 parent 945fe89 commit 4fc4d01

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/tool/subcommands/archive_cmd.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ pub enum ArchiveCommands {
126126
#[arg(long)]
127127
depth: Option<u64>,
128128
},
129+
SyncBucket {
130+
#[arg(required = true)]
131+
snapshot_files: Vec<PathBuf>,
132+
},
129133
}
130134

131135
impl ArchiveCommands {
@@ -174,7 +178,7 @@ impl ArchiveCommands {
174178
epoch,
175179
depth,
176180
} => show_tipset_diff(snapshot_files, epoch, depth).await,
177-
}
181+
Self::SyncBucket { snapshot_files } => sync_bucket(snapshot_files).await,
178182
}
179183
}
180184

@@ -581,6 +585,22 @@ async fn show_tipset_diff(
581585
Ok(())
582586
}
583587

588+
// This command is used for keeping the S3 bucket of archival snapshots
589+
// up-to-date. It takes a set of snapshot files and queries the S3 bucket to see
590+
// what is missing. If the input set of snapshot files can be used to generate
591+
// missing lite or diff snapshots, they'll be generated and uploaded to the S3
592+
// bucket.
593+
async fn sync_bucket(snapshot_files: Vec<PathBuf>) -> anyhow::Result<()> {
594+
// Compute the range of epochs that are covered by the input snapshot files.
595+
let store = ManyCar::try_from(snapshot_files)?;
596+
let heaviest_tipset = store.heaviest_tipset()?;
597+
let genesis = heaviest_tipset.genesis(&store)?;
598+
let network = NetworkChain::from_genesis_or_devnet_placeholder(genesis.cid());
599+
600+
601+
Ok(())
602+
}
603+
584604
#[cfg(test)]
585605
mod tests {
586606
use super::*;

0 commit comments

Comments
 (0)