lbcdblocknotify: support multiple stratum server #100

Open
peterpan0708 wants to merge 1 commit from peterpan0708/lbcdblocknotify-support-multi-stratum-server into master

View file

@ -2,6 +2,7 @@ package main
import (
"flag"
"fmt"
"log"
"os/exec"
"path/filepath"
@ -10,13 +11,15 @@ import (
"github.com/lbryio/lbcutil"
)
type stratumFlag []string
var (
lbcdHomeDir = lbcutil.AppDataDir("lbcd", false)
defaultCert = filepath.Join(lbcdHomeDir, "rpc.cert")
stratumList stratumFlag
)
var (
coinid = flag.String("coinid", "1425", "Coin ID")
stratumServer = flag.String("stratum", "", "Stratum server")
stratumPass = flag.String("stratumpass", "", "Stratum server password")
rpcserver = flag.String("rpcserver", "localhost:9245", "LBCD RPC server")
rpcuser = flag.String("rpcuser", "rpcuser", "LBCD RPC username")
@ -29,10 +32,12 @@ var (
func main() {
flag.Var(&stratumList, "stratum", "--stratum=stratum1 --stratum=stratum2")
flag.Parse()
for _, stratum := range stratumList {
go func(stratum string) {
// Setup notification handler
b := newBridge(*stratumServer, *stratumPass, *coinid)
b := newBridge(stratum, *stratumPass, *coinid)
if len(*run) > 0 {
// Check if ccommand exists.
@ -58,8 +63,21 @@ func main() {
log.Fatalf("ERROR: %s", err)
client.Shutdown()
}()
// Wait until the client either shuts down gracefully (or the user
// terminates the process with Ctrl+C).
client.WaitForShutdown()
}(stratum)
}
quit := make(chan bool)
<-quit
}
func (f *stratumFlag) String() string {
return fmt.Sprintf("%v", []string(*f))
}
func (f *stratumFlag) Set(value string) error {
*f = append(*f, value)
return nil
}