1

I want to get all the node IP addresses of ETH, so I need to parse the geth/nodes directory, but I can't find the specific data format and cannot parse it.

I found a same problem, but there is no solution: Format of LevelDB files in nodes directory? Trouble pulling contents with python leveldb API

My code:

import leveldb
import rlp

db = leveldb.LevelDB("../nodes")
for k in db.RangeIter():
    print(k)
    print(rlp.decode(k[0]))
    break

Result:

(bytearray(b'local:\xc6\x83\x00\xb8LX\xcc+\xcd\x98CDd\x96\x89R\x92\x1a\xaeV\xe1\x93\xfeV\x95)\t~$e\xfa|:seq'), bytearray(b'\x97\x08'))
Traceback (most recent call last):
  File "temp.py", line 7, in <module>
    print(rlp.decode(k[0]))
  File "PATH/.local/lib/python3.6/site-packages/rlp/codec.py", line 235, in decode
    raise DecodingError(msg, rlp)
rlp.exceptions.DecodingError: RLP string ends with 41 superfluous bytes

I searched a lot of information and found that rlp.sedes needs to be specified when decoding. I can't determine which kind of sedes it is. I am a newcomer to ETH and I need help. Examples of parsing in other programming languages are also available.

Thank you.

0

I have no idea on how to do it with leveldb. But you could use the admin.peers from geth api/cli that return something like that:

[{
    caps: ["eth/61", "eth/62", "eth/63"],
    id: "08a6b39263470c78d3e4f58e3c997cd2e7af623afce64656cfc56480babcea7a9138f3d09d7b9879344c2d2e457679e3655d4b56eaff5fd4fd7f147bdb045124",
    name: "Geth/v1.5.0-unstable/linux/go1.5.1",
    network: {
      localAddress: "192.168.0.104:51068",
      remoteAddress: "71.62.31.72:30303"
    },
    protocols: {
      eth: {
        difficulty: 17334052235346465000,
        head: "5794b768dae6c6ee5366e6ca7662bdff2882576e09609bf778633e470e0e7852",
        version: 63
      }
    }
}, /* ... */ {
    caps: ["eth/61", "eth/62", "eth/63"],
    id: "fcad9f6d3faf89a0908a11ddae9d4be3a1039108263b06c96171eb3b0f3ba85a7095a03bb65198c35a04829032d198759edfca9b63a8b69dc47a205d94fce7cc",
    name: "Geth/v1.3.5-506c9277/linux/go1.4.2",
    network: {
      localAddress: "192.168.0.104:55968",
      remoteAddress: "121.196.232.205:30303"
    },
    protocols: {
      eth: {
        difficulty: 17335165914080772000,
        head: "5794b768dae6c6ee5366e6ca7662bdff2882576e09609bf778633e470e0e7852",
        version: 63
      }
    }
}]

documentation here

The remoteAddress should be what you are looking for. But keep in mind that just the list of your node peers and not the whole list of ethereum nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.