mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-05 14:01:32 +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/blocknotify
|
||||
blocknotify/blocknotify
|
||||
blocknotify-dcr/blocknotify-dcr
|
||||
bin/stratum
|
||||
bin/blocknotify
|
||||
bin/blocknotify-dcr
|
||||
stratum/config/
|
||||
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/dcrrpcclient"
|
||||
"github.com/decred/dcrutil"
|
||||
// "github.com/decred/dcrutil"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -27,6 +27,8 @@ const (
|
|||
|
||||
walletUser = "yiimprpc"
|
||||
walletPass = "myDecredPassword"
|
||||
|
||||
debug = false
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -38,18 +40,26 @@ func main() {
|
|||
OnBlockConnected: func(hash *chainhash.Hash, height int32, time time.Time, vb uint16) {
|
||||
|
||||
// Find the process path.
|
||||
cmd := exec.Command(processName, stratumDest, coinId, hash.String())
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Fatalln(err)
|
||||
str := hash.String()
|
||||
args := []string{ stratumDest, coinId, str }
|
||||
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.
|
||||
dcrdHomeDir := dcrutil.AppDataDir("dcrd", false)
|
||||
certs, err := ioutil.ReadFile(filepath.Join(dcrdHomeDir, "rpc.cert"))
|
||||
// dcrwHomeDir := dcrutil.AppDataDir("dcrwallet", false)
|
||||
// folder := dcrwHomeDir
|
||||
folder := ""
|
||||
certs, err := ioutil.ReadFile(filepath.Join(folder, "rpc.cert"))
|
||||
if err != nil {
|
||||
certs = nil
|
||||
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)
|
||||
{
|
||||
CommonUnlock(&g_db_mutex);
|
||||
// client_block_ip(client, "account locked");
|
||||
client_block_ip(client, "account locked");
|
||||
clientlog(client, "account locked");
|
||||
|
||||
return false;
|
||||
|
@ -275,6 +275,10 @@ bool client_update_block(YAAMP_CLIENT *client, json_value *json_params)
|
|||
coind->newblock = true;
|
||||
coind->notreportingcounter = 0;
|
||||
|
||||
if (!strcmp("DCR", coind->symbol)) {
|
||||
usleep(500*YAAMP_MS);
|
||||
}
|
||||
|
||||
block_confirm(coind->id, hash);
|
||||
|
||||
coind_create_job(coind);
|
||||
|
|
|
@ -104,7 +104,7 @@ void client_block_ip(YAAMP_CLIENT *client, const char *reason)
|
|||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
if(!strcmp(coind->symbol, "DCR")) {
|
||||
coind->usegetwork = true;
|
||||
coind->noblocknotifiy = true;
|
||||
//coind->noblocknotifiy = true;
|
||||
sprintf(account, "default");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue