0

I am trying to sync to Ethereum mainnet.

when attach the running geth to console and execute admin.peers I get below output

[{
    caps: ["eth/63"],
    id: "147fd0986cdba18279e309149290431e874a2ff0d72a18d2a81bb02d2bf0b65456b7419eb21800516177767b5037449950a9ad7f3d06c910df760c89d76c9ff1",
    name: "Geth/v1.7.3-stable-4bb3c89d/darwin-amd64/go1.9.2",
    network: {
      localAddress: "10.10.25.218:59778",
      remoteAddress: "71.236.189.250:30303"
    },
    protocols: {
      eth: {
        difficulty: 17179869184,
        head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
        version: 63
      }
    }
}, {
    caps: ["eth/63"],
    id: "1bba662f185f45cd68465ee3b340ed107a1bc309c6e7f3ad4634e69fa5f864d4daf1a1188cf2cd38659027aee5d33daecf9d04f1a003b136cfa3605f22ca590b",
    name: "Geth/v1.7.2-stable-1db4ecdc/windows-amd64/go1.9",
    network: {
      localAddress: "10.10.25.218:59736",
      remoteAddress: "85.72.54.240:30303"
    },
    protocols: {
      eth: {
        difficulty: 17179869184,
        head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
        version: 63
      }
    }
}, {
    caps: ["eth/63"],
    id: "4630000bc70b789a45b58beba3944c050ac9998e55db40b6e8ea5df1da95bf1452863c3271f48341854a0de4f1a5ce6578c424ab04af510d68b1745125d26dac",
    name: "Geth/v1.7.2-stable-1db4ecdc/linux-amd64/go1.9",
    network: {
      localAddress: "10.10.25.218:50086",
      remoteAddress: "189.27.174.216:30303"
    },
    protocols: {
      eth: {
        difficulty: 17179869184,
        head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
        version: 63
      }
    }
}, {
    caps: ["eth/63"],
    id: "a4c00346511940ed69d408fb8801efd5ad2822985817c6f5f534591463befc00ba21c23a76c19e4ee9bb91b215b02300b9b7d14105711a0a4f75951f89e148a9",
    name: "Geth/v1.8.0-unstable-a139041d/linux-amd64/go1.9.2",
    network: {
      localAddress: "10.10.25.218:38442",
      remoteAddress: "46.29.13.213:30303"
    },
    protocols: {
      eth: {
        difficulty: 17179869184,
        head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
        version: 63
      }
    }
}, {
    caps: ["eth/63"],
    id: "ab3662c8e1b62b36444a50f87af14e7668a6afcf15f4d7a1fd3bb160dc945360378edb6ab63a7d518d26372c89fb559fd37f00010f9d090c2ecfdc303874a3f9",
    name: "Geth/v1.7.2-stable-1db4ecdc/windows-amd64/go1.9",
    network: {
      localAddress: "10.10.25.218:35660",
      remoteAddress: "95.43.38.32:30303"
    },
    protocols: {
      eth: {
        difficulty: 17179869184,
        head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
        version: 63
      }
    }
}, {
    caps: ["eth/63"],
    id: "d1254b0d24582469d3f0e8a4692f27155ad40d46ebc2c74a700d94e68d9f8fc903022140661185aa2367f5738ea9b75066e66f83076198e12643257701668467",
    name: "Geth/v1.8.0-unstable-3a5a5599/linux-amd64/go1.7.4",
    network: {
      localAddress: "10.10.25.218:33204",
      remoteAddress: "144.76.60.212:30303"
    },
    protocols: {
      eth: {
        difficulty: 17179869184,
        head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
        version: 63
      }
    }
}]

and if I run net.getPeerCount(), I get below output

    > net.getPeerCount()
      undefined
    >

I was hoping it will give me the count of the peers which were output of admin.peers

  • "This property is read only and returns the number of connected peers." github.com/ethereum/wiki/wiki/JavaScript-API#web3netpeercount – ʰᵈˑ Jan 10 '18 at 11:35
  • So isn't the output of admin.peers give me the list and details of connected peers? – Ajay Jan 10 '18 at 11:39
  • 1
    It is, but try calling net.peerCount without the parenthesis – ʰᵈˑ Jan 10 '18 at 12:37
  • @ʰᵈˑ This is what i get If I call it without parenthesis - > net.getPeerCount function(callback) > – Ajay Jan 10 '18 at 13:03
0

As noted above, to see the property value use net.peerCount, not net.getPeerCount

  • but I want to know what does ` net.getPeerCount` give? – Ajay Jan 10 '18 at 16:32
  • 1
    They both return the same thing, but getPeerCount is asynchronous so it requires a call back function to execute when it completes web3.net.getPeerCount(callback(error, result){ ... }) – chris2187 Jan 10 '18 at 17:29
0

net.peerCount() is a command which returns number of Peers connected to your node.

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.