Skip to content

Commit

Permalink
feat: update baseurl, use r2
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-reorg committed Nov 26, 2024
1 parent 153482c commit a18462f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ This issue will be fixed in the next release.
Additionally, you can get the latest snapshot url and sha256 checksum as below:

```
$ curl https://opbnb-snapshot-mainnet.bnbchain.org/geth-pbss-latest
$ curl https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-pbss-latest
geth-pbss-20240525.tar.gz
$ curl https://opbnb-snapshot-mainnet.bnbchain.org/geth-pbss-20240525.tar.gz.sha256
$ curl https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-pbss-20240525.tar.gz.sha256
d361af99362f3e6c55984e4aff127fffe9939e5c28274450f4b168b04d87370a geth-pbss-20240525.tar.gz
```

Expand All @@ -54,7 +54,7 @@ d361af99362f3e6c55984e4aff127fffe9939e5c28274450f4b168b04d87370a geth-pbss-2024
### Step 1: Download the snapshot and decompress it.

```bash
wget -q -O - https://opbnb-snapshot-mainnet.bnbchain.org/geth-pbss-20240525.tar.gz | tar -xvf -
wget -q -O - https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-mainnet-pbss-20241125.tar.gz | tar -xvf -
```

### Step 2: Replace the data.
Expand Down
6 changes: 3 additions & 3 deletions README.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ This issue will be fixed in the next release.
Additionally, you can get the latest snapshot url and sha256 checksum as below:

```
$ curl https://opbnb-snapshot-mainnet.bnbchain.org/geth-pbss-latest
$ curl {{baseURL}}/geth-pbss-latest
geth-pbss-20240525.tar.gz

$ curl https://opbnb-snapshot-mainnet.bnbchain.org/geth-pbss-20240525.tar.gz.sha256
$ curl {{baseURL}}/geth-pbss-20240525.tar.gz.sha256
d361af99362f3e6c55984e4aff127fffe9939e5c28274450f4b168b04d87370a geth-pbss-20240525.tar.gz
```

Expand All @@ -54,7 +54,7 @@ d361af99362f3e6c55984e4aff127fffe9939e5c28274450f4b168b04d87370a geth-pbss-2024
### Step 1: Download the snapshot and decompress it.

```bash
wget -q -O - https://opbnb-snapshot-mainnet.bnbchain.org/geth-pbss-20240525.tar.gz | tar -xvf -
wget -q -O - {{mainnetPbss.url}} | tar -xvf -
```

### Step 2: Replace the data.
Expand Down
23 changes: 13 additions & 10 deletions auto_update.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Template from "https://deno.land/x/[email protected]/mod.ts";

const baseURL = "https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev";

// date format: YYYYMMDD, e.g. 20231102
function getSnapshotURL(
network:
Expand All @@ -12,15 +14,15 @@ function getSnapshotURL(
): string {
const dateString = date.toISOString().substr(0, 10).replace(/-/g, "");
if (network === "mainnet") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-mainnet-${dateString}.tar.gz`;
return `${baseURL}/geth-mainnet-${dateString}.tar.gz`;
} else if (network === "mainnet_prune") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-mainnet-prune-${dateString}.tar.gz`;
return `${baseURL}/geth-mainnet-prune-${dateString}.tar.gz`;
} else if (network === "mainnet_pbss") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-mainnet-pbss-${dateString}.tar.gz`;
return `${baseURL}/geth-mainnet-pbss-${dateString}.tar.gz`;
} else if (network === "testnet_pbss") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-testnet-pbss-${dateString}.tar.gz`;
return `${baseURL}/geth-testnet-pbss-${dateString}.tar.gz`;
} else if (network === "testnet") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-testnet-${dateString}.tar.gz`;
return `${baseURL}/geth-testnet-${dateString}.tar.gz`;
} else {
throw new Error("invalid network");
}
Expand Down Expand Up @@ -83,15 +85,15 @@ function getLatestSnapshotURL(
| "testnet_pbss"
) {
if (network === "mainnet") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-mainnet-latest`;
return `${baseURL}/geth-mainnet-latest`;
} else if (network === "mainnet_prune") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-mainnet-prune-latest`;
return `${baseURL}/geth-mainnet-prune-latest`;
} else if (network === "mainnet_pbss") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-mainnet-pbss-latest`;
return `${baseURL}/geth-mainnet-pbss-latest`;
} else if (network === "testnet_pbss") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-testnet-pbss-latest`;
return `${baseURL}/geth-testnet-pbss-latest`;
} else if (network === "testnet") {
return `https://pub-2ea2209b4ee74f4398c5ac50c3b2efeb.r2.dev/geth-testnet-latest`;
return `${baseURL}/geth-testnet-latest`;
} else {
throw new Error("invalid network");
}
Expand All @@ -110,6 +112,7 @@ async function main() {
mainnetPbss: mainnetPbssLatestSnapshotURL,
// testnet: testnetLatestSnapshotURL,
testnetPbss: testnetPbssLatestSnapshotURL,
baseURL,
updatedAt: new Date().toISOString(),
};
console.log(data);
Expand Down

0 comments on commit a18462f

Please sign in to comment.