[关闭]
@sqfasd 2016-11-07T15:02:37.000000Z 字数 1569 阅读 1363

中金云storage私链服务接口

未分类


0 通用错误处理

每一个接口都返回json数据
每个响应都包含success字段,表示请求是否成功,成功为true, 失败为false
如果失败,则还会包含一个error字段,表示错误原因

  1. {
  2. "success": false,
  3. "error": "Invalide content encode type"
  4. }

1 上传数据

请求

路径 /api/storages
方法 put
格式 json
说明 上传数据

参数列表

名称 类型 必填 说明
secret string Y asch账户密码
content string Y 上传数据内容
encode string N 上传数据的格式,可选项为:raw/base64/hex,默认为raw
wait number N 等待确认数,范围为0-6,默认为0

特别说明 wait为0表示不等待,速度最快,但无法保证数据在掉电情况下不丢失,大于2时,可以100%确保数据已经同步到大部分机器上了,但需要时间较长10-20秒之间,折中的方案是1,wait为1时虽然不能100%保证同步到其他机器,但失败的几率非常小,只是理论上存在,实际上还没遇到过

示例

  1. curl -k -H "Content-Type: application/json" -X PUT -d '{"secret":"mirror napkin recycle parent rough point arctic suspect film cage orchard spot","content":"aGVsbG93b3JsZA==","encode":"base64","wait":1}' http://10.1.238.16:6666/api/storages

响应

  1. {
  2. "success": true,
  3. "transactionId": "12642332469631378771"
  4. }

2 查询数据

请求

路径 /api/storages/get
方法 get
格式 urlencode
说明 获取数据

参数列表

名称 类型 必填 说明
id string Y 交易id

示例

  1. curl http://10.1.238.16:6666/api/storages/get?id=12642332469631378771

响应

  1. {
  2. "success": true,
  3. "id": "12642332469631378771", // 交易id
  4. "height": "43", // 交易所在区块高度
  5. "blockId": "1610713892747510166", // 交易所在区块id
  6. "type": 8, // 交易类型
  7. "timestamp": 11470937, // 交易时间,举例创世块的offset
  8. "senderPublicKey": "8e2916ec9bf9807fdac2d0f0263a02be587a49f45ab0ce7fa50b3a7b01a3af9d", // 上传者公钥
  9. "senderId": "8329974131975904225", // 上传者id
  10. "recipientId": "", // 可忽略
  11. "amount": 0, // 可忽略
  12. "fee": 10000000, // 交易费
  13. "signature": "4129d535c8f041e9ea6721ab1ecc91bb965756612494c6264cb75016ec2757de72a540f48623dd6aa403f97b53f5e7bd6a7e790905a6947e58fd82b25d4ceb03", // 交易签名
  14. "signSignature": "", // 二级签名,有二级密码时才有
  15. "signatures": null, // 多重签名,使用多重签名账户时才有
  16. "confirmations": "3", // 交易确认数
  17. "asset": {
  18. "storage": {
  19. "content": "68656c6c6f776f726c64" // 数据内容,16进制字符串
  20. }
  21. }
  22. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注