forked from TrueCloudLab/frostfs-node
[#125] ir: Set extra wallets on SIGHUP
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
0624820909
commit
6f47c75e43
7 changed files with 61 additions and 36 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -52,7 +53,10 @@ func (ap *Processor) processEmit() {
|
|||
|
||||
nmNodes := networkMap.Nodes()
|
||||
nmLen := len(nmNodes)
|
||||
extraLen := len(ap.parsedWallets)
|
||||
ap.pwLock.RLock()
|
||||
pw := ap.parsedWallets
|
||||
ap.pwLock.RUnlock()
|
||||
extraLen := len(pw)
|
||||
|
||||
ap.log.Debug(logs.AlphabetGasEmission,
|
||||
zap.Int("network_map", nmLen),
|
||||
|
@ -66,7 +70,7 @@ func (ap *Processor) processEmit() {
|
|||
|
||||
ap.transferGasToNetmapNodes(nmNodes, gasPerNode)
|
||||
|
||||
ap.transferGasToExtraNodes(extraLen, gasPerNode)
|
||||
ap.transferGasToExtraNodes(pw, gasPerNode)
|
||||
}
|
||||
|
||||
func (ap *Processor) transferGasToNetmapNodes(nmNodes []netmap.NodeInfo, gasPerNode fixedn.Fixed8) {
|
||||
|
@ -92,12 +96,12 @@ func (ap *Processor) transferGasToNetmapNodes(nmNodes []netmap.NodeInfo, gasPerN
|
|||
}
|
||||
}
|
||||
|
||||
func (ap *Processor) transferGasToExtraNodes(extraLen int, gasPerNode fixedn.Fixed8) {
|
||||
if extraLen != 0 {
|
||||
err := ap.morphClient.BatchTransferGas(ap.parsedWallets, gasPerNode)
|
||||
func (ap *Processor) transferGasToExtraNodes(pw []util.Uint160, gasPerNode fixedn.Fixed8) {
|
||||
if len(pw) > 0 {
|
||||
err := ap.morphClient.BatchTransferGas(pw, gasPerNode)
|
||||
if err != nil {
|
||||
receiversLog := make([]string, extraLen)
|
||||
for i, addr := range ap.parsedWallets {
|
||||
receiversLog := make([]string, len(pw))
|
||||
for i, addr := range pw {
|
||||
receiversLog[i] = addr.StringLE()
|
||||
}
|
||||
ap.log.Warn(logs.AlphabetCantTransferGasToWallet,
|
||||
|
|
|
@ -3,6 +3,7 @@ package alphabet
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
|
@ -45,7 +46,9 @@ type (
|
|||
|
||||
// Processor of events produced for alphabet contracts in the sidechain.
|
||||
Processor struct {
|
||||
parsedWallets []util.Uint160
|
||||
parsedWallets []util.Uint160
|
||||
// protects parsedWallets from concurrent change
|
||||
pwLock *sync.RWMutex
|
||||
log *logger.Logger
|
||||
pool *ants.Pool
|
||||
alphabetContracts Contracts
|
||||
|
@ -88,6 +91,7 @@ func New(p *Params) (*Processor, error) {
|
|||
|
||||
return &Processor{
|
||||
parsedWallets: p.ParsedWallets,
|
||||
pwLock: new(sync.RWMutex),
|
||||
log: p.Log,
|
||||
pool: pool,
|
||||
alphabetContracts: p.AlphabetContracts,
|
||||
|
@ -98,6 +102,12 @@ func New(p *Params) (*Processor, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (ap *Processor) SetParsedWallets(parsedWallets []util.Uint160) {
|
||||
ap.pwLock.Lock()
|
||||
ap.parsedWallets = parsedWallets
|
||||
ap.pwLock.Unlock()
|
||||
}
|
||||
|
||||
// ListenerNotificationParsers for the 'event.Listener' event producer.
|
||||
func (ap *Processor) ListenerNotificationParsers() []event.NotificationParserInfo {
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue