Skip to content

feat:Added podsi method #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

AnonO6
Copy link

@AnonO6 AnonO6 commented Jul 26, 2025

User description

Description

Implemeted podsi method

New Features

A method to retrieve proof of data storage and integrity (PODSI) from the Lighthouse network.


PR Type

Enhancement


Description

  • Added PODSI method for proof of data storage and integrity

  • Implemented comprehensive TypedDict structures for API response

  • Added error handling for non-existent proofs


Diagram Walkthrough

flowchart LR
  A["Client Request"] --> B["get_lighthouse_proof()"]
  B --> C["Lighthouse API"]
  C --> D["PODSI Response"]
  D --> E["TypedDict Structures"]
Loading

File Walkthrough

Relevant files
Formatting
config.py
Minor formatting fix                                                                         

src/lighthouseweb3/functions/config.py

  • Added trailing newline to configuration file
+1/-0     
Enhancement
podsi.py
Implement PODSI proof retrieval functionality                       

src/lighthouseweb3/functions/podsi.py

  • Created comprehensive TypedDict structures for PODSI data types
  • Implemented get_lighthouse_proof() function with CID parameter
  • Added error handling for 400 status codes and request exceptions
  • Integrated with existing Config class for API endpoint
+56/-0   

Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Return Type Mismatch

The function returns raw JSON data but is annotated to return PODSIData TypedDict. The returned data should be validated or cast to ensure it matches the expected structure.

data = response.json()
return data
Error Handling

The error handling for 400 status code is duplicated in both the main try block and the exception handler. This could lead to inconsistent behavior.

        if response.status_code == 400:
            raise Exception("Proof Doesn't exist yet")
        raise Exception(f"Request failed with status code {response.status_code}")

    data = response.json()
    return data

except requests.RequestException as error:
    if hasattr(error, 'response') and error.response and error.response.status_code == 400:
        raise Exception("Proof Doesn't exist yet")

Copy link

codiumai-pr-agent-free bot commented Jul 26, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Validate API response structure

The function returns raw JSON data without validating it against the defined
PODSIData type. This could lead to runtime errors if the API response doesn't
match the expected structure. Consider validating the response against the
defined TypedDict.

src/lighthouseweb3/functions/podsi.py [41-51]

 def get_lighthouse_proof(cid: str) -> PODSIData:
     try:
         response = requests.get(f"{Config.lighthouse_api}/api/lighthouse/get_proof?cid={cid}")
         
         if not response.ok:
             if response.status_code == 400:
                 raise Exception("Proof Doesn't exist yet")
             raise Exception(f"Request failed with status code {response.status_code}")
         
         data = response.json()
+        # Basic validation that the response matches our expected structure
+        if "pieceCID" not in data or "dealInfo" not in data:
+            raise Exception("API response doesn't match expected PODSIData structure")
         return data
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that the function doesn't validate the API response against the PODSIData type hint, and adding a check improves robustness.

Medium
  • Update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant