mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-06 18:49:45 +00:00
decred: rename blocknotifygo to blocknotify-dcr
also add a small delay before blockconfirm also, for locked accounts, use iptables reject with the specific port
This commit is contained in:
parent
3b74cc6a89
commit
284cbcdae7
7 changed files with 39 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,8 +3,10 @@
|
||||||
stratum/stratum
|
stratum/stratum
|
||||||
stratum/blocknotify
|
stratum/blocknotify
|
||||||
blocknotify/blocknotify
|
blocknotify/blocknotify
|
||||||
|
blocknotify-dcr/blocknotify-dcr
|
||||||
bin/stratum
|
bin/stratum
|
||||||
bin/blocknotify
|
bin/blocknotify
|
||||||
|
bin/blocknotify-dcr
|
||||||
stratum/config/
|
stratum/config/
|
||||||
log/
|
log/
|
||||||
*.log
|
*.log
|
||||||
|
|
13
blocknotify-dcr/Makefile
Normal file
13
blocknotify-dcr/Makefile
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
OUT_GO=blocknotify-dcr
|
||||||
|
OUTPUT=blocknotify-dcr
|
||||||
|
|
||||||
|
all:
|
||||||
|
rm -f $(OUT_GO)
|
||||||
|
go build
|
||||||
|
|
||||||
|
install: all
|
||||||
|
strip -s $(OUT_GO)
|
||||||
|
killall -9 $(OUTPUT) || echo ok
|
||||||
|
mv $(OUT_GO) ../bin/$(OUTPUT)
|
||||||
|
sh -c "../bin/$(OUTPUT) &"
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
|
|
||||||
"github.com/decred/dcrd/chaincfg/chainhash"
|
"github.com/decred/dcrd/chaincfg/chainhash"
|
||||||
"github.com/decred/dcrrpcclient"
|
"github.com/decred/dcrrpcclient"
|
||||||
"github.com/decred/dcrutil"
|
// "github.com/decred/dcrutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -27,6 +27,8 @@ const (
|
||||||
|
|
||||||
walletUser = "yiimprpc"
|
walletUser = "yiimprpc"
|
||||||
walletPass = "myDecredPassword"
|
walletPass = "myDecredPassword"
|
||||||
|
|
||||||
|
debug = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -38,18 +40,26 @@ func main() {
|
||||||
OnBlockConnected: func(hash *chainhash.Hash, height int32, time time.Time, vb uint16) {
|
OnBlockConnected: func(hash *chainhash.Hash, height int32, time time.Time, vb uint16) {
|
||||||
|
|
||||||
// Find the process path.
|
// Find the process path.
|
||||||
cmd := exec.Command(processName, stratumDest, coinId, hash.String())
|
str := hash.String()
|
||||||
if err := cmd.Run(); err != nil {
|
args := []string{ stratumDest, coinId, str }
|
||||||
log.Fatalln(err)
|
out, err := exec.Command(processName, args...).Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("err %s", err)
|
||||||
|
} else if debug {
|
||||||
|
log.Printf("out %s", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Block connected: %v (%d)", hash, height)
|
if (debug) {
|
||||||
|
log.Printf("Block connected: %s %d", hash, height)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect to local dcrd RPC server using websockets.
|
// Connect to local dcrd RPC server using websockets.
|
||||||
dcrdHomeDir := dcrutil.AppDataDir("dcrd", false)
|
// dcrwHomeDir := dcrutil.AppDataDir("dcrwallet", false)
|
||||||
certs, err := ioutil.ReadFile(filepath.Join(dcrdHomeDir, "rpc.cert"))
|
// folder := dcrwHomeDir
|
||||||
|
folder := ""
|
||||||
|
certs, err := ioutil.ReadFile(filepath.Join(folder, "rpc.cert"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
certs = nil
|
certs = nil
|
||||||
log.Printf("%s, trying without TLS...", err)
|
log.Printf("%s, trying without TLS...", err)
|
|
@ -1,3 +0,0 @@
|
||||||
all:
|
|
||||||
rm -f blocknotifygo
|
|
||||||
go build
|
|
|
@ -207,7 +207,7 @@ bool client_authorize(YAAMP_CLIENT *client, json_value *json_params)
|
||||||
if(client->userid == -1)
|
if(client->userid == -1)
|
||||||
{
|
{
|
||||||
CommonUnlock(&g_db_mutex);
|
CommonUnlock(&g_db_mutex);
|
||||||
// client_block_ip(client, "account locked");
|
client_block_ip(client, "account locked");
|
||||||
clientlog(client, "account locked");
|
clientlog(client, "account locked");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -275,6 +275,10 @@ bool client_update_block(YAAMP_CLIENT *client, json_value *json_params)
|
||||||
coind->newblock = true;
|
coind->newblock = true;
|
||||||
coind->notreportingcounter = 0;
|
coind->notreportingcounter = 0;
|
||||||
|
|
||||||
|
if (!strcmp("DCR", coind->symbol)) {
|
||||||
|
usleep(500*YAAMP_MS);
|
||||||
|
}
|
||||||
|
|
||||||
block_confirm(coind->id, hash);
|
block_confirm(coind->id, hash);
|
||||||
|
|
||||||
coind_create_job(coind);
|
coind_create_job(coind);
|
||||||
|
|
|
@ -104,7 +104,7 @@ void client_block_ip(YAAMP_CLIENT *client, const char *reason)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
|
|
||||||
sprintf(buffer, "iptables -A INPUT -s %s -j DROP", client->sock->ip);
|
sprintf(buffer, "iptables -A INPUT -s %s -p tcp --dport %d -j REJECT", client->sock->ip, g_tcp_port);
|
||||||
int s = system(buffer);
|
int s = system(buffer);
|
||||||
|
|
||||||
stratumlog("%s %s blocked (%s)\n", client->sock->ip, client->username, reason);
|
stratumlog("%s %s blocked (%s)\n", client->sock->ip, client->username, reason);
|
||||||
|
|
|
@ -152,7 +152,7 @@ void coind_init(YAAMP_COIND *coind)
|
||||||
coind->rpc.curl = g_stratum_curl;
|
coind->rpc.curl = g_stratum_curl;
|
||||||
if(!strcmp(coind->symbol, "DCR")) {
|
if(!strcmp(coind->symbol, "DCR")) {
|
||||||
coind->usegetwork = true;
|
coind->usegetwork = true;
|
||||||
coind->noblocknotifiy = true;
|
//coind->noblocknotifiy = true;
|
||||||
sprintf(account, "default");
|
sprintf(account, "default");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue