Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

a question about get txs #55

Closed
poria-cat opened this issue Dec 11, 2017 · 8 comments
Closed

a question about get txs #55

poria-cat opened this issue Dec 11, 2017 · 8 comments

Comments

@poria-cat
Copy link

poria-cat commented Dec 11, 2017

After read code, I found that txs store in a nother database (txCache)which will not sync by Tendermint. So that means when I query a tx information in one peer, I can get it. If I query this information in another peer, I can’t get it, right? Emmmm, I have another question : how to let one lotion peer connect another one? I can’t find this way in document 😅😅😅

@keppel
Copy link
Owner

keppel commented Dec 11, 2017

hey @Elvenisboy, great questions!

If I query this information in another peer, I can’t get it, right?

correct, you'll only wanna GET /txs to interact with a lotion server running locally.

how to let one lotion peer connect another one?

you can specify the locations of other tendermint nodes you want to connect to like this:

let app = lotion({
  p2pPort: 46656,
  peers: [
    'localhost:46657',
    '12.22.11.33:46657',
    '<ip>:<p2p-port>',
    '<other-ip>:<other-p2p-port>'
  ]
  // ... plus your other app options here ...
})

also consider whether a light client might do what you need in this section of the readme!

thanks @Elvenisboy, holla if anything else is confusing.

@poria-cat
Copy link
Author

Aha, thanks for you answer @keppel😁. This is a sad story if I can get txs only in local. In a Blockchain app , we can’t avoid querying txs in database. Such as query somebody’s account balance or develop a Blockchain explorer. So if I wanna to get a complete data, what should I do? 😀😀

@keppel
Copy link
Owner

keppel commented Dec 12, 2017

you can run a full node locally, connect it to a peer, then querying /txs should give you the same output on either node!

Such as query somebody’s account balance

you should probably just keep account balances in your state object, and query /state to figure out someone's balance! it should be pretty rare that you need to directly query /txs, it's usually just the current state of your blockchain that you'll care about for most apps.

@poria-cat
Copy link
Author

@keppel OK~ Thank you for your help😋

@poria-cat
Copy link
Author

Hey~keppel @keppel I found a interesting thing. when i run couter app, and add a tx in it like this:

 curl http://localhost:3000/txs -d '{"name":"b"}'

then, use this url in firefox:

http://localhost:3000/tendermint/abci_query?data="name"

it will give me a message in bash:

FATAL ERROR STACK:  RangeError: not enough data for decode
    at Object.decode (/home/elven/Work/test-lotion/node_modules/varstruct/lib/varbuffer.js:28:41)
    at Object.decode (/home/elven/Work/test-lotion/node_modules/varstruct/lib/varstring.js:19:31)
    at /home/elven/Work/test-lotion/node_modules/varstruct/lib/object.js:36:36
    at Object.exports.size (/home/elven/Work/test-lotion/node_modules/varstruct/lib/util.js:6:49)
    at Object.decode (/home/elven/Work/test-lotion/node_modules/varstruct/lib/object.js:35:27)
    at exports.decode.queryBuffer (/home/elven/Work/test-lotion/node_modules/lotion/lib/query-encoding.js:9:29)
    at AbciApp.abciApp.query (/home/elven/Work/test-lotion/node_modules/lotion/lib/abci-app.js:139:17)
    at Connection.msgCb (/home/elven/Work/test-lotion/node_modules/lotion/lib/abci/server.js:70:34)
    at Connection.appendData (/home/elven/Work/test-lotion/node_modules/lotion/lib/abci/connection.js:38:10)
    at Socket.<anonymous> (/home/elven/Work/test-lotion/node_modules/lotion/lib/abci/connection.js:15:10)
FATAL ERROR:  RangeError: not enough data for decode
    at Object.decode (/home/elven/Work/test-lotion/node_modules/varstruct/lib/varbuffer.js:28:41)
    at Object.decode (/home/elven/Work/test-lotion/node_modules/varstruct/lib/varstring.js:19:31)
    at /home/elven/Work/test-lotion/node_modules/varstruct/lib/object.js:36:36
    at Object.exports.size (/home/elven/Work/test-lotion/node_modules/varstruct/lib/util.js:6:49)
    at Object.decode (/home/elven/Work/test-lotion/node_modules/varstruct/lib/object.js:35:27)
    at exports.decode.queryBuffer (/home/elven/Work/test-lotion/node_modules/lotion/lib/query-encoding.js:9:29)
    at AbciApp.abciApp.query (/home/elven/Work/test-lotion/node_modules/lotion/lib/abci-app.js:139:17)
    at Connection.msgCb (/home/elven/Work/test-lotion/node_modules/lotion/lib/abci/server.js:70:34)
    at Connection.appendData (/home/elven/Work/test-lotion/node_modules/lotion/lib/abci/connection.js:38:10)
    at Socket.<anonymous> (/home/elven/Work/test-lotion/node_modules/lotion/lib/abci/connection.js:15:10)

emmmm, and I found that I can't add a new tx in blockchain, so sad 😢

This may be a bug for tendermint 😕

@keppel
Copy link
Owner

keppel commented Dec 13, 2017

not a bug in tendermint, just related to the way I handle abci queries in the abci server that lotion manages!

for now, I'd pretend /tendermint doesn't exist -- you should be able to build an app on just /txs and /state.

if you wanna describe what you'd like to do, I'd be happy to explain how exactly you might go about building it w/ lotion!

thanks for your questions btw -- I'll try to clarify the things you ask about in the readme. :)

@poria-cat
Copy link
Author

poria-cat commented Dec 13, 2017

Thanks again~ I wanna develop a ACG community with tendermint and lotion~ Few days ago, I found lotion, and it is friendly than cosmos-sdk(I think) 😄 Can I join lotion slack group? @keppel

@keppel
Copy link
Owner

keppel commented Jan 10, 2018

awesome! you absolutely may jump in the slack. :)

@keppel keppel closed this as completed Jan 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants