Comments (9)
thanks for reporting! I'll look into it today First thing. 1) did you have cpp-ethereum running first? That guide just shows how to read cpp-ethereum's db. If you didn't run cpp-ethereum at some point there will be no DB. 2) Did you have cpp-ethereum running while you tried to read the DB? leveldb can't have more than one reader at a time. So you need to make use cpp-ethereum is not running while you are trying to read the DB.
from ethereumjs-lib.
Thank you for the quick response! I opened and closed AlethZero, and I checked that ~/.ethereum/state/LOCK exists.
BTW, I noticed that the example code has .ethereum in the app's local directory. So I tried copying .ethereum to ./. LevelUp loaded the ./.ethereum/state database just fine, but when I changed
var db = levelup('./.ethereum/state');
to
var db = levelup('~/.ethereum/state');
so that .ethereum would be loaded from the home directory, I get the same error: "~/.ethereum/state/LOCK: No such file or directory", even though I checked, and the file does exist. I also tried running the code with root access, and nothing changed.
Edit: I found the problem. levelup doesn't process ~/ as my home directory. Using a relative path to the home directory fixes the problem. But I wonder why ~/ isn't processed as my home?
Now I'm just having the problem that I don't know how to copy a block's state's root from the AlethZero client.
BTW, I don't know where to post general usage questions, so I'll ask here: My goal currently is to have the Node server listen for transactions that go to a specific address and to trigger an event whenever a transaction arrives. I'm just starting looking at the API, and I'm wondering if this is possible yet.
from ethereumjs-lib.
I don't think "~" will work; you have to use the full path or a relative path.
... and I'm wondering if this is possible yet.
It is. But I probably need to update the docs. There are two ways to do it. Do you want to run a full node? ie actually validate and run VM. Or do you just want a 'dumb' node that listens to the network?
Here is how to do simple listener
var Network = require('ethereumjs-lib').Network;
var network = new Network({
ethVersion: 32,
capabilities: ['eth']
});
//the protocol requires that we send a genesis hash after we connect so that we
// know we have the correct blockchain. Currently the genesis the following
var genesisHash = new Buffer('08436a4d33c77e6acf013e586a3333ad152f25d31df8b68749d85046810e1f4b', 'hex');
//send our status.
network.on('message.hello', function (hello, peer) {
//arguments: totally difficultly, highest block, genesisHash
peer.sendStatus(new Buffer([0]), genesisHash, genesisHash);
console.log('networking', 'hello from: ' + hello.clientId + ' version:' + hello.protocolVersion);
});
network.on('message.transactions', function (txs) {
txs.forEach(function(tx){
//you can insert your logic here.
console.log('got a transaction to: ' + tx.to.toString('hex'));
});
});
network.listen(30303, "0.0.0.0");
//or use network.connect
Lastly feel free to open new issue if you have more questions like this.
from ethereumjs-lib.
Thanks!
That code looks easy enough to use. Unfortunately, when I run it, I never get a hello message, so nothing happens. Any idea what's gone wrong? I'm confused about the code -- the "//arguments: totally difficultly, highest block, genesisHash" comment doesn't seem to match any code.
For now, I'll stick to a 'dumb' node, but I'd like to try a full node in the future. I'm just experimenting with Ethereum right now to see what I can do. My first project is to prove to the server that the client owns an Ethereum address.
from ethereumjs-lib.
when I run it, I never get a hello message
Right, that's because its only listening. If you have another client such cpp-ethereum you can connect to it. Or you can initiate a connection with network.listen(port, ip);
As far as the send status that is pretty new and it is not in the docs yet. If you want to read about the protocol see here
from ethereumjs-lib.
OK. I changed it to "network.connect(30303, "poc-6.ethdev.com");"
It connects and gets a hello message, but it disconnects immediately after, so it never gets any blocks or messages. :(
I also tried using "network.listen(30304, "0.0.0.0");" and connecting to it with the AlethZero client. Same thing. I get a hello message and then immediately disconnect.
from ethereumjs-lib.
I'm going to try this out. But off the top of my head I'm guesing network version is wrong. I tested the above snippet against version 32. I think we are now at 33. I'll try to get you an update ASAP.
from ethereumjs-lib.
Hi Martin,
Changing the version number to 33 didn't work. Still haven't gotten the library to successfully connect to ethereum.
I'm going to close this issue though and open up a new one.
from ethereumjs-lib.
@ldurback I added PoC7 networking and this is working for me now
var Network = require('ethereumjs-lib').Network;
var network = new Network();
var genesisHash = new Buffer('08436a4d33c77e6acf013e586a3333ad152f25d31df8b68749d85046810e1f4b', 'hex');
network.on('message.hello', function (hello, peer) {
peer.sendStatus(new Buffer([0]), genesisHash, genesisHash);
console.log('networking', 'hello from: ' + hello.clientId + ' version:' + hello.protocolVersion);
});
network.on('message.transactions', function (txs) {
txs.forEach(function (tx) {
console.log('got a transaction to: ' + tx.to.toString('hex'));
});
});
network.on('message.disconnect', function (dis) {
console.log('networking', 'dissconect: ' + dis.reason);
});
network.listen(30303, "0.0.0.0");
network.connect(30303, "poc-7.ethdev.com");
from ethereumjs-lib.
Related Issues (20)
- update blockchain tests
- rename getSenderPublickey -> from
- Invalid transaction when nonce=0 HOT 4
- TODOs
- SPV light-client support HOT 15
- Can't create a contract in VM HOT 1
- Couldn't create a contract in VM HOT 3
- update blockchain api HOT 2
- Add blockchain Tests HOT 1
- BlockProcess updates HOT 1
- update Docs
- Can't determine number of topics of logN in VM HOT 11
- runBlock() fails with the error undefinedinvalid receiptTrie HOT 2
- Export account to keystore json? HOT 5
- about transactions and blocks HOT 5
- installation error - [email protected]? HOT 5
- `npm install` fails HOT 6
- Missing "r"s in the readme HOT 6
- Meteor 1.3 Integration HOT 3
- Install package on windows HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ethereumjs-lib.