检查点
返回由证明生成器节点产出的密码学同步检查点列表,使客户端能够针对特定区块高度校验数据完整性。
端点
POST https://indexer.pivx.name/v1.0/checkpoints
请求体
请求体必须是包含以下参数的 JSON 对象:
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
count | integer | 100 | 限制单次响应中返回的检查点最大数量。 |
from_block | integer | 无 | 从该区块高度开始请求检查点数据。 |
order | string | desc | 检查点的排序方式。可接受的取值:asc 或 desc。 |
代码示例
- cURL
- JavaScript
- Python
- PHP
curl -X POST https://indexer.pivx.name/v1.0/checkpoints \
-H "Content-Type: application/json" \
-d '{
"count": 2,
"from_block": 1,
"order": "asc"
}'
const url = 'https://indexer.pivx.name/v1.0/checkpoints';
const data = {
count: 2,
from_block: 1,
order: 'asc'
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
import requests
url = "https://indexer.pivx.name/v1.0/checkpoints"
payload = {
"count": 2,
"from_block": 1,
"order": "asc"
}
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$url = 'https://indexer.pivx.name/v1.0/checkpoints';
$data = [
'count' => 2,
'from_block' => 1,
'order' => 'asc'
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
响应示例
{
"response": [
{
"idx": 41,
"block_id": 3422048,
"smt_root": "b4c9dacf8e194e353dce7638d76f282fe40399f7b0ad74a2229a6d4f5be774de"
},
{
"idx": 42,
"block_id": 3422335,
"smt_root": "eba675788f0fbf1df8a3c32e83da3e71dfd9337cca5a7c8ae2f51e963d03be17"
}
]
}
| 字段 | 类型 | 说明 |
|---|---|---|
idx | int | 在锚定合约 rootChain 数组中的位置;检查点发现的续传游标 |
block_id | int | 该检查点所包含的最后一个 PIVX block_id |
smt_root | string | 该检查点的 SMT 根 |