Skip to content

Commit

Permalink
Filipe/arweave gw url (#4806)
Browse files Browse the repository at this point in the history
* Make the arweave url configurable

* bump max connections on ci
  • Loading branch information
mangas committed Aug 21, 2023
1 parent 61d1cd9 commit 14d4bd3
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
6 changes: 4 additions & 2 deletions graph/src/components/link_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use async_trait::async_trait;
use futures03::prelude::Stream;
use reqwest::Client;
use serde_json::Value;
use slog::{debug, o, Logger};
use slog::{debug, Logger};
use thiserror::Error;

use crate::cheap_clone::CheapClone;
Expand Down Expand Up @@ -64,6 +64,8 @@ impl CheapClone for FileSizeLimit {}

impl Default for ArweaveClient {
fn default() -> Self {
use slog::o;

Self {
base_url: "https://arweave.net".parse().unwrap(),
client: Client::default(),
Expand All @@ -77,7 +79,7 @@ impl ArweaveClient {
Self {
base_url,
logger,
..Default::default()
client: Client::default(),
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ pub struct Opt {
help = "HTTP addresses of IPFS nodes\n"
)]
pub ipfs: Vec<String>,
#[clap(
long,
value_name = "{HOST:PORT|URL}",
default_value = "https://arweave.net",
env = "GRAPH_NODE_ARWEAVE_URL",
help = "HTTP base URL for arweave gateway"
)]
pub arweave: String,
#[clap(
long,
default_value = "3",
Expand Down Expand Up @@ -774,6 +782,7 @@ struct Context {
node_id: NodeId,
config: Cfg,
ipfs_url: Vec<String>,
arweave_url: String,
fork_base: Option<Url>,
registry: Arc<MetricsRegistry>,
pub prometheus_registry: Arc<Registry>,
Expand All @@ -785,6 +794,7 @@ impl Context {
node_id: NodeId,
config: Cfg,
ipfs_url: Vec<String>,
arweave_url: String,
fork_base: Option<Url>,
version_label: Option<String>,
) -> Self {
Expand Down Expand Up @@ -812,6 +822,7 @@ impl Context {
fork_base,
registry,
prometheus_registry,
arweave_url,
}
}

Expand Down Expand Up @@ -1041,6 +1052,7 @@ async fn main() -> anyhow::Result<()> {
node,
config,
opt.ipfs,
opt.arweave,
fork_base,
version_label.clone(),
);
Expand Down Expand Up @@ -1171,6 +1183,7 @@ async fn main() -> anyhow::Result<()> {
let store_builder = ctx.store_builder().await;
let job_name = version_label.clone();
let ipfs_url = ctx.ipfs_url.clone();
let arweave_url = ctx.arweave_url.clone();
let metrics_ctx = MetricsContext {
prometheus: ctx.prometheus_registry.clone(),
registry: registry.clone(),
Expand All @@ -1183,6 +1196,7 @@ async fn main() -> anyhow::Result<()> {
store_builder,
network_name,
ipfs_url,
arweave_url,
config,
metrics_ctx,
node_id,
Expand Down
7 changes: 6 additions & 1 deletion node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ async fn main() {
ENV_VARS.mappings.ipfs_timeout,
ENV_VARS.mappings.ipfs_request_limit,
);
let arweave_resolver = Arc::new(ArweaveClient::default());
let arweave_resolver = Arc::new(ArweaveClient::new(
logger.cheap_clone(),
opt.arweave
.parse()
.expect("unable to parse arweave gateway address"),
));

let arweave_service = arweave_service(
arweave_resolver.cheap_clone(),
Expand Down
6 changes: 5 additions & 1 deletion node/src/manager/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub async fn run(
store_builder: StoreBuilder,
network_name: String,
ipfs_url: Vec<String>,
arweave_url: String,
config: Config,
metrics_ctx: MetricsContext,
node_id: NodeId,
Expand All @@ -73,7 +74,10 @@ pub async fn run(
env_vars.mappings.ipfs_timeout,
env_vars.mappings.ipfs_request_limit,
);
let arweave_resolver = Arc::new(ArweaveClient::default());
let arweave_resolver = Arc::new(ArweaveClient::new(
logger.cheap_clone(),
arweave_url.parse().expect("invalid arweave url"),
));
let arweave_service = arweave_service(
arweave_resolver.cheap_clone(),
env_vars.mappings.ipfs_timeout,
Expand Down
8 changes: 8 additions & 0 deletions node/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ pub struct Opt {
help = "HTTP addresses of IPFS nodes"
)]
pub ipfs: Vec<String>,
#[clap(
long,
value_name = "{HOST:PORT|URL}",
default_value = "https://arweave.net",
env = "GRAPH_NODE_ARWEAVE_URL",
help = "HTTP base URL for arweave gateway"
)]
pub arweave: String,
#[clap(
long,
default_value = "8000",
Expand Down

0 comments on commit 14d4bd3

Please sign in to comment.