Bitcoind

測試網中的 bitcoind 未同步

  • March 16, 2014

我將 bitcoind 安裝到 Linux 中。我在 testnet 模式下執行它,但它沒有同步,因為它沒有下載塊。

我在 bitcoin.conf 中有以下內容:

rpcport=8332  # Needed for testnet as default port for testnet is 18332

以下是它顯示的內容bitcoind getinfo

{
   "version" : 80600,
   "protocolversion" : 70001,
   "walletversion" : 60000,
   "balance" : 0.00000000,
   "blocks" : 0,
   "timeoffset" : 0,
   "connections" : 0,
   "proxy" : "",
   "difficulty" : 1.00000000,
   "testnet" : true,
   "keypoololdest" : 1392428204,
   "keypoolsize" : 101,
   "paytxfee" : 0.00000000,
   "errors" : ""
}

我有以下ufw status verbose防火牆:

Status: active

To                         Action      From
--                         ------      ----
8333/tcp                   ALLOW       Anywhere
8332/tcp                   ALLOW       Anywhere
18333/tcp                  ALLOW       Anywhere
8333                       ALLOW       Anywhere
8332                       ALLOW       Anywhere
18333                      ALLOW       Anywhere
8333/tcp                   ALLOW       Anywhere (v6)
8332/tcp                   ALLOW       Anywhere (v6)
18333/tcp                  ALLOW       Anywhere (v6)
8333                       ALLOW       Anywhere (v6)
8332                       ALLOW       Anywhere (v6)
18333                      ALLOW       Anywhere (v6)

8332/tcp                   ALLOW OUT   Anywhere
18333/tcp                  ALLOW OUT   Anywhere
8333                       ALLOW OUT   Anywhere
8332                       ALLOW OUT   Anywhere
18333                      ALLOW OUT   Anywhere
8333/tcp                   ALLOW OUT   Anywhere
8332/tcp                   ALLOW OUT   Anywhere (v6)
18333/tcp                  ALLOW OUT   Anywhere (v6)
8333                       ALLOW OUT   Anywhere (v6)
8332                       ALLOW OUT   Anywhere (v6)
18333                      ALLOW OUT   Anywhere (v6)
8333/tcp                   ALLOW OUT   Anywhere (v6)

以下是 debug.log 的內容:

2014-03-13 01:04:57 Bitcoin version v0.8.6.0-g03a7d67-beta ()
2014-03-13 01:04:57 Using OpenSSL version OpenSSL 1.0.1 14 Mar 2012
2014-03-13 01:04:57 Default data directory /home/jlp/.bitcoin
2014-03-13 01:04:57 Using data directory /home/jlp/.bitcoin/testnet3
2014-03-13 01:04:57 Using at most 125 connections (1024 file descriptors available)
2014-03-13 01:04:57 Using 4 threads for script verification
2014-03-13 01:04:57 init message: Verifying wallet...
2014-03-13 01:04:57 dbenv.open LogDir=/home/jlp/.bitcoin/testnet3/database ErrorFile=/h$
2014-03-13 01:04:57 Bound to [::]:18333
2014-03-13 01:04:57 Bound to 0.0.0.0:18333
2014-03-13 01:04:57 init message: Loading block index...
2014-03-13 01:04:57 Opening LevelDB in /home/jlp/.bitcoin/testnet3/blocks/index
2014-03-13 01:04:57 Opened LevelDB successfully
2014-03-13 01:04:57 Opening LevelDB in /home/jlp/.bitcoin/testnet3/chainstate
2014-03-13 01:04:58 Opened LevelDB successfully
2014-03-13 01:04:58 LoadBlockIndexDB(): last block file = 0
2014-03-13 01:04:58 LoadBlockIndexDB(): last block file info: CBlockFileInfo(blocks=1, s$
2014-03-13 01:04:58 LoadBlockIndexDB(): transaction index disabled
2014-03-13 01:04:58 LoadBlockIndexDB(): hashBestChain=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2014-03-13 01:04:58 init message: Verifying blocks...
2014-03-13 01:04:58  block index              43ms
2014-03-13 01:04:58 init message: Loading wallet...
2014-03-13 01:04:58 nFileVersion = 80600
2014-03-13 01:04:58  wallet                  441ms
2014-03-13 01:04:58 init message: Loading addresses...
2014-03-13 01:04:58 Loaded 0 addresses from peers.dat  1ms
2014-03-13 01:04:58 mapBlockIndex.size() = 1
2014-03-13 01:04:58 nBestHeight = 0
2014-03-13 01:04:58 setKeyPool.size() = 101
2014-03-13 01:04:58 mapWallet.size() = 0
2014-03-13 01:04:58 mapAddressBook.size() = 1
2014-03-13 01:04:58 AddLocal(XXX.XXX.XXX.XXX:18333,1)
2014-03-13 01:04:58 IPv4 eth0: XXX.XXX.XXX.XXX
2014-03-13 01:04:58 dnsseed thread start
2014-03-13 01:04:58 Loading addresses from DNS seeds (could take a while)
2014-03-13 01:04:58 net thread start
2014-03-13 01:04:58 addcon thread start
2014-03-13 01:04:58 opencon thread start
2014-03-13 01:04:58 msghand thread start
2014-03-13 01:04:58 dumpaddr thread start
2014-03-13 01:04:58 0 addresses found from DNS seeds
2014-03-13 01:04:58 dnsseed thread exit
2014-03-13 01:04:58 init message: Done loading
2014-03-13 01:04:59 GetMyExternalIP() received [XXX.XXX.XXX.XXX] XXX.XXX.XXX.XXX:0
2014-03-13 01:04:59 GetMyExternalIP() returned XXX.XXX.XXX.XXX
2014-03-13 01:04:59 AddLocal(XXX.XXX.XXX.XXX:18333,4)
2014-03-13 01:06:52 ThreadRPCServer method=getinfo
2014-03-13 01:06:52 keypool reserve 2
2014-03-13 01:06:52 keypool return 2
2014-03-13 01:09:09 ThreadRPCServer method=getinfo
2014-03-13 01:09:09 keypool reserve 2
2014-03-13 01:09:09 keypool return 2
2014-03-13 01:19:58 Flushed 0 addresses to peers.dat  4ms
2014-03-13 01:34:58 Flushed 0 addresses to peers.dat  18ms
2014-03-13 01:49:58 Flushed 0 addresses to peers.dat  1ms
2014-03-13 02:04:58 Flushed 0 addresses to peers.dat  22ms
2014-03-13 02:19:58 Flushed 0 addresses to peers.dat  3ms
2014-03-13 02:34:58 Flushed 0 addresses to peers.dat  44ms
2014-03-13 02:49:58 Flushed 0 addresses to peers.dat  22ms
2014-03-13 03:04:58 Flushed 0 addresses to peers.dat  34ms
2014-03-13 03:19:58 Flushed 0 addresses to peers.dat  16ms
2014-03-13 03:34:58 Flushed 0 addresses to peers.dat  32ms
...
...
...
2014-03-13 13:04:59 Flushed 0 addresses to peers.dat  20ms
2014-03-13 13:19:59 Flushed 0 addresses to peers.dat  3ms
2014-03-13 13:30:47 ThreadRPCServer method=getinfo
2014-03-13 13:30:47 keypool reserve 2
2014-03-13 13:30:47 keypool return 2
2014-03-13 13:34:59 Flushed 0 addresses to peers.dat  21ms

任何人都可以提出任何解決方案來讓比特幣同步和下載塊嗎?

2014-03-13 更新:

我嘗試刪除 bitcoin.conf 並執行它:

bitcoind -testnet -debugnet -printtoconsole

我得到了以下資訊:

Bitcoin version v0.8.6.0-g03a7d67-beta ()
Using OpenSSL version OpenSSL 1.0.1 14 Mar 2012
Default data directory /home/jlp/.bitcoin
Using data directory /home/jlp/.bitcoin/testnet3
Using at most 125 connections (1024 file descriptors available)
Using 4 threads for script verification
init message: Verifying wallet...
dbenv.open LogDir=/home/jlp/.bitcoin/testnet3/database ErrorFile=/home/jlp/.bitcoin/testnet3/db.log
Bound to [::]:18333
Bound to 0.0.0.0:18333
init message: Loading block index...
Opening LevelDB in /home/jlp/.bitcoin/testnet3/blocks/index
Opened LevelDB successfully
Opening LevelDB in /home/jlp/.bitcoin/testnet3/chainstate
Opened LevelDB successfully
LoadBlockIndexDB(): last block file = 0
LoadBlockIndexDB(): last block file info: CBlockFileInfo(blocks=1, size=293, heights=0...0, time=2011-02-02...2011-02-02)
LoadBlockIndexDB(): transaction index disabled
LoadBlockIndexDB(): hashBestChain=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  height=0 date=2011-02-02 23:16:42
init message: Verifying blocks...
block index              32ms
init message: Loading wallet...
nFileVersion = 80600
wallet                  454ms
init message: Loading addresses...
Loaded 0 addresses from peers.dat  0ms
mapBlockIndex.size() = 1
nBestHeight = 0
setKeyPool.size() = 101
mapWallet.size() = 0
mapAddressBook.size() = 1
AddLocal(XXX.XXX.XXX.XXX:18333,1)
IPv4 eth0: XXX.XXX.XXX.XXX
dnsseed thread start
Loading addresses from DNS seeds (could take a while)
net thread start
addcon thread start
opencon thread start
msghand thread start


dumpaddr thread start
Error: To use bitcoind, you must set a rpcpassword in the configuration file:
/home/jlp/.bitcoin/bitcoin.conf
It is recommended you use the following random password:
rpcuser=bitcoinrpc
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
(you do not need to remember this password)
The username and password MUST NOT be the same.
If the file does not exist, create it with owner-readable-only file permissions.
It is also recommended to set alertnotify so you are notified of problems;
for example: alertnotify=echo %s | mail -s "Bitcoin Alert" admin@foo.com

Error: To use bitcoind, you must set a rpcpassword in the configuration file:
/home/jlp/.bitcoin/bitcoin.conf
It is recommended you use the following random password:
rpcuser=bitcoinrpc
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
(you do not need to remember this password)
The username and password MUST NOT be the same.
If the file does not exist, create it with owner-readable-only file permissions.
It is also recommended to set alertnotify so you are notified of problems;
for example: alertnotify=echo %s | mail -s "Bitcoin Alert" admin@foo.com

init message: Done loading
dumpaddr thread stop
Shutdown : In progress...
msghand thread interrupt
Flush(false)
wallet.dat refcount=0
opencon thread interrupt
wallet.dat checkpoint
addcon thread interrupt
wallet.dat detach
wallet.dat closed
DBFlush(false) ended               1ms
StopNode()
net thread interrupt
0 addresses found from DNS seeds
dnsseed thread exit
Flushed 0 addresses to peers.dat  9ms
Committing 0 changed transactions to coin database...
Flush(true)
wallet.dat refcount=0
wallet.dat checkpoint
wallet.dat detach
wallet.dat closed
DBFlush(true) ended               1ms
Shutdown : done

根據上述回復中的建議,我將以下內容放入 bitcoin.conf:

rpcuser=bitcoinrpc
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

並重新執行:

bitcoind -testnet -debugnet -printtoconsole

並得到以下資訊:

Bitcoin version v0.8.6.0-g03a7d67-beta ()
Using OpenSSL version OpenSSL 1.0.1 14 Mar 2012
Default data directory /home/jlp/.bitcoin
Using data directory /home/jlp/.bitcoin/testnet3
Using at most 125 connections (1024 file descriptors available)
Using 4 threads for script verification
init message: Verifying wallet...
dbenv.open LogDir=/home/jlp/.bitcoin/testnet3/database ErrorFile=/home/jlp/.bitcoin/testnet3/db.log
Bound to [::]:18333
Bound to 0.0.0.0:18333
init message: Loading block index...
Opening LevelDB in /home/jlp/.bitcoin/testnet3/blocks/index
Opened LevelDB successfully
Opening LevelDB in /home/jlp/.bitcoin/testnet3/chainstate
Opened LevelDB successfully
LoadBlockIndexDB(): last block file = 0
LoadBlockIndexDB(): last block file info: CBlockFileInfo(blocks=1, size=293, heights=0...0, time=2011-02-02...2011-02-02)
LoadBlockIndexDB(): transaction index disabled
LoadBlockIndexDB(): hashBestChain=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  height=0 date=2011-02-02 23:16:42
init message: Verifying blocks...
block index              50ms
init message: Loading wallet...
nFileVersion = 80600
wallet                  436ms
init message: Loading addresses...
Loaded 0 addresses from peers.dat  1ms
mapBlockIndex.size() = 1
nBestHeight = 0
setKeyPool.size() = 101
mapWallet.size() = 0
mapAddressBook.size() = 1
AddLocal(XXX.XXX.XXX.XXX:18333,1)
IPv4 eth0: XXX.XXX.XXX.XXX
dnsseed thread start
net thread start
Loading addresses from DNS seeds (could take a while)
addcon thread start
opencon thread start
msghand thread start
dumpaddr thread start
init message: Done loading
0 addresses found from DNS seeds
dnsseed thread exit
connection timeout
ERROR: GetMyExternalIP() : connection to YYY.YYY.YYY.YYY:80 failed
connection timeout
ERROR: GetMyExternalIP() : connection to ZZZ.ZZZ.ZZZ.ZZZ:80 failed
GetMyExternalIP() received [XXX.XXX.XXX.XXX] XXX.XXX.XXX.XXX:0
GetMyExternalIP() returned XXX.XXX.XXX.XXX
AddLocal(XXX.XXX.XXX.XXX:18333,4)

過了很久,我得到了以下額外的回复:

Flushed 0 addresses to peers.dat  201ms
Flushed 0 addresses to peers.dat  4ms

誰能從上面看出問題是什麼以及如何解決?

我再次嘗試在 testnet 模式下執行 bitcoind,這次它正在下載塊。我不確定為什麼。也許這與我將 IP 地址放回 /etc/resolv.conf 中有關,我之前已將其註釋掉。

您找不到節點的原因是通過傳統引導方法可能沒有很多可用的節點(許多客戶端安裝時關閉了 UPnP,或者在防火牆後面並且無法接受傳入連接,並且具有入站連接的現有節點有時可能會分散)。如果你有足夠的耐心,你最終會得到一個連接。

如果您不想耐心等待,可以使用一種解決方法。您需要找到連接到測試網上節點的 bitcoind 的主機名(IP 地址或 URL)。一旦你找到了,關閉 bitcoind,然後編輯你的比特幣配置文件 (nano .bitcoin/bitcoin.conf) :

addnode=<hostname>

當您啟動 bitcoind 時,它將查看 conf 文件並嘗試以這種方式定義的每個節點。

您也可以簡單地關閉 bitcoind 並使用以下命令開始:

bitcoind -dameon -addnode=<hostname>

成功連接的對等節點保存在 peers.dat 文件中,因此如果您嘗試連接的節點處於聯機狀態,這兩種方法同樣適用。有關 peers.dat 的更多資訊以及如何查看它可以在這裡找到(如果您想幫助朋友找到與 testnet 的連接):如何閱讀 peers.dat 文件以獲取所有看到的對等點的列表或bitcoind已經連接到?

引用自:https://bitcoin.stackexchange.com/questions/23462