Skip to content

Commit

Permalink
Make recursive endpoints proxiable (ordinals#3797)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph authored Jun 6, 2024
1 parent ed0939b commit b58fe0c
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 33 deletions.
4 changes: 2 additions & 2 deletions docs/po/zh.po
Original file line number Diff line number Diff line change
Expand Up @@ -7642,7 +7642,7 @@ msgid ""
"of the mainnet inscriptions."
msgstr ""
"为了避免在测试时必须将依赖铭文ID更改为主网铭文ID,你可以在测试时使用内容代"
"理。`ord server`接受一个`--content-proxy`选项,它需要另一个`ord server`实例的"
"理。`ord server`接受一个`--proxy`选项,它需要另一个`ord server`实例的"
"URL。当设置了内容代理并且铭文未找到时,向`/content/<INSCRIPTION_ID>`发出请"
"求,`ord server`将会将请求转发给内容代理。这允许你运行一个带有主网内容代理的"
"测试`ord server`实例。然后你可以在测试铭文中使用主网铭文ID,这将返回主网铭文"
Expand All @@ -7651,7 +7651,7 @@ msgstr ""
#: src/guides/testing.md:155
msgid ""
"```\n"
"ord --regtest server --content-proxy https://ordinals.com\n"
"ord --regtest server --proxy https://ordinals.com\n"
"```"
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions docs/src/guides/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bitcoin-cli generatetoaddress 6 <receive address>

To avoid having to change dependency inscription IDs to mainnet inscription IDs,
you may utilize a content proxy when testing. `ord server` accepts a
`--content-proxy` option, which takes the URL of a another `ord server`
`--proxy` option, which takes the URL of a another `ord server`
instance. When making a request to `/content/<INSCRIPTION_ID>` when a content
proxy is set and the inscription is not found, `ord server` will forward the
request to the content proxy. This allows you to run a test `ord server`
Expand All @@ -154,5 +154,5 @@ in your test inscription, which will then return the content of the mainnet
inscriptions.

```
ord --regtest server --content-proxy https://ordinals.com
ord --regtest server --proxy https://ordinals.com
```
10 changes: 5 additions & 5 deletions src/subcommand/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub(crate) struct Env {
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."
help = "Proxy `/content/INSCRIPTION_ID` and other recursive endpoints to `<PROXY>` if the inscription is not present on current chain."
)]
pub(crate) content_proxy: Option<Url>,
pub(crate) proxy: Option<Url>,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -137,7 +137,7 @@ rpcport={bitcoind_port}
let ord = std::env::current_exe()?;

let decompress = self.decompress;
let content_proxy = self.content_proxy.map(|url| url.to_string());
let proxy = self.proxy.map(|url| url.to_string());

let mut command = Command::new(&ord);
let ord_server = command
Expand All @@ -152,8 +152,8 @@ rpcport={bitcoind_port}
ord_server.arg("--decompress");
}

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

let _ord = KillOnDrop(ord_server.spawn()?);
Expand Down
Loading

0 comments on commit b58fe0c

Please sign in to comment.