Skip to content

Commit

Permalink
chore: add retry
Browse files Browse the repository at this point in the history
  • Loading branch information
OasisLCrypto committed Dec 10, 2024
1 parent c13b189 commit 878f728
Show file tree
Hide file tree
Showing 4 changed files with 785 additions and 493 deletions.
53 changes: 40 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The **walrus-go** SDK provides a Go client for interacting with the [Walrus](htt
- [StoreOptions](#storeoptions)
- [Methods](#methods)
- [Store](#store)
- [StoreReader](#storereader)
- [StoreFromReader](#StoreFromReader)
- [StoreFromURL](#storefromurl)
- [StoreFile](#storefile)
- [Head](#head)
Expand Down Expand Up @@ -60,16 +60,25 @@ import (
)

func main() {
// Create client with default testnet endpoints
client := walrus.NewClient()

// Or customize with specific options
client := walrus.NewClient(
"https://aggregator.walrus-testnet.walrus.space",
"https://publisher.walrus-testnet.walrus.space",
walrus.WithAggregatorURLs([]string{"https://custom-aggregator.example.com"}),
walrus.WithPublisherURLs([]string{"https://custom-publisher.example.com"}),
walrus.WithHTTPClient(customHTTPClient),
)

// Your code here
}
```

Replace the URLs with the aggregator and publisher endpoints you wish to use.
By default, the client uses testnet endpoints. You can customize the client using the following options:

- `WithAggregatorURLs(urls []string)`: Set custom aggregator URLs
- `WithPublisherURLs(urls []string)`: Set custom publisher URLs
- `WithHTTPClient(client *http.Client)`: Set a custom HTTP client

### Storing Data

Expand Down Expand Up @@ -114,12 +123,12 @@ func (c *Client) Store(data []byte, opts *StoreOptions) (*StoreResponse, error)
- `*StoreResponse`: The complete response containing either NewlyCreated or AlreadyCertified information.
- `error`: Error if the operation fails.

#### StoreReader
#### StoreFromReader

Stores data from an io.Reader on the Walrus Publisher.

```go
func (c *Client) StoreReader(reader io.Reader, contentLength int64, opts *StoreOptions) (*StoreResponse, error)
func (c *Client) StoreFromReader(reader io.Reader, contentLength int64, opts *StoreOptions) (*StoreResponse, error)
```

**Parameters:**
Expand Down Expand Up @@ -277,22 +286,40 @@ The `Client` struct is used to interact with the Walrus API.

#### Fields

- `AggregatorURL string`: The base URL of the Walrus Aggregator.
- `PublisherURL string`: The base URL of the Walrus Publisher.
- `httpClient *http.Client`: The HTTP client used for requests.
- `AggregatorURL []string`: The base URLs of the Walrus Aggregators
- `PublisherURL []string`: The base URLs of the Walrus Publishers
- `httpClient *http.Client`: The HTTP client used for requests

#### NewClient

Creates a new `Client` instance.
Creates a new `Client` instance with optional configuration.

```go
func NewClient(aggregatorURL, publisherURL string) *Client
func NewClient(opts ...ClientOption) *Client
```

**Parameters:**

- `aggregatorURL string`: The aggregator's base URL.
- `publisherURL string`: The publisher's base URL.
- `opts ...ClientOption`: Optional configuration functions

**Available Options:**

- `WithAggregatorURLs(urls []string)`: Set custom aggregator URLs
- `WithPublisherURLs(urls []string)`: Set custom publisher URLs
- `WithHTTPClient(client *http.Client)`: Set a custom HTTP client

**Example:**

```go
// Use default testnet endpoints
client := walrus.NewClient()

// Customize specific options
client := walrus.NewClient(
// optional: walrus.WithAggregatorURLs([]string{"https://custom-aggregator.example.com"}),
// optional: walrus.WithPublisherURLs([]string{"https://custom-publisher.example.com"}),
)
```

### StoreOptions

Expand Down
51 changes: 51 additions & 0 deletions endpoints.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package walrus_go

var DefaultTestnetPublishers = []string{
"https://publisher.walrus-testnet.walrus.space",
"https://wal-publisher-testnet.staketab.org",
"https://walrus-testnet-publisher.bartestnet.com",
"https://walrus-testnet-publisher.nodes.guru",
"https://sui-walrus-testnet.bwarelabs.com/publisher",
"https://walrus-testnet-publisher.stakin-nodes.com",
"https://testnet-publisher-walrus.kiliglab.io",
"https://walrus-testnet-publisher.nodeinfra.com",
"https://walrus-testnet.blockscope.net:11444",
"https://walrus-publish-testnet.chainode.tech:9003",
"https://walrus-testnet-publisher.starduststaking.com:11445",
"http://walrus-publisher-testnet.overclock.run:9001",
"http://walrus-testnet-publisher.everstake.one:9001",
"http://walrus.testnet.pops.one:9001",
"http://ivory-dakar-e5812.walrus.bdnodes.net:9001",
"http://publisher.testnet.sui.rpcpool.com:9001",
"http://walrus.krates.ai:9001",
"http://walrus-publisher-testnet.latitude-sui.com:9001",
"http://walrus-tn.juicystake.io:9090",
"http://walrus-testnet.stakingdefenseleague.com:9001",
"http://walrus.sui.thepassivetrust.com:9001",
"http://walrus.globalstake.io:9001",
}

var DefaultTestnetAggregators = []string{
"https://aggregator.walrus-testnet.walrus.space",
"https://wal-aggregator-testnet.staketab.org",
"https://walrus-testnet-aggregator.bartestnet.com",
"https://walrus-testnet.blockscope.net",
"https://walrus-testnet-aggregator.nodes.guru",
"https://walrus-cache-testnet.overclock.run",
"https://sui-walrus-testnet.bwarelabs.com/aggregator",
"https://walrus-testnet-aggregator.stakin-nodes.com",
"https://testnet-aggregator-walrus.kiliglab.io",
"https://walrus-cache-testnet.latitude-sui.com",
"https://walrus-testnet-aggregator.nodeinfra.com",
"https://walrus-tn.juicystake.io:9443",
"https://walrus-agg-testnet.chainode.tech:9002",
"https://walrus-testnet-aggregator.starduststaking.com:11444",
"http://walrus-testnet-aggregator.everstake.one:9000",
"http://walrus.testnet.pops.one:9000",
"http://scarlet-brussels-376c2.walrus.bdnodes.net:9000",
"http://aggregator.testnet.sui.rpcpool.com:9000",
"http://walrus.krates.ai:9000",
"http://walrus-testnet.stakingdefenseleague.com:9000",
"http://walrus.sui.thepassivetrust.com:9000",
"http://walrus.globalstake.io:9000",
}
Loading

0 comments on commit 878f728

Please sign in to comment.