filecoin-station / spark-api

💥 SPARK API
https://github.com/filecoin-station/spark
Other
3 stars 1 forks source link

feat: get retrievable deals per miner or client #388

Closed bajtos closed 1 month ago

bajtos commented 1 month ago

Links:

Out of the scope of this pull request:

Example request:

GET /retrievable-deals/miner/:minerId

Example response:

[
  {
    "clientId": "f02516933",
    "dealCount": 6880
  },
  {
    "clientId": "f02833886",
    "dealCount": 3126
  }
]

Example request:

GET /retrievable-deals/client/:clientId

Example response:

[
  {
    "minerId": "f0406478",
    "dealCount": 4592
  },
  {
    "minerId": "f0814049",
    "dealCount": 758
  }
]
bajtos commented 1 month ago

@patrickwoodhead I reworked the implementation, below are the new examples. I'll need to update the README, but I'll wait until we agree on the new API request & response formats.

Example request:

GET /miner/f0814049/retrievable-deals/summary

Example response:

{
  "minerId": "f0814049",
  "clients": [
    { "clientId": "f02516933", "dealCount": 6880 },
    { "clientId": "f02833886", "dealCount": 3126 }
  ]
}

Example request:

GET /clients/f0215074/retrievable-deals/summary

Example response:

{
  "clientId": "f0215074",
  "providers": [
    { "minerId": "f0406478", "dealCount": 4592 },
    { "minerId": "f0814049", "dealCount": 758 }
  ]
}
bajtos commented 1 month ago
{
  "clientId": "f0215074",
  "providers": [
    { "minerId": "f0406478", "dealCount": 4592 },
    { "minerId": "f0814049", "dealCount": 758 }
  ]
}

Two questions to consider:

  1. Should the top-level property be called providers or miners?
  2. Since the response contains a summary, maybe we can abbreviate the field name dealCount to deals?
{
  "clientId": "f0215074",
  "miners": [
    { "minerId": "f0406478", "deals": 4592 },
    { "minerId": "f0814049", "deals": 758 }
  ]
}
bajtos commented 1 month ago

I realised that this new API should be implemented in spark-stats to make it part of the Spark Stats product. I moved the implementation to https://github.com/filecoin-station/spark-stats/pull/194