Have a Geth 1.5.5 node running on a raspberry pi 3. When I type in
sudo systemctl status geth
I'll get ever changing time and block information. Neat, but how do I know when I am synced up? Is there another sudo command I should do?
Continuing to research, need to enter the geth node console to enter special commands. The following works:
geth attach
Sends user to the geth node console.
eth.syncing
Produces a result like current block: 82,100; highest block 2,910,032.
exit
To go back to Pi prompt.
eth.syncing
just getting false
printed
Commented
Jun 24, 2017 at 3:45
geth attach ipc:\\.\pipe\geth.ipc
Commented
Jun 30, 2018 at 16:06
false
means you are fully synced already (technically just means that it is not syncing actually so I suppose maybe it could also mean you aren't syncing for some reason other than being fully sync'd ... hmmmm)
Commented
Dec 4, 2020 at 3:47
After running your normal geth --fast command you can open a new window and run the "geth attach" command as this will attach you to the javascript interface
$ geth attach
Then you can use this script to have a nice output of what is happening. It is very rudimentary but works really well to give you an idea of how long you will still need to wait. First wait 10 seconds (as the first ETA is incorrect) then after the second display of estimates you will start to see the actual numbers.
var lastPercentage = 0;var lastBlocksToGo = 0;var timeInterval = 10000;
setInterval(function(){
var percentage = eth.syncing.currentBlock/eth.syncing.highestBlock*100;
var percentagePerTime = percentage - lastPercentage;
var blocksToGo = eth.syncing.highestBlock - eth.syncing.currentBlock;
var bps = (lastBlocksToGo - blocksToGo) / (timeInterval / 1000)
var etas = 100 / percentagePerTime * (timeInterval / 1000)
var etaM = parseInt(etas/60,10);
console.log(parseInt(percentage,10)+'% ETA: '+etaM+' minutes @ '+bps+'bps');
lastPercentage = percentage;lastBlocksToGo = blocksToGo;
},timeInterval);
This will give you an output similar to this:
85% ETA: 573 minutes @ 134.4bps
86% ETA: 533 minutes @ 144.3bps
86% ETA: 442 minutes @ 173.9bps
Firstly you will need to connect to the running geth process from a second terminal
$ geth attach
As the other answers have stated the structure you are interested is eth.syncing
To see the remaining blocks you could do
> eth.syncing.highestBlock - eth.syncing.currentBlock
And for the remaining states
> eth.syncing.knownStates - eth.syncing.pulledStates
While running geth sync process, I used geth attach
and then used eth.syncing
on geth console.
I could get block info. And if you're just after running geth
command itself, you need to wait until geth starts "real" syncing process. Otherwise you'll see false
.
geth version
result
Geth
Version: 1.7.2-stable
Git Commit: 1db4ecdc0b9e828ff65777fb466fc7c1d04e0de9
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9.1
Operating System: darwin
GOPATH=
GOROOT=/usr/local/Cellar/go/1.9.1/libexec
You can use web3.eth.syncing, i.e.:
server:~# geth attach
> web3.eth.syncing
{
currentBlock: 4504031,
highestBlock: 4660759,
knownStates: 31357681,
pulledStates: 31357680,
startingBlock: 4504031
}
Or the same as above but async
using getSyncing:
web3.eth.getSyncing(callback(error, result){ ... })
Eth syncing percent:
eth.syncing.currentBlock * 100 / eth.syncing.highestBlock