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

Add default content proxy and decompress to env command #3509

Merged
merged 5 commits into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions src/subcommand/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ impl Drop for KillOnDrop {
pub(crate) struct Env {
#[arg(default_value = "env", help = "Create env in <DIRECTORY>.")]
directory: PathBuf,
#[arg(
long,
help = "Decompress encoded content. Currently only supports brotli. Be careful using this on production instances. A decompressed inscription may be arbitrarily large, making decompression a DoS vector."
)]
pub(crate) decompress: bool,
#[arg(
long,
help = "Proxy `/content/INSCRIPTION_ID` requests to `<CONTENT_PROXY>/content/INSCRIPTION_ID` if the inscription is not present on current chain."
)]
pub(crate) content_proxy: Option<Url>,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -117,16 +127,27 @@ rpcport={bitcoind_port}

let ord = std::env::current_exe()?;

let _ord = KillOnDrop(
Command::new(&ord)
.arg("--datadir")
.arg(&absolute)
.arg("server")
.arg("--polling-interval=100ms")
.arg("--http-port")
.arg(ord_port.to_string())
.spawn()?,
);
let decompress = self.decompress;
let content_proxy = self.content_proxy.map(|url| url.to_string());

let mut command = Command::new(&ord);
let ord_server = command
.arg("--datadir")
.arg(&absolute)
.arg("server")
.arg("--polling-interval=100ms")
.arg("--http-port")
.arg(ord_port.to_string());

if decompress {
ord_server.arg("--decompress");
}

if let Some(content_proxy) = content_proxy {
ord_server.arg("--content-proxy").arg(content_proxy);
}

let _ord = KillOnDrop(ord_server.spawn()?);

thread::sleep(Duration::from_millis(250));

Expand Down
Loading