diff --git a/README.md b/README.md index e536655..8d2acb8 100644 --- a/README.md +++ b/README.md @@ -264,8 +264,15 @@ otherwise you will get errors on start because of JSON comments.** "endpoint": "127.0.0.1:6379", "poolSize": 10, "database": 0, - "password": "" - }, + "password": "", + "sentinelEnabled": false, + "masterName": "mymaster", + "sentinelAddrs": [ + "127.0.0.1:26379", + "127.0.0.1:26389", + "127.0.0.1:26399" + ] + }, "exchange": { "enabled": true, diff --git a/api.json b/api.json index 5f6be5f..d0faa02 100644 --- a/api.json +++ b/api.json @@ -93,7 +93,14 @@ "endpoint": "127.0.0.1:6379", "poolSize": 10, "database": 0, - "password": "" + "password": "", + "sentinelEnabled": false, + "masterName": "mymaster", + "sentinelAddrs": [ + "127.0.0.1:26379", + "127.0.0.1:26389", + "127.0.0.1:26399" + ] }, "exchange": { diff --git a/docs/PAYOUTS.md b/docs/PAYOUTS.md index 6e1324f..7b0bcb6 100644 --- a/docs/PAYOUTS.md +++ b/docs/PAYOUTS.md @@ -38,7 +38,7 @@ After payout session, payment module will perform `BGSAVE` (background saving) o If your payout is not logged and not confirmed by Ethereum network you can resolve it automatically. You need to payouts in maintenance mode by setting up `RESOLVE_PAYOUT=1` or `RESOLVE_PAYOUT=True` environment variable: -`RESOLVE_PAYOUT=1 ./build/bin/open-etc-pool-friends api.json`. +`RESOLVE_PAYOUT=1 ./build/bin/open-etc-pool-friends payouts.json`. Payout module will fetch all rows from Redis with key `eth:payments:pending` and credit balance back to miners. Usually you will have only single entry there. diff --git a/payouts.json b/payouts.json new file mode 100644 index 0000000..6013eea --- /dev/null +++ b/payouts.json @@ -0,0 +1,51 @@ +{ + "threads": 4, + "coin": "etc", + "name": "main", + "pplns": 9000, + "network": "classic", + "coin-name":"etc", + + + + "payouts": { + "enabled": true, + "requirePeers": 1, + "interval": "20m", + "daemon": "http://127.0.0.1:8545", + "timeout": "10s", + "address": "0xd92fa5a9732a0aec36dc8d5a6a1305dc2d3e09e6", + "gas": "21000", + "gasPrice": "50000000000", + "maxPriorityFee": "2000000000", + "autoGas": true, + "threshold": 500000000, + "bgsave": false, + "concurrentTx": 10 + }, + + "upstreamCheckInterval": "5s", + + "upstream": [ + { + "name": "main", + "url": "http://127.0.0.1:8545", + "timeout": "10s" + } + ], + + "redis": { + "endpoint": "127.0.0.1:6379", + "poolSize": 10, + "database": 0, + "password": "", + "sentinelEnabled": false, + "masterName": "mymaster", + "sentinelAddrs": [ + "127.0.0.1:26379", + "127.0.0.1:26389", + "127.0.0.1:26399" + ] + } + +} diff --git a/storage/redis.go b/storage/redis.go index 8d761cf..9351a59 100644 --- a/storage/redis.go +++ b/storage/redis.go @@ -16,10 +16,13 @@ import ( ) type Config struct { - Endpoint string `json:"endpoint"` - Password string `json:"password"` - Database int64 `json:"database"` - PoolSize int `json:"poolSize"` + SentinelEnabled bool `json:"sentinelEnabled"` + Endpoint string `json:"endpoint"` + Password string `json:"password"` + Database int64 `json:"database"` + PoolSize int `json:"poolSize"` + MasterName string `json:"masterName"` + SentinelAddrs []string `json:"sentinelAddrs"` } type RedisClient struct { @@ -156,12 +159,25 @@ type Worker struct { } func NewRedisClient(cfg *Config, prefix string, pplns int64, CoinName string) *RedisClient { - client := redis.NewClient(&redis.Options{ - Addr: cfg.Endpoint, - Password: cfg.Password, - DB: cfg.Database, - PoolSize: cfg.PoolSize, - }) + var client *redis.Client + if cfg.SentinelEnabled && len(cfg.MasterName) != 0 && len(cfg.SentinelAddrs) != 0 { + // sentinel mode + client = redis.NewFailoverClient(&redis.FailoverOptions{ + MasterName: cfg.MasterName, + SentinelAddrs: cfg.SentinelAddrs, + Password: cfg.Password, + DB: cfg.Database, + PoolSize: cfg.PoolSize, + }) + } else { + // single instance + client = redis.NewClient(&redis.Options{ + Addr: cfg.Endpoint, + Password: cfg.Password, + DB: cfg.Database, + PoolSize: cfg.PoolSize, + }) + } return &RedisClient{client: client, prefix: prefix, pplns: pplns, CoinName: CoinName} }