738 lines
30 KiB
HTML
738 lines
30 KiB
HTML
|
||
|
||
<!DOCTYPE html>
|
||
<html class="writer-html5" lang="zh-CN" >
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
|
||
<title>Request Examples {#_request_examples} — 北大数瑞大数据区块链 V1.0 文档</title>
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
|
||
|
||
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<!--[if lt IE 9]>
|
||
<script src="../_static/js/html5shiv.min.js"></script>
|
||
<![endif]-->
|
||
|
||
|
||
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/translations.js"></script>
|
||
|
||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||
|
||
|
||
<link rel="index" title="索引" href="../genindex.html" />
|
||
<link rel="search" title="搜索" href="../search.html" />
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav">
|
||
|
||
|
||
<div class="wy-grid-for-nav">
|
||
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search" >
|
||
|
||
|
||
|
||
<a href="../index.html">
|
||
|
||
|
||
|
||
|
||
<img src="../_static/logo.png" class="logo" alt="Logo"/>
|
||
|
||
</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||
<input type="text" name="q" placeholder="在文档中搜索" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
|
||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<p class="caption"><span class="caption-text">目录</span></p>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../Introduction.html">BDContract介绍</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../InstallTips.html">BDContract安装说明</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../IDEUsage.html">BDContract管理界面</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../ContractAPI.html">BDContract SDK</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../YJSInDepth.html">YJS语法</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../YJSAPI.html">YJS SDK</a></li>
|
||
</ul>
|
||
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||
|
||
|
||
<nav class="wy-nav-top" aria-label="top navigation">
|
||
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="../index.html">北大数瑞大数据区块链</a>
|
||
|
||
</nav>
|
||
|
||
|
||
<div class="wy-nav-content">
|
||
|
||
<div class="rst-content">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||
|
||
<ul class="wy-breadcrumbs">
|
||
|
||
<li><a href="../index.html" class="icon icon-home"></a> »</li>
|
||
|
||
<li>Request Examples {#_request_examples}</li>
|
||
|
||
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
<a href="../_sources/markdown_BDWare/httpapi.md.txt" rel="nofollow"> 查看页面源码</a>
|
||
|
||
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<div class="highlight-{.yaml} notranslate"><div class="highlight"><pre><span></span>type: google.api.Service
|
||
config_version: 3
|
||
|
||
http:
|
||
rules:
|
||
- selector: bdware.bdledger.api.Node.ClientVersion
|
||
get: /v0/node/version
|
||
- selector: bdware.bdledger.api.Ledger.CreateLedger
|
||
post: /v0/ledgers
|
||
body: "*"
|
||
- selector: bdware.bdledger.api.Ledger.GetLedgers
|
||
get: /v0/ledgers
|
||
- selector: bdware.bdledger.api.Ledger.SendTransaction
|
||
post: /v0/ledgers/{ledger}/transactions
|
||
body: "*"
|
||
- selector: bdware.bdledger.api.Query.GetBlockByHash
|
||
get: /v0/ledgers/{ledger}/block
|
||
- selector: bdware.bdledger.api.Query.GetBlocks
|
||
post: /v0/ledgers/{ledger}/blocks/query
|
||
body: "*"
|
||
- selector: bdware.bdledger.api.Query.CountBlocks
|
||
post: /v0/ledgers/{ledger}/blocks/count
|
||
body: "*"
|
||
- selector: bdware.bdledger.api.Query.GetRecentBlocks
|
||
get: /v0/ledgers/{ledger}/blocks/recent
|
||
- selector: bdware.bdledger.api.Query.GetTransactionByHash
|
||
get: /v0/ledgers/{ledger}/transaction
|
||
- selector: bdware.bdledger.api.Query.GetTransactionByBlockHashAndIndex
|
||
get: /v0/ledgers/{ledger}/block/transaction
|
||
- selector: bdware.bdledger.api.Query.GetTransactions
|
||
post: /v0/ledgers/{ledger}/transactions/query
|
||
body: "*"
|
||
- selector: bdware.bdledger.api.Query.CountTransactions
|
||
post: /v0/ledgers/{ledger}/transactions/count
|
||
body: "*"
|
||
</pre></div>
|
||
</div>
|
||
<blockquote>
|
||
<div><p><strong>Note</strong></p>
|
||
<p>Request/Response data of <strong>bytes</strong> type should/will be encoded with
|
||
<a class="reference external" href="https://tools.ietf.org/html/rfc4648#section-4">Base64</a>.</p>
|
||
</div></blockquote>
|
||
<blockquote>
|
||
<div><p><strong>Note</strong></p>
|
||
<p>When using hash strings in URL, they need to be encoded with
|
||
<a class="reference external" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">encodeURIComponent</a>.</p>
|
||
</div></blockquote>
|
||
<div class="section" id="request-examples-request-examples">
|
||
<h1>Request Examples {#_request_examples}<a class="headerlink" href="#request-examples-request-examples" title="永久链接至标题">¶</a></h1>
|
||
<div class="section" id="node-clientversion-node-clientversion">
|
||
<h2>Node.ClientVersion {#_node_clientversion}<a class="headerlink" href="#node-clientversion-node-clientversion" title="永久链接至标题">¶</a></h2>
|
||
<p>Get BDLedger node version</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">GET</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">node</span><span class="o">/</span><span class="n">version</span>
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"version": "dev-210119.a88bf4eb"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="ledger-createledger-ledger-createledger">
|
||
<h2>Ledger.CreateLedger {#_ledger_createledger}<a class="headerlink" href="#ledger-createledger-ledger-createledger" title="永久链接至标题">¶</a></h2>
|
||
<p>Create a new ledger</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span>
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Request body.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"name": "test"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"ok": true
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="ledger-getledgers-ledger-getledgers">
|
||
<h2>Ledger.GetLedgers {#_ledger_getledgers}<a class="headerlink" href="#ledger-getledgers-ledger-getledgers" title="永久链接至标题">¶</a></h2>
|
||
<p>Get all ledgers</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">GET</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span>
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"ledgers": [
|
||
"default",
|
||
"test"
|
||
]
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="ledger-sendtransaction-ledger-sendtransaction">
|
||
<h2>Ledger.SendTransaction {#_ledger_sendtransaction}<a class="headerlink" href="#ledger-sendtransaction-ledger-sendtransaction" title="永久链接至标题">¶</a></h2>
|
||
<p>Send a new transaction</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">transactions</span>
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Request body.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"transaction": {
|
||
"type": 0,
|
||
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
|
||
"nonce": 52,
|
||
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
|
||
}
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE="
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="query-getblockbyhash-query-getblockbyhash">
|
||
<h2>Query.GetBlockByHash {#_query_getblockbyhash}<a class="headerlink" href="#query-getblockbyhash-query-getblockbyhash" title="永久链接至标题">¶</a></h2>
|
||
<p>Get a block identified by its hash</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>GET http://{{IP}}:{{PORT}}/v0/ledgers/test/block?hash=LSKr%2BK079Ax%2BrKdlyYN5ze2YGzo%3D
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>hash</strong> has to be encoded with
|
||
<a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">encodeURIComponent</a></p>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"block": {
|
||
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
|
||
"creator": "",
|
||
"nonce": "0",
|
||
"parentHashes": [
|
||
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
|
||
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
|
||
"3XkwkuMBearq8uavN76Te7Zdpl8="
|
||
],
|
||
"witnesses": [],
|
||
"timestamp": "1611038043",
|
||
"size": "0",
|
||
"transactionCount": 1,
|
||
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"transactions": [
|
||
{
|
||
"blockHash": "",
|
||
"blockTimestamp": "0",
|
||
"index": 0,
|
||
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"type": "RECORD",
|
||
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
|
||
"nonce": "0",
|
||
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
|
||
}
|
||
],
|
||
"transactionHashes": [
|
||
"VQBeA5Ee0Y5hqEileoQuYMHbOSE="
|
||
]
|
||
}
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="query-getblocks-query-getblocks">
|
||
<h2>Query.GetBlocks {#_query_getblocks}<a class="headerlink" href="#query-getblocks-query-getblocks" title="永久链接至标题">¶</a></h2>
|
||
<p>Get blocks in a timestamp range</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">blocks</span><span class="o">/</span><span class="n">query</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="highlight-{.protobuf} notranslate"><div class="highlight"><pre><span></span>enum IncludeTransactions {
|
||
NONE = 0; // Don't include transaction data
|
||
HASH = 1; // Include transactions hashes
|
||
FULL = 2; // Include full transactions
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p>Requirement: asciimath:[“start_timestamp”⇐”end_timestamp”]</p>
|
||
<p>If only <strong>end_timestamp</strong> is not specified, or
|
||
asciimath:[“end_timestamp”-“start_timestamp”>”query.maxDuration”],
|
||
then <strong>end_timestamp</strong> will be set to
|
||
asciimath:[“start_timestamp”+”query.maxDuration”].</p>
|
||
<p>If only <strong>start_timestamp</strong> is not specified, then <strong>start_timestamp</strong>
|
||
will be set to asciimath:[“end_timestamp”-“query.maxDuration”].</p>
|
||
<p>In all cases, <strong>start_timestamp</strong> will never be earlier than the
|
||
genesis block’s timestamp, and <strong>end_timestamp</strong> will never be later
|
||
than the current timestamp when the node process the query request.</p>
|
||
<p><strong>Request body 1.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"start_timestamp": 1611038000,
|
||
"end_timestamp": 1611039000,
|
||
"include_transactions": 0
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response 1.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"blocks": [
|
||
{
|
||
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
|
||
"creator": "",
|
||
"nonce": "0",
|
||
"parentHashes": [
|
||
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
|
||
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
|
||
"3XkwkuMBearq8uavN76Te7Zdpl8="
|
||
],
|
||
"witnesses": [],
|
||
"timestamp": "1611038043",
|
||
"size": "0",
|
||
"transactionCount": 1,
|
||
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"transactions": [],
|
||
"transactionHashes": []
|
||
}
|
||
],
|
||
"startTimestamp": "1611038043",
|
||
"endTimestamp": "1611038043"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Request body 2.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"start_timestamp": 1611038000,
|
||
"end_timestamp": 1611039000,
|
||
"include_transactions": 1
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response 2.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"blocks": [
|
||
{
|
||
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
|
||
"creator": "",
|
||
"nonce": "0",
|
||
"parentHashes": [
|
||
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
|
||
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
|
||
"3XkwkuMBearq8uavN76Te7Zdpl8="
|
||
],
|
||
"witnesses": [],
|
||
"timestamp": "1611038043",
|
||
"size": "0",
|
||
"transactionCount": 1,
|
||
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"transactions": [],
|
||
"transactionHashes": [
|
||
"VQBeA5Ee0Y5hqEileoQuYMHbOSE="
|
||
]
|
||
}
|
||
],
|
||
"startTimestamp": "1611038043",
|
||
"endTimestamp": "1611038043"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Request body 3.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"start_timestamp": 1611038000,
|
||
"end_timestamp": 1611039000,
|
||
"include_transactions": 2
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response 3.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"blocks": [
|
||
{
|
||
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
|
||
"creator": "",
|
||
"nonce": "0",
|
||
"parentHashes": [
|
||
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
|
||
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
|
||
"3XkwkuMBearq8uavN76Te7Zdpl8="
|
||
],
|
||
"witnesses": [],
|
||
"timestamp": "1611038043",
|
||
"size": "0",
|
||
"transactionCount": 1,
|
||
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"transactions": [
|
||
{
|
||
"blockHash": "",
|
||
"blockTimestamp": "0",
|
||
"index": 0,
|
||
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"type": "RECORD",
|
||
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
|
||
"nonce": "0",
|
||
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
|
||
}
|
||
],
|
||
"transactionHashes": [
|
||
"VQBeA5Ee0Y5hqEileoQuYMHbOSE="
|
||
]
|
||
}
|
||
],
|
||
"startTimestamp": "1611038043",
|
||
"endTimestamp": "1611038043"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="query-countblocks-query-countblocks">
|
||
<h2>Query.CountBlocks {#_query_countblocks}<a class="headerlink" href="#query-countblocks-query-countblocks" title="永久链接至标题">¶</a></h2>
|
||
<p>Count all blocks in a ledger, or blocks in a timestamp range</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">blocks</span><span class="o">/</span><span class="n">count</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Requirement: asciimath:[“start_timestamp”⇐”end_timestamp”]</p>
|
||
<p>If neither <strong>start_timestamp</strong> nor <strong>end_timestamp</strong> is specified,
|
||
then count all blocks in the specified ledger.</p>
|
||
<p>If only <strong>end_timestamp</strong> is not specified, then count all blocks with
|
||
timestamps later than <strong>start_timestamp</strong>.</p>
|
||
<p>If only <strong>start_timestamp</strong> is not specified, then count all blocks
|
||
with timestamps earlier than <strong>end_timestamp</strong>.</p>
|
||
<p>In all cases, <strong>start_timestamp</strong> will never be earlier than the
|
||
genesis block’s timestamp, and <strong>end_timestamp</strong> will never be later
|
||
than the current timestamp when the node process the query request.</p>
|
||
<p><strong>Request body 1.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response 1.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"count": "5",
|
||
"startTimestamp": "0",
|
||
"endTimestamp": "1611039957"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Request body 2.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"start_timestamp": 1611038000,
|
||
"end_timestamp": 1611039000
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response 2.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"count": "1",
|
||
"startTimestamp": "1611038000",
|
||
"endTimestamp": "1611039000"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="query-getrecentblocks-query-getrecentblocks">
|
||
<h2>Query.GetRecentBlocks {#_query_getrecentblocks}<a class="headerlink" href="#query-getrecentblocks-query-getrecentblocks" title="永久链接至标题">¶</a></h2>
|
||
<p>Get recent <strong>count</strong> blocks (Only support IncludeTransactions=NONE for
|
||
now)</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>GET http://{{IP}}:{{PORT}}/v0/ledgers/test/blocks/recent?count=2
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"blocks": [
|
||
{
|
||
"hash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
|
||
"creator": "",
|
||
"nonce": "0",
|
||
"parentHashes": [
|
||
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
|
||
"rk0DWMaUpRG82yVX+cFhbfhPFdw=",
|
||
"3XkwkuMBearq8uavN76Te7Zdpl8="
|
||
],
|
||
"witnesses": [],
|
||
"timestamp": "1611038043",
|
||
"size": "0",
|
||
"transactionCount": 1,
|
||
"transactionsRoot": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"transactions": [],
|
||
"transactionHashes": []
|
||
},
|
||
{
|
||
"hash": "rk0DWMaUpRG82yVX+cFhbfhPFdw=",
|
||
"creator": "",
|
||
"nonce": "0",
|
||
"parentHashes": [
|
||
"fLX5pMY8M1qSAGZdKT1rWBkdEMo=",
|
||
"3XkwkuMBearq8uavN76Te7Zdpl8=",
|
||
"8pZPR74OALIbps5XFb4dL/s0j0M="
|
||
],
|
||
"witnesses": [],
|
||
"timestamp": "1610968019",
|
||
"size": "0",
|
||
"transactionCount": 1,
|
||
"transactionsRoot": "LuxttCm/pSHVMOKF0sJExk+DJXc=",
|
||
"transactions": [],
|
||
"transactionHashes": []
|
||
}
|
||
],
|
||
"startTimestamp": "1610968019",
|
||
"endTimestamp": "1611038043"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="query-gettransactionbyhash-query-gettransactionbyhash">
|
||
<h2>Query.GetTransactionByHash {#_query_gettransactionbyhash}<a class="headerlink" href="#query-gettransactionbyhash-query-gettransactionbyhash" title="永久链接至标题">¶</a></h2>
|
||
<p>Get a transaction identified by its hash</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>GET http://{{IP}}:{{PORT}}/v0/ledgers/test/transaction?hash=VQBeA5Ee0Y5hqEileoQuYMHbOSE%3D
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>hash</strong> has to be encoded with
|
||
<a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">encodeURIComponent</a></p>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"transaction": {
|
||
"blockHash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
|
||
"blockTimestamp": "1611038043",
|
||
"index": 0,
|
||
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"type": "RECORD",
|
||
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
|
||
"nonce": "0",
|
||
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
|
||
}
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="query-gettransactionbyblockhashandindex-query-gettransactionbyblockhashandindex">
|
||
<h2>Query.GetTransactionByBlockHashAndIndex {#_query_gettransactionbyblockhashandindex}<a class="headerlink" href="#query-gettransactionbyblockhashandindex-query-gettransactionbyblockhashandindex" title="永久链接至标题">¶</a></h2>
|
||
<p>Get a transaction identified by hash of the block it belongs to and its
|
||
index inside the block</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>GET http://{{IP}}:{{PORT}}/v0/ledgers/test/block/transaction?blockHash=LSKr%2BK079Ax%2BrKdlyYN5ze2YGzo%3D&index=0
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>blockHash</strong> has to be encoded with
|
||
<a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent">encodeURIComponent</a></p>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"transaction": {
|
||
"blockHash": "LSKr+K079Ax+rKdlyYN5ze2YGzo=",
|
||
"blockTimestamp": "1611038043",
|
||
"index": 0,
|
||
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"type": "RECORD",
|
||
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
|
||
"nonce": "0",
|
||
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
|
||
}
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="query-gettransactions-query-gettransactions">
|
||
<h2>Query.GetTransactions {#_query_gettransactions}<a class="headerlink" href="#query-gettransactions-query-gettransactions" title="永久链接至标题">¶</a></h2>
|
||
<p>Get transactions in a timestamp range</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">transactions</span><span class="o">/</span><span class="n">query</span>
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>start_timestamp</strong> and <strong>end_timestamp</strong> follow the same requirements
|
||
and rules as in <a class="reference external" href="#Query.GetBlocks">???</a>.</p>
|
||
<p><strong>Request body.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"start_timestamp": 1611038000,
|
||
"end_timestamp": 1611039000
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"transactions": [
|
||
{
|
||
"blockHash": "",
|
||
"blockTimestamp": "0",
|
||
"index": 0,
|
||
"hash": "VQBeA5Ee0Y5hqEileoQuYMHbOSE=",
|
||
"type": "RECORD",
|
||
"from": "8A3K/vANyv7wDcr+8A3K/vANyv4=",
|
||
"nonce": "0",
|
||
"to": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
||
"data": "lQItWZKS5hlUn6V/DMKKwvZXxvM="
|
||
}
|
||
],
|
||
"startTimestamp": "1611038043",
|
||
"endTimestamp": "1611038043"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="query-counttransactions-query-counttransactions">
|
||
<h2>Query.CountTransactions {#_query_counttransactions}<a class="headerlink" href="#query-counttransactions-query-counttransactions" title="永久链接至标题">¶</a></h2>
|
||
<p>Count all transactions in a ledger, or transactions in a timestamp range</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">POST</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{{</span><span class="n">IP</span><span class="p">}}:{{</span><span class="n">PORT</span><span class="p">}}</span><span class="o">/</span><span class="n">v0</span><span class="o">/</span><span class="n">ledgers</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">transactions</span><span class="o">/</span><span class="n">count</span>
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>start_timestamp</strong> and <strong>end_timestamp</strong> follow the same requirements
|
||
and rules as in <a class="reference external" href="#Query.CountBlocks">???</a>.</p>
|
||
<p><strong>Request body 1.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response 1.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"count": "4",
|
||
"startTimestamp": "0",
|
||
"endTimestamp": "1611039957"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Request body 2.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"start_timestamp": 1611038000,
|
||
"end_timestamp": 1611039000
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
<p><strong>Response 2.</strong></p>
|
||
<div class="highlight-{.json} notranslate"><div class="highlight"><pre><span></span>{
|
||
"count": "1",
|
||
"startTimestamp": "1611038000",
|
||
"endTimestamp": "1611039000"
|
||
}
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<footer>
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>
|
||
© 版权所有 2021, Peking University.
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
|
||
利用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 构建,使用了
|
||
|
||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">主题</a>
|
||
|
||
由 <a href="https://readthedocs.org">Read the Docs</a>开发.
|
||
|
||
</footer>
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function () {
|
||
SphinxRtdTheme.Navigation.enable(true);
|
||
});
|
||
</script>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</body>
|
||
</html> |