鍍金池/ 問答/C++  Linux/ 運(yùn)行btcpool的測(cè)試程序的問題

運(yùn)行btcpool的測(cè)試程序的問題

1.運(yùn)行測(cè)試程序run_simulator

編譯btcpool源碼之后,運(yùn)行其測(cè)試程序

cd /work/btcpool/build/run_simulator
./simulator -c simulator.cfg -l log_simulator

這個(gè)程序沒有hang住,直接“完”了,我拿不準(zhǔn)這個(gè)程序是否運(yùn)行出錯(cuò)了還是怎么樣。
請(qǐng)教各位大俠,是否知道btcpool的測(cè)試程序(run_simulator)如何正確運(yùn)行,謝謝!

2.查看問題

我查看log_simulator下面的日志發(fā)現(xiàn)日志最下面一行如下:

E0403 14:34:04.956310   698 StratumClient.cc:256] event error: Connection refused

判斷是sserver沒有啟動(dòng),我單獨(dú)用命令去啟動(dòng)sserver,如下:

root@zc-x0:/work/btcpool/build/run_sserver# ./sserver -c sserver.cfg -l log_sserver/
F0403 14:35:37.795059   743 Kafka.cc:192] Failed to acquire metadata: Local: Timed out
*** Check failure stack trace: ***
    @     0x7ff03507c03d  google::LogMessage::Fail()
    @     0x7ff03507dea3  google::LogMessage::SendToLog()
    @     0x7ff03507bbcb  google::LogMessage::Flush()
    @     0x7ff03507e88e  google::LogMessageFatal::~LogMessageFatal()
    @           0x462e3b  KafkaConsumer::checkAlive()
    @           0x43ce48  JobRepository::setupThreadConsume()
    @           0x43efd9  Server::setup()
    @           0x43fb84  StratumServer::init()
    @           0x434973  main
    @     0x7ff0338d0830  __libc_start_main
    @           0x436af9  _start
Aborted (core dumped)
root@zc-x0:/work/btcpool/build/run_sserver# 

查看日志:

3 Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
  4 W0403 14:35:34.784273   743 StratumServerMain.cc:122] using bitcoin testnet3
  5 I0403 14:35:34.794375   743 Kafka.cc:347] producer librdkafka version: 0.9.1
  6 I0403 14:35:34.794396   743 Kafka.cc:347] producer librdkafka version: 0.9.1
  7 I0403 14:35:34.794406   743 Kafka.cc:347] producer librdkafka version: 0.9.1
  8 I0403 14:35:34.794416   743 Kafka.cc:347] producer librdkafka version: 0.9.1
  9 I0403 14:35:34.794425   743 Kafka.cc:347] producer librdkafka version: 0.9.1
 10 I0403 14:35:34.794432   743 Kafka.cc:82] consumer librdkafka version: 0.9.1
 11 I0403 14:35:34.794566   743 Kafka.cc:160] add brokers: 127.0.0.1:9092
 12 I0403 14:35:34.794602   743 Kafka.cc:167] create topic handle: StratumJob
 13 F0403 14:35:37.795059   743 Kafka.cc:192] Failed to acquire metadata: Local: Timed out

鑒于日志判斷,可能是因?yàn)閗afka的Topic:StratumJob 里面沒有數(shù)據(jù)引起的。(后面證實(shí)這個(gè)是不對(duì)的,這一步可以跳過)故通過命令,用生產(chǎn)者發(fā)送此topic的消息,然后再次運(yùn)行sserver

root@zc-x0:/work/btcpool/build/run_sserver# ./sserver -c sserver.cfg  -l log_sserver/
F0403 16:10:05.019886  3165 StratumServerMain.cc:171] init failure
*** Check failure stack trace: ***
    @     0x7f27bad8703d  google::LogMessage::Fail()
    @     0x7f27bad88ea3  google::LogMessage::SendToLog()
    @     0x7f27bad86bcb  google::LogMessage::Flush()
    @     0x7f27bad8988e  google::LogMessageFatal::~LogMessageFatal()
    @           0x434ac5  main
    @     0x7f27b95db830  __libc_start_main
    @           0x436af9  _start
Aborted (core dumped)
root@zc-x0:/work/btcpool/build/run_sserver# vi log_sserver/

查看日志 vi log_sserver/sserver.INFO

3 Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
  4 W0403 17:24:39.469852  4886 StratumServerMain.cc:122] using bitcoin testnet3
  5 W0403 17:24:39.470086  4886 StratumServer.cc:862] Simulator is enabled, all share will be accepted
  6 I0403 17:24:39.470122  4886 Kafka.cc:347] producer librdkafka version: 0.9.1
  7 I0403 17:24:39.470132  4886 Kafka.cc:347] producer librdkafka version: 0.9.1
  8 I0403 17:24:39.470140  4886 Kafka.cc:347] producer librdkafka version: 0.9.1
  9 I0403 17:24:39.470146  4886 Kafka.cc:347] producer librdkafka version: 0.9.1
 10 I0403 17:24:39.470152  4886 Kafka.cc:347] producer librdkafka version: 0.9.1
 11 I0403 17:24:39.470158  4886 Kafka.cc:82] consumer librdkafka version: 0.9.1
 12 I0403 17:24:39.470310  4886 Kafka.cc:160] add brokers: 127.0.0.1:9092
 13 I0403 17:24:39.470350  4886 Kafka.cc:167] create topic handle: StratumJob
 14 I0403 17:24:39.577185  4891 StratumServer.cc:162] start job repository consume thread
 15 E0403 17:24:39.589262  4886 Utils.cc:221] unable to request data from: https://127.0.0.1/get_user_id_list?last_id=0, error: Couldn't connect to server
 16 E0403 17:24:39.589727  4886 StratumServer.cc:480] http get request user list fail, url: https://127.0.0.1/get_user_id_list?last_id=0
 17 E0403 17:24:39.589777  4886 StratumServer.cc:547] update user list failure
 18 E0403 17:24:39.589867  4886 StratumServer.cc:776] fail to setup server
 19 F0403 17:24:39.589912  4886 StratumServerMain.cc:171] init failure

sserver的配置文件如下:

  1 #
  2 # stratum server cfg
  3 #
  4 # @since 2016-06
  5 # @copyright btc.com
  6 #
  7 
  8 # is using testnet3
  9 testnet = true;
 10 
 11 kafka = {
 12   brokers = "127.0.0.1:9092"; # "10.0.0.1:9092,10.0.0.2:9092,..."
 13 };
 14 
 15 sserver = {
 16   ip = "0.0.0.0";
 17   port = 3333;
 18 
 19   # should be global unique, range: [1, 255]
 20   id = 1;
 21 
 22   # write last mining notify job send time to file, for monitor
 23   file_last_notify_time = "/work/btcpool/build/run_sserver/sserver_lastnotifytime.txt";
 24 
 25   # how many seconds between two share submit
 26   share_avg_seconds = 10;
 27 
 28   ########################## dev options #########################
 29 
 30   # if enable simulator, all share will be accepted. for testing
 31   enable_simulator = true;
 32 
 33   # if enable it, all share will make block and submit. for testing
 34   enable_submit_invalid_block = false;
 35 
 36   # if enable, difficulty sent to miners is always miner_difficulty. for development
 37   enable_dev_mode = false;
 38 
 39   # difficulty to send to miners. for development
 40   miner_difficulty = 0.005;
 41 
 42   ###################### end of dev options ######################
 43 };
 44 
 45 users = {
 46   #
 47   # https://example.com/get_user_id_list?last_id=0
 48   # {"err_no":0,"err_msg":null,"data":{"jack":1,"terry":2}}
 49   #
 50   # There is a demo: https://github.com/btccom/btcpool/issues/16#issuecomment-278245381
 51   #
 52   list_id_api_url = "https://127.0.0.1/get_user_id_list";
 53 };
回答
編輯回答
真難過

如 sserver 日志所示

 15 E0403 17:24:39.589262  4886 Utils.cc:221] unable to request data from: https://127.0.0.1/get_user_id_list?last_id=0, error: Couldn't connect to server
 16 E0403 17:24:39.589727  4886 StratumServer.cc:480] http get request user list fail, url: https://127.0.0.1/get_user_id_list?last_id=0
 17 E0403 17:24:39.589777  4886 StratumServer.cc:547] update user list failure
 18 E0403 17:24:39.589867  4886 StratumServer.cc:776] fail to setup server
 19 F0403 17:24:39.589912  4886 StratumServerMain.cc:171] init failure

參考 sserver.cfg 的注釋,你需要自己搭建一個(gè)網(wǎng)站服務(wù)器(xx.yy),并提供一個(gè)網(wǎng)站接口(/get_user_id_list),然后把網(wǎng)址寫入 sserver.cfg 文件的 list_id_api_url 項(xiàng),如下

users = {
    list_id_api_url = "http://xx.yy/get_user_id_list";
};

你可以在本機(jī)搭建一個(gè) apache 或者 nginx 服務(wù)器,然后按照
https://github.com/btccom/btc...
上的說明操作便可。

2017年3月29日 05:18