github.com/prysmaticlabs/prysm@v1.4.4/validator/client/key_reload.go (about)

     1  package client
     2  
     3  import (
     4  	"context"
     5  
     6  	eth "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
     7  	"go.opencensus.io/trace"
     8  )
     9  
    10  // HandleKeyReload makes sure the validator keeps operating correctly after a change to the underlying keys.
    11  // It is also responsible for logging out information about the new state of keys.
    12  func (v *validator) HandleKeyReload(ctx context.Context, newKeys [][48]byte) (anyActive bool, err error) {
    13  	ctx, span := trace.StartSpan(ctx, "validator.HandleKeyReload")
    14  	defer span.End()
    15  
    16  	statusRequestKeys := make([][]byte, len(newKeys))
    17  	for i := range newKeys {
    18  		statusRequestKeys[i] = newKeys[i][:]
    19  	}
    20  	resp, err := v.validatorClient.MultipleValidatorStatus(ctx, &eth.MultipleValidatorStatusRequest{
    21  		PublicKeys: statusRequestKeys,
    22  	})
    23  	if err != nil {
    24  		return false, err
    25  	}
    26  	statuses := make([]*validatorStatus, len(resp.Statuses))
    27  	for i, s := range resp.Statuses {
    28  		statuses[i] = &validatorStatus{
    29  			publicKey: resp.PublicKeys[i],
    30  			status:    s,
    31  			index:     resp.Indices[i],
    32  		}
    33  	}
    34  	anyActive = v.checkAndLogValidatorStatus(statuses)
    35  	if anyActive {
    36  		logActiveValidatorStatus(statuses)
    37  	}
    38  
    39  	return anyActive, nil
    40  }