rchain-community / rchain-api

An API for rchain dapps to communicate with the blockchain
Other
22 stars 12 forks source link

getAllBlocks does not return its result #61

Closed ziqiDev closed 5 years ago

ziqiDev commented 5 years ago

Hello,

when I call 'getAllBlocks' through API, many value is empty, But when call "show-blocks" through command line, there is some value in it ? I have tried to figure out what's wrong with that, but failed. Could you help me ?

dckc commented 5 years ago

More details, please?

How exactly did you call getAllBlocks through an API?

How exactly did you call "show-blocks" through a command line? If you were using rnode show-blocks, note that's a separate repository: https://github.com/rchain/rchain

The code in this repository is a bit behind; see #60.

ziqiDev commented 5 years ago

Whether getAllBlocks through api has the same result with rnode show-blocks?

dckc commented 5 years ago

Point me to your code for calling getAllBlocks?

dckc commented 5 years ago

try again now that #60 is done?

ziqiDev commented 5 years ago

queryBlock() async function queryBlock () { const host = 'localhost'; const port = 40401; const rnode = RNode(require('grpc'),{host, port}); const res = await rnode.getAllBlocks() console.log('res:'+res); }

The log is res:undefined Please point it out if I am wrong.

another question, what's the difference between rnode show-blocks through command line and call getAllBlocks through the rchain-api?

JoshOrndorff commented 5 years ago

I haven't tried to reproduce your results. Just helping the thinking process.

Are you sure that your blockdag actually has any blocks in it? I wonder what the expected result is when there are no blocks to be gotten. We should have a test for that. I guess it should be an empty list.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Sunday, April 7, 2019 10:57 PM, Richard notifications@github.com wrote:

queryBlock() async function queryBlock () { const host = 'localhost'; const port = 40401; const rnode = RNode(require('grpc'),{host, port}); const res = await rnode.getAllBlocks() console.log('res:'+res); } The log is res:undefined Please point it out if I am wrong.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

ziqiDev commented 5 years ago

`rnode show-blocks

------------- block 1 --------------- blockHash: "2ff2678938d9749d4d1693d8ca15fd14381c1704ece224520fcf373fdc1aa0ac" blockSize: "1220" blockNumber: 1 version: 1 deployCount: 1 tupleSpaceHash: "a4e1ff938f6d38000ad281d0e7f1c2a6d0ac0c315a7aa37a024991aeaa6a3fcc" timestamp: 1554730610630 faultTolerance: -1.0 mainParentHash: "d0f736d1c4b1aeab77902b2eb81a577406faa773190b2dac41865ffe03700327" parentsHashList: "d0f736d1c4b1aeab77902b2eb81a577406faa773190b2dac41865ffe03700327" sender: "64b5119f8f7aff56cf0f864ae475d449a7f9b7cb0a951d347cbd685a8c5f3603"


count: 1`

But when I run the code upper, the result is undefined

dckc commented 5 years ago

fixed in 2670374 . If it doesn't work, let us know.

It works here now:

~/projects/RChain-API$ node test/testRNode.js --net
TAP version 13
...
# smart contract deploy
ok 5 should be equal
# test getAllBlocks
ok 6 should be equal
ok 7 should be equivalent
...