-
Notifications
You must be signed in to change notification settings - Fork 411
A reference implementation of list_id_api_url | 用户名、子账户名接口 list_id_api_url 的参考实现
From https://github.com/btccom/btcpool/issues/16
how to insert user in database for testing backend?
There is no user database in the project. You may design any type of user database by yourself. And write a get-user-list
web api to expose all username-uid pairs to pool's stratum server.
Only the username-uid pairs from the web api is needed for the pool backend.
For test, you may write a small script with static user list. There is an example:
get-user-list.php
<?php
header('Content-Type: application/json');
$last_id = (int) $_GET['last_id'];
$users = [
'aaa' => 1,
'bbb' => 2,
'xxx' => 3,
'mmm' => 4,
'vvv' => 5,
'ddd' => 6,
];
$requestedUsers = [];
foreach ($users as $name=>$id) {
if ($id > $last_id) {
$requestedUsers [$name] = $id;
}
}
echo json_encode(
[
'err_no' => 0,
'err_msg' => null,
'data' => (object) $requestedUsers,
]
);
Then put it in a httpd server and edit /work/btcpool/build/run_sserver/sserver.cfg
:
list_id_api_url = "http://localhost/get-user-list.php";
Then you can mining for aaa
, bbb
or xxx
, etc. Its id 1
, 2
or 3
will be recorded to tables in bpool_local_stats_db
as column puid
.
You can use PHP-CLI
to quickly create a web server. Suppose you are using Ubuntu or Debian:
mkdir -p /var/www/html
cp get-user-list.php /var/www/html
apt install php-cli
php -S localhost:8000 -t /var/www/html
Then you can set list_id_api_url ="http://localhost:8000/get-user-list.php"
.
Note: the performance of PHP-CLI's web server is very poor, don't use it in a production environment.
zhCN: 添加当USER_DEFINED_COINBASE
开启时,对list_id_api_url
的说明。
en: Add a description of list_id_api_url
when USER_DEFINED_COINBASE
is defined.