mirror of
https://github.com/logos-storage/bittorrent-benchmarks.git
synced 2026-01-03 13:33:07 +00:00
28 lines
533 B
Python
28 lines
533 B
Python
import math
|
|
|
|
from pydantic import BaseModel
|
|
|
|
API_VERSION = "v1"
|
|
|
|
Cid = str
|
|
|
|
|
|
class Manifest(BaseModel):
|
|
cid: Cid
|
|
treeCid: Cid
|
|
datasetSize: int
|
|
blockSize: int
|
|
filename: str
|
|
mimetype: str
|
|
protected: bool
|
|
|
|
@property
|
|
def block_count(self) -> int:
|
|
return math.ceil(self.datasetSize / self.blockSize)
|
|
|
|
@staticmethod
|
|
def from_codex_api_response(response: dict) -> "Manifest":
|
|
return Manifest.model_validate(
|
|
dict(cid=response["cid"], **response["manifest"])
|
|
)
|