Conversation
|
Warning Rate Limit Exceeded@jcstein has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 8 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughIn the realm of code, a sprightly update dances into the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
|
d5bb437 to
e37c361
Compare
|
Relevant: |
There was a problem hiding this comment.
Actionable comments posted: 3
Out of diff range and nitpick comments (14)
developers/golang-client-tutorial.md (1)
17-17: Consider varying the sentence structure to enhance readability.The repeated use of "To" at the beginning of sentences in this paragraph could be rephrased for better flow. For example, "To get your auth token, see this guide. Alternatively, you can run your node without an auth token by using the
--rpc.skip-authflag, which allows you to pass an empty string as your auth token."developers/submit-data.md (3)
Line range hint
29-29: Consider adding a comma for clarity.In the sentence starting with "However," a comma after "However" would improve readability:
- However gas price is often specified by users instead of calculating the flat fee from the gas used and the gas price. + However, gas price is often specified by users instead of calculating the flat fee from the gas used and the gas price.
Line range hint
136-136: Clarify the description of the mempool's behavior.The phrase "each block" might be missing a preposition. It could be clearer as:
- The mempool Celestia uses works by maintaining a fork of the canonical state each block. + The mempool Celestia uses works by maintaining a fork of the canonical state for each block.
Line range hint
151-151: Consider using more formal language in documentation.The verb "fix" could be replaced with a more formal alternative to enhance the professional tone of the documentation:
- ...and a willingness to accept changes to fix this issue. + ...and a willingness to accept changes to address this issue.developers/node-tutorial.md (10)
Line range hint
108-108: Consider adding a comma for clarity.- celestia-node is written in Golang so we must install Golang to build and + celestia-node is written in Golang, so we must install Golang to build and
Line range hint
502-502: Consider revising for conciseness.- In order to interact with the API using RPC CLI, you will need to set the authentication token. + To interact with the API using RPC CLI, set the authentication token.
Line range hint
526-526: Consider revising for conciseness.- In order to interact with the API using RPC CLI, you can also use your node store to set your auth token. + To interact with the API using RPC CLI, you can use your node store to set your auth token.
Line range hint
594-594: Correct the unpaired quotation mark.- or a plaintext string which will be encoded to base64 (`'Hello There!'`) + or a plaintext string which will be encoded to base64 ('Hello There!')
Line range hint
860-860: Consider revising for conciseness.- This is an RPC call in order to get your node's peerId information: + This RPC call retrieves your node's peerId information:
Line range hint
888-888: Consider revising for conciseness.- This is an RPC call in order to get your node's account address: + This RPC call retrieves your node's account address:
Line range hint
1032-1032: Consider using "number" instead of "amount" for countable nouns.- Then, transfer the amount of tokens that you would like, while setting the + Then, transfer the number of tokens that you would like, while setting the
Line range hint
1064-1064: Add "to" for grammatical correctness.- To get help and view the CLI menu, use the following command: + To get help and to view the CLI menu, use the following command:
Line range hint
1091-1091: Consider revising for conciseness.- In order to post a blob using curl, you will need a light node running + To post a blob using curl, you need a light node running
Line range hint
1095-1095: Add the missing article for grammatical correctness.- The flag indicates node to connect to the given core consensus node. + The flag indicates the node to connect to the given core consensus node.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- developers/golang-client-tutorial.md (1 hunks)
- developers/node-tutorial.md (1 hunks)
- developers/submit-data.md (1 hunks)
Additional Context Used
LanguageTool (17)
developers/golang-client-tutorial.md (2)
Near line 17: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... need the node URL and your auth token. To get your auth token, see this [guide](....
Near line 17: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...guide. To run your node without an auth token, yo...developers/node-tutorial.md (12)
Near line 108: Possible missing comma found.
Context: ...all Golang celestia-node is written in Golang so we must install Golang to build and ...
Near line 502: Consider a shorter alternative to avoid wordiness.
Context: ...ore. #### Auth token 🔐 {#auth-token} In order to interact with the API using RPC CLI, yo...
Near line 526: Consider a shorter alternative to avoid wordiness.
Context: ....network arabica) ``` #### Node store In order to interact with the API using RPC CLI, yo...
Near line 594: Unpaired symbol: ‘"’ seems to be missing
Context: ... hex-encoded (0x...), base64-encoded ("..."), or a plaintext string which wi...
Near line 860: Consider a shorter alternative to avoid wordiness.
Context: ...# Get your node ID This is an RPC call in order to get your node's peerId information: ``...
Near line 888: Consider a shorter alternative to avoid wordiness.
Context: ...ur account address This is an RPC call in order to get your node's account address: ```ba...
Near line 1032: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...c02gxspa29wmh0d ``` Then, transfer the amount of tokens that you would like, while se...
Near line 1064: The word ‘help’ is a conjunction. In formal texts, use “to”.
Context: ...$NODE_STORE ``` #### Help To get help and view the CLI menu, use the following co...
Near line 1070: Possible missing article found.
Context: ...:bash celestia --helpTo view help menu for a specific method, use the fol...
Near line 1091: Consider a shorter alternative to avoid wordiness.
Context: ...rces ### Submitting a blob using curl In order to post a blob using curl, you will need a...
Near line 1095: Possible missing article found.
Context: ... consensus endpoint. The flag indicates node to connect to the given core consensus ...
Near line 1158: Possible missing comma found.
Context: ...net faucet has funded your account with tokens and then try again.developers/submit-data.md (3)
Near line 29: A comma may be missing after the conjunctive/linking adverb ‘However’.
Context: ...by specifying and deducting a flat fee. However gas price is often specified by users i...
Near line 136: Possible missing preposition found.
Context: ...intaining a fork of the canonical state each block. This means that each time we sub...
Near line 151: Consider using a different verb for a more formal wording.
Context: ... and a willingness to accept changes to fix this issue. ## API Users can currentl...
Additional comments not posted (2)
developers/golang-client-tutorial.md (2)
6-6: Verify the validity of the link fragment.Verification successful
The output from the executed script confirms that the link fragment
#setting-up-dependenciesexists within thedevelopers/golang-client-tutorial.mdfile. This indicates that the link is correctly pointing to a valid section within the same document, thus verifying the validity of the link fragment as requested in the review comment.Link Fragment Verified in Markdown Document
- The link fragment
#setting-up-dependenciesis correctly used in the markdown filedevelopers/golang-client-tutorial.md.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the validity of the link fragment in the markdown file. # Test: Search for the anchor setting in the markdown file. Expect: At least one occurrence. rg --type md '#setting-up-dependencies' developers/golang-client-tutorial.mdLength of output: 157
83-83: Consider resolving the discussion on error handling before merging.The comment about the ongoing argument regarding error handling in the
GetAllmethod should be resolved or updated before this PR is merged to ensure the tutorial reflects the final decision.
There was a problem hiding this comment.
Actionable comments posted: 2
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- developers/golang-client-tutorial.md (1 hunks)
Additional Context Used
LanguageTool (2)
developers/golang-client-tutorial.md (2)
Near line 17: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... need the node URL and your auth token. To get your auth token, see this [guide](....
Near line 17: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...guide. To run your node without an auth token, yo...
Additional comments not posted (3)
developers/golang-client-tutorial.md (3)
32-77: Ensure consistent indentation in Go code snippets.
86-122: Ensure consistent indentation in Go code snippets.
127-145: Ensure consistent indentation in Go code snippets.
There was a problem hiding this comment.
Actionable comments posted: 3
Out of diff range and nitpick comments (10)
developers/node-tutorial.md (10)
Line range hint
184-184: Consider adding a comma after "correctly" for better readability.- ...the correct version of Go was installed correctly run: + ...the correct version of Go was installed correctly, run:
Line range hint
497-497: Consider rephrasing for clarity and conciseness.- If user passes auth token, auth token is used. + If the user passes an auth token, it is used.
Line range hint
502-502: Consider a shorter alternative to avoid wordiness.- In order to interact with the API using RPC CLI, you will need to set the authentication token. + To interact with the API using RPC CLI, set the authentication token.
Line range hint
526-526: Consider a shorter alternative to avoid wordiness.- In order to interact with the API using RPC CLI, you can also use your node store to set your auth token. + To interact with the API using RPC CLI, you can use your node store to set your auth token.
Line range hint
860-860: Consider a shorter alternative to avoid wordiness.- This is an RPC call in order to get your node's peerId information: + This RPC call retrieves your node's peerId information:
Line range hint
888-888: Consider a shorter alternative to avoid wordiness.- This is an RPC call in order to get your node's account address: + This RPC call retrieves your node's account address:
Line range hint
1032-1032: Consider using "number" instead of "amount" for countable nouns.- Then, transfer the amount of tokens that you would like, while setting the recipient's address, gas fee, and gasLimit. + Then, transfer the number of tokens that you would like, while setting the recipient's address, gas fee, and gasLimit.
Line range hint
1064-1064: Consider adding "to" for grammatical correctness.- To get help and view the CLI menu, use the following command: + To get help and view the CLI menu, use the following command to:
Line range hint
1070-1070: Consider adding an article for grammatical correctness.- To view help menu for a specific method, use the following command: + To view the help menu for a specific method, use the following command:
Line range hint
1091-1091: Consider a shorter alternative to avoid wordiness.- In order to post a blob using curl, you will need a light node running with the `--core.ip string` flag, providing access to a consensus endpoint. + To post a blob using curl, you need a light node running with the `--core.ip string` flag, providing access to a consensus endpoint.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
yarn.lockis excluded by!**/*.lock
Files selected for processing (2)
- developers/golang-client-tutorial.md (1 hunks)
- developers/node-tutorial.md (2 hunks)
Additional Context Used
LanguageTool (14)
developers/golang-client-tutorial.md (2)
Near line 17: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... need the node URL and your auth token. To get your auth token, see this [guide](....
Near line 17: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...guide. To run your node without an auth token, yo...developers/node-tutorial.md (12)
Near line 184: Possible missing comma found.
Context: ...the correct version of Go was installed correctly run:bash go version...
Near line 497: Possible missing article found.
Context: ...se flags in the following order: 1. If user passes auth token, auth token is used. ...
Near line 502: Consider a shorter alternative to avoid wordiness.
Context: ...ore. #### Auth token 🔐 {#auth-token} In order to interact with the API using RPC CLI, yo...
Near line 526: Consider a shorter alternative to avoid wordiness.
Context: ....network arabica) ``` #### Node store In order to interact with the API using RPC CLI, yo...
Near line 594: Unpaired symbol: ‘"’ seems to be missing
Context: ... hex-encoded (0x...), base64-encoded ("..."), or a plaintext string which wi...
Near line 860: Consider a shorter alternative to avoid wordiness.
Context: ...# Get your node ID This is an RPC call in order to get your node's peerId information: ``...
Near line 888: Consider a shorter alternative to avoid wordiness.
Context: ...ur account address This is an RPC call in order to get your node's account address: ```ba...
Near line 1032: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...c02gxspa29wmh0d ``` Then, transfer the amount of tokens that you would like, while se...
Near line 1064: The word ‘help’ is a conjunction. In formal texts, use “to”.
Context: ...$NODE_STORE ``` #### Help To get help and view the CLI menu, use the following co...
Near line 1070: Possible missing article found.
Context: ...:bash celestia --helpTo view help menu for a specific method, use the fol...
Near line 1091: Consider a shorter alternative to avoid wordiness.
Context: ...rces ### Submitting a blob using curl In order to post a blob using curl, you will need a...
Near line 1158: Possible missing comma found.
Context: ...net faucet has funded your account with tokens and then try again.
| text: "Node RPC CLI tutorial" | ||
| link: "/developers/node-tutorial" | ||
| text: "Golang client tutorial" | ||
| link: "/developers/golang-client-tutorial" |
There was a problem hiding this comment.
the prev and next frontmatter allow you to customize the text/link for previous and next pages that are shown at the footer. this is something i mostly use here to skip external links in the menu, preserving the nav flow (page on it in vitepress docs)
There was a problem hiding this comment.
Actionable comments posted: 4
Out of diff range and nitpick comments (13)
developers/prompt-scavenger.md (1)
Line range hint
119-123: Consider using "set up" instead of "setup" when used as a verb.- This will be used for the env var file we setup later. + This will be used for the env var file we set up later.developers/node-tutorial.md (12)
Line range hint
178-178: Consider adding a comma for clarity.- ...the correct version of Go was installed correctly run: + ...the correct version of Go was installed correctly, run:
Line range hint
491-491: Add the definite article "the" for grammatical correctness.- If user passes auth token, auth token is used. + If the user passes an auth token, the auth token is used.
Line range hint
496-496: Simplify the sentence to enhance readability.- In order to interact with the API using RPC CLI, you will need to set the authentication token. + To interact with the API using RPC CLI, set the authentication token.
Line range hint
520-520: Simplify the sentence to enhance readability.- In order to interact with the API using RPC CLI, you can also use your node store to set your auth token. + To interact with the API using RPC CLI, you can also use your node store to set your auth token.
Line range hint
588-588: Ensure proper punctuation for clarity.- ... hex-encoded (`0x...`), base64-encoded (`"..."`), or a plaintext string which will be encoded to base64 (`'Hello There!'`) + ... hex-encoded (`0x...`), base64-encoded (`"..."`), or a plaintext string which will be encoded to base64 (`'Hello There!'`)
Line range hint
854-854: Simplify the sentence to enhance readability.- This is an RPC call in order to get your node's peerId information: + This RPC call retrieves your node's peerId information:
Line range hint
882-882: Simplify the sentence to enhance readability.- This is an RPC call in order to get your node's account address: + This RPC call retrieves your node's account address:
Line range hint
1026-1026: Use "number" instead of "amount" for countable nouns.- Then, transfer the amount of tokens that you would like, while setting the recipient's address, gas fee, and gasLimit. + Then, transfer the number of tokens that you would like, while setting the recipient's address, gas fee, and gasLimit.
Line range hint
1058-1058: Clarify the sentence structure for better readability.- To get help and view the CLI menu, use the following command: + To get help and view the CLI menu, use the following command:
Line range hint
1064-1064: Add the definite article "the" for grammatical correctness.- To view help menu for a specific method, use the following command: + To view the help menu for a specific method, use the following command:
Line range hint
1085-1085: Simplify the sentence to enhance readability.- In order to post a blob using curl, you will need a light node running with the `--core.ip string` flag, providing access to a consensus endpoint. + To post a blob using curl, you need a light node running with the `--core.ip string` flag, providing access to a consensus endpoint.
Line range hint
1152-1152: Add a comma for grammatical correctness.- Ensure the testnet faucet has funded your account with tokens and then try again. + Ensure the testnet faucet has funded your account with tokens, and then try again.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- .vitepress/config.ts (1 hunks)
- developers/golang-client-tutorial.md (1 hunks)
- developers/node-tutorial.md (2 hunks)
- developers/prompt-scavenger.md (1 hunks)
Additional Context Used
LanguageTool (30)
developers/golang-client-tutorial.md (2)
Near line 23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... need the node URL and your auth token. To get your auth token, see this [guide](....
Near line 23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...guide. To run your node without an auth token, yo...developers/node-tutorial.md (12)
Near line 178: Possible missing comma found.
Context: ...the correct version of Go was installed correctly run:bash go version...
Near line 491: Possible missing article found.
Context: ...se flags in the following order: 1. If user passes auth token, auth token is used. ...
Near line 496: Consider a shorter alternative to avoid wordiness.
Context: ...ore. #### Auth token 🔐 {#auth-token} In order to interact with the API using RPC CLI, yo...
Near line 520: Consider a shorter alternative to avoid wordiness.
Context: ....network arabica) ``` #### Node store In order to interact with the API using RPC CLI, yo...
Near line 588: Unpaired symbol: ‘"’ seems to be missing
Context: ... hex-encoded (0x...), base64-encoded ("..."), or a plaintext string which wi...
Near line 854: Consider a shorter alternative to avoid wordiness.
Context: ...# Get your node ID This is an RPC call in order to get your node's peerId information: ``...
Near line 882: Consider a shorter alternative to avoid wordiness.
Context: ...ur account address This is an RPC call in order to get your node's account address: ```ba...
Near line 1026: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...c02gxspa29wmh0d ``` Then, transfer the amount of tokens that you would like, while se...
Near line 1058: The word ‘help’ is a conjunction. In formal texts, use “to”.
Context: ...$NODE_STORE ``` #### Help To get help and view the CLI menu, use the following co...
Near line 1064: Possible missing article found.
Context: ...:bash celestia --helpTo view help menu for a specific method, use the fol...
Near line 1085: Consider a shorter alternative to avoid wordiness.
Context: ...rces ### Submitting a blob using curl In order to post a blob using curl, you will need a...
Near line 1152: Possible missing comma found.
Context: ...net faucet has funded your account with tokens and then try again.developers/prompt-scavenger.md (16)
Near line 38: Unpaired symbol: ‘]’ seems to be missing
Context: ...e installed or obtained: - Golang, see [setting up environment](../nodes/environ...
Near line 39: Unpaired symbol: ‘]’ seems to be missing
Context: ...nt](../nodes/environment.md) - Celestia light node - Ge...
Near line 47: Unpaired symbol: ‘)’ seems to be missing
Context: ...wing commands to get our env vars setup (NOTE: ForCORE_IPyou can select from ...
Near line 71: Unpaired symbol: ‘]’ seems to be missing
Context: ...ceiving the funds on the explorer here: [Interchain Explorer by Cosmostation](htt...
Near line 73: Consider a shorter alternative to avoid wordiness.
Context: ...e to paste yourcelestia1****address in order to look it up. We will be running this ve...
Near line 119: The word “setup” is a noun. The verb is spelled with a space.
Context: ...is will be used for the env var file we setup later. ### OpenAI key Make sure to [g...
Near line 123: Consider a shorter alternative to avoid wordiness.
Context: ...go over to OpenAI](https://openai.com/) in order to sign up for an account and generate an ...
Near line 129: The word “setup” is a noun. The verb is spelled with a space.
Context: ...Prompt Scavenger We will first need to setup a.envfile with the following pasted...
Near line 139: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ..._IP`, it is assumed to be the local host but it can point to a light node that is re...
Near line 142: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ... ID, we made a sample one for you to use but you can generate your own. Now, let’s ...
Near line 189: The word “setup” is a noun. The verb is spelled with a space.
Context: ... func main() { // TODO } ``` Here we setup all required libraries we need to use p...
Near line 230: The word “setup” is a noun. The verb is spelled with a space.
Context: ...in the Node RPC IP and the JWT Token we setup before. Now, if we go back to our `mai...
Near line 247: The word “setup” is a noun. The verb is spelled with a space.
Context: ...nished client.Close() } ``` Here, we setup a workflow that allows us to load our e...
Near line 295: Consider using just “returns”.
Context: ...r a successful submission, the function returns back to you the block height it was submitte...
Near line 320: Consider using just “return”.
Context: ...block height and a namespace ID, it can return back the block data (called shares here) whi...
Near line 322: Consider using just “returns”.
Context: ...helper function that given a prompt, it returns back a statement: ```go // gpt3 processes a...
Additional comments not posted (1)
.vitepress/config.ts (1)
Line range hint
1-672: Configuration looks good and well-structured.
| <!--- | ||
| Yet another thing: There is a argument rn that GetAll should return an error if no blobs are found. I do not agree with this argument, as it is not intuitive to the user, as seen in this example. I will try to resolve this before this PR is merged. | ||
| ---> | ||
|
|
||
| You can subscribe to new headers using the [header.Subscribe](https://node-rpc-docs.celestia.org/?version=v0.11.0#header.Subscribe) method. This method returns a channel that will receive new headers as they are produced. In this example, we will fetch all blobs at the height of the new header in the `0xDEADBEEF` namespace. | ||
|
|
||
| ```go | ||
| // SubscribeHeaders subscribes to new headers and fetches all blobs at the height of the new header in the 0xDEADBEEF namespace. | ||
| func SubscribeHeaders(ctx context.Context, url string, token string) error { | ||
| client, err := client.NewClient(ctx, url, token) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // create a namespace to filter blobs with | ||
| namespace, err := share.NewBlobNamespaceV0([]byte{0xDE, 0xAD, 0xBE, 0xEF}) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // subscribe to new headers using a <-chan *header.ExtendedHeader channel | ||
| headerChan, err := client.Header.Subscribe(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| for { | ||
| select { | ||
| case header := <-headerChan: | ||
| // fetch all blobs at the height of the new header | ||
| blobs, err := client.Blob.GetAll(context.TODO(), header.Height(), []share.Namespace{namespace}) | ||
| if err != nil { | ||
| fmt.Printf("Error fetching blobs: %v\n", err) | ||
| } | ||
|
|
||
| fmt.Printf("Found %d blobs at height %d in 0xDEADBEEF namespace\n", len(blobs), header.Height()) | ||
| case <-ctx.Done(): | ||
| return nil | ||
| } | ||
| } | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Replace tabs with spaces for consistency and replace context.TODO() with ctx to respect the passed context.
- client, err := client.NewClient(ctx, url, token)
- if err != nil {
- return err
- }
+ client, err := client.NewClient(ctx, url, token)
+ if err != nil {
+ return err
+ }
- blobs, err := client.Blob.GetAll(context.TODO(), header.Height(), []share.Namespace{namespace})
+ blobs, err := client.Blob.GetAll(ctx, header.Height(), []share.Namespace{namespace})Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| <!--- | |
| Yet another thing: There is a argument rn that GetAll should return an error if no blobs are found. I do not agree with this argument, as it is not intuitive to the user, as seen in this example. I will try to resolve this before this PR is merged. | |
| ---> | |
| You can subscribe to new headers using the [header.Subscribe](https://node-rpc-docs.celestia.org/?version=v0.11.0#header.Subscribe) method. This method returns a channel that will receive new headers as they are produced. In this example, we will fetch all blobs at the height of the new header in the `0xDEADBEEF` namespace. | |
| ```go | |
| // SubscribeHeaders subscribes to new headers and fetches all blobs at the height of the new header in the 0xDEADBEEF namespace. | |
| func SubscribeHeaders(ctx context.Context, url string, token string) error { | |
| client, err := client.NewClient(ctx, url, token) | |
| if err != nil { | |
| return err | |
| } | |
| // create a namespace to filter blobs with | |
| namespace, err := share.NewBlobNamespaceV0([]byte{0xDE, 0xAD, 0xBE, 0xEF}) | |
| if err != nil { | |
| return err | |
| } | |
| // subscribe to new headers using a <-chan *header.ExtendedHeader channel | |
| headerChan, err := client.Header.Subscribe(ctx) | |
| if err != nil { | |
| return err | |
| } | |
| for { | |
| select { | |
| case header := <-headerChan: | |
| // fetch all blobs at the height of the new header | |
| blobs, err := client.Blob.GetAll(context.TODO(), header.Height(), []share.Namespace{namespace}) | |
| if err != nil { | |
| fmt.Printf("Error fetching blobs: %v\n", err) | |
| } | |
| fmt.Printf("Found %d blobs at height %d in 0xDEADBEEF namespace\n", len(blobs), header.Height()) | |
| case <-ctx.Done(): | |
| return nil | |
| } | |
| } | |
| } | |
| ``` | |
| // SubscribeHeaders subscribes to new headers and fetches all blobs at the height of the new header in the 0xDEADBEEF namespace. | |
| func SubscribeHeaders(ctx context.Context, url string, token string) error { | |
| client, err := client.NewClient(ctx, url, token) | |
| if err != nil { | |
| return err | |
| } | |
| // create a namespace to filter blobs with | |
| namespace, err := share.NewBlobNamespaceV0([]byte{0xDE, 0xAD, 0xBE, 0xEF}) | |
| if err != nil { | |
| return err | |
| } | |
| // subscribe to new headers using a <-chan *header.ExtendedHeader channel | |
| headerChan, err := client.Header.Subscribe(ctx) | |
| if err != nil { | |
| return err | |
| } | |
| for { | |
| select { | |
| case header := <-headerChan: | |
| // fetch all blobs at the height of the new header | |
| blobs, err := client.Blob.GetAll(ctx, header.Height(), []share.Namespace{namespace}) | |
| if err != nil { | |
| fmt.Printf("Error fetching blobs: %v\n", err) | |
| } | |
| fmt.Printf("Found %d blobs at height %d in 0xDEADBEEF namespace\n", len(blobs), header.Height()) | |
| case <-ctx.Done(): | |
| return nil | |
| } | |
| } | |
| } |
Overview
Summary by CodeRabbit
New Features
SubmitBlob,SubscribeHeaders, andGetEDS.Documentation
Bug Fixes