daex區塊鏈
Ⅰ 華碩FA5060M5800一0DAEXHA6X11筆記本電腦多少錢一台
准確型號是天選2 ,FA506QM,建議參考華碩京東官方旗艦店價格:
Ⅱ 怎樣通過RPC命令實現區塊鏈的查詢
基本架構如下:
前端web基於socket.io或者REST實現,
後端加一層mongodb/mysql等資料庫來代替單機leveldb做數據存儲
目的應該是:
1. 加速查詢
2. 做更高層的數據分析
3.做分布式資料庫
思考:
這些online的查詢固然可以方便我們的日常用, 那如何與相關應用集成呢? 我們是否可以通過簡單的rpc命令實現同等的效果?
有幾個用處:
1 . 大家都可以做自己的qukuai.com或blockchain.info的查詢:)
2. 集成RPC命令到自己的店鋪,收款後查詢用
3. 集成到錢包應用
4. 其他應用場景
cmd分析:
根據高度height查block hash
./bitcoin-cli getblockhash 19999
2. 然後根據block hash查block 信息
./bitcoin-cli getblock
{
"hash" : "",
"confirmations" : 263032,
"size" : 215,
"height" : 19999,
"version" : 1,
"merkleroot" : "",
"tx" : [
""
],
"time" : 1248291140,
"nonce" : 1085206531,
"bits" : "1d00ffff",
"difficulty" : 1.00000000,
"chainwork" : "",
"previousblockhash" : "",
"nextblockhash" : ""
}
3. 根據tx查詢單筆交易的信息:
沒建index時,只能查詢自己錢包的信息,若不是錢包的交易,則返回如下:
./bitcoin-cli getrawtransaction
error: {"code":-5,"message":"Invalid or non-wallet transaction id"}
那怎麼辦呢? 直接分析代碼找原因:
// Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
{
CBlockIndex *pindexSlow = NULL;
{
LOCK(cs_main);
{
if (mempool.lookup(hash, txOut))
{
return true;
}
}
if (fTxIndex) {
CDiskTxPos postx;
if (pblocktree->ReadTxIndex(hash, postx)) {
CAutoFile file(OpenBlockFile(postx, true), SER_DISK, CLIENT_VERSION);
CBlockHeader header;
try {
file >> header;
fseek(file, postx.nTxOffset, SEEK_CUR);
file >> txOut;
} catch (std::exception &e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
hashBlock = header.GetHash();
if (txOut.GetHash() != hash)
return error("%s : txid mismatch", __func__);
return true;
}
}
if (fAllowSlow) { // use coin database to locate block that contains transaction, and scan it
int nHeight = -1;
{
CCoinsViewCache &view = *pcoinsTip;
CCoins coins;
if (view.GetCoins(hash, coins))
nHeight = coins.nHeight;
}
if (nHeight > 0)
pindexSlow = chainActive[nHeight];
}
}
if (pindexSlow) {
CBlock block;
if (ReadBlockFromDisk(block, pindexSlow)) {
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
if (tx.GetHash() == hash) {
txOut = tx;
hashBlock = pindexSlow->GetBlockHash();
return true;
}
}
}
}
return false;
}