Ethereum Asked by Shifted Five on December 9, 2020
I have build a Ethereum Full Node in Ubuntu 18.04. geth
is running through the following command:
nohup geth --rpcaddr 127.0.0.1 -rpcport 8545 --rpc -rpcapi "wb3,admin,eth,personal,net" --ws --wsaddr 127.0.0.1 --wsport 8546 --wsorigins "*" --datadir "/data/ethereum" --syncmode fast --maxpeers 10000 --cache 8196 >> geth.log 2>&1 &
one line of geth.log content:
INFO [06-06|00:59:22.250] Imported new block headers count=1 elapsed=6.793ms number=10206927 hash="92683d…04062d"
truffle
is configured as the following:
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
}
In truffle console, when I use command web3.eth.getBlockNumber().then(console.log)
, it just returns
0
undefined
Why is it not 10206927(from geth.log) or a close number?
Thanks in advance!
In the case your node is syncing, then do:
this.web3.eth.isSyncing((error: Error, sync: any) => {
if (!error && sync) {
console.log(sync.currentBlock);
console.log(sync.highestBlock);
}
});
Answered by msp on December 9, 2020
maybe the web3.eth.getBlockNumber().then(console.log)
returns 0
because geth
has not yet starterd the block synchronization but only the headers import.
When the import of the headers will be completed and the blocks sync will start, the web3.eth.getBlockNumber().then(console.log)
probably will return a non-zero value.
Hope this helps.
Answered by Gabriele Del Monte on December 9, 2020
1 Asked on February 13, 2021 by luca590
0 Asked on February 12, 2021 by user65561
1 Asked on February 12, 2021 by exaltedoil
1 Asked on February 6, 2021 by iameli
1 Asked on February 3, 2021 by krritik
0 Asked on February 1, 2021 by koukotsu
6 Asked on January 31, 2021 by user3280964
0 Asked on January 31, 2021 by angel-guastaferro
contract deployment contract design contract development solidity wallets
0 Asked on January 29, 2021 by itzi
1 Asked on January 29, 2021 by bob5421
2 Asked on January 28, 2021 by hillfias
arrays bytes32 contract debugging contract development web3js
1 Asked on January 24, 2021 by user938363
0 Asked on January 22, 2021 by deci
1 Asked on January 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP