mirror of https://github.com/certusone/vouch.git
Tidy ups
This commit is contained in:
parent
68fb49a21b
commit
aed5402fbb
|
@ -278,19 +278,19 @@ func (s *Service) fetchAccountsForWallet(ctx context.Context, wallet e2wtypes.Wa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we can unlock the account with a known passphrase.
|
// Ensure we can unlock the account with a known passphrase.
|
||||||
if unlocker, isUnlocker := account.(e2wtypes.AccountLocker); isUnlocker {
|
|
||||||
unlocked := false
|
unlocked := false
|
||||||
|
if unlocker, isUnlocker := account.(e2wtypes.AccountLocker); isUnlocker {
|
||||||
for _, passphrase := range s.passphrases {
|
for _, passphrase := range s.passphrases {
|
||||||
if err := unlocker.Unlock(ctx, passphrase); err == nil {
|
if err := unlocker.Unlock(ctx, passphrase); err == nil {
|
||||||
unlocked = true
|
unlocked = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !unlocked {
|
if !unlocked {
|
||||||
log.Warn().Str("account", name).Msg("Failed to unlock account with any passphrase")
|
log.Warn().Str("account", name).Msg("Failed to unlock account with any passphrase")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Set up account as unknown to beacon chain.
|
// Set up account as unknown to beacon chain.
|
||||||
accounts[bytesutil.ToBytes48(pubKey)] = account
|
accounts[bytesutil.ToBytes48(pubKey)] = account
|
||||||
|
|
|
@ -76,8 +76,12 @@ func (s *Service) Subscribe(ctx context.Context,
|
||||||
epoch spec.Epoch,
|
epoch spec.Epoch,
|
||||||
accounts map[spec.ValidatorIndex]e2wtypes.Account,
|
accounts map[spec.ValidatorIndex]e2wtypes.Account,
|
||||||
) (map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
|
) (map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription, error) {
|
||||||
started := time.Now()
|
if len(accounts) == 0 {
|
||||||
|
// Nothing to do.
|
||||||
|
return map[spec.Slot]map[spec.CommitteeIndex]*beaconcommitteesubscriber.Subscription{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
started := time.Now()
|
||||||
log := log.With().Uint64("epoch", uint64(epoch)).Logger()
|
log := log.With().Uint64("epoch", uint64(epoch)).Logger()
|
||||||
log.Trace().Msg("Subscribing")
|
log.Trace().Msg("Subscribing")
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,11 @@ func (s *Service) scheduleAttestations(ctx context.Context,
|
||||||
validatorIndices []spec.ValidatorIndex,
|
validatorIndices []spec.ValidatorIndex,
|
||||||
notCurrentSlot bool,
|
notCurrentSlot bool,
|
||||||
) {
|
) {
|
||||||
|
if len(validatorIndices) == 0 {
|
||||||
|
// Nothing to do.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
started := time.Now()
|
started := time.Now()
|
||||||
log.Trace().Uint64("epoch", uint64(epoch)).Msg("Scheduling attestations")
|
log.Trace().Uint64("epoch", uint64(epoch)).Msg("Scheduling attestations")
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,11 @@ func (s *Service) scheduleProposals(ctx context.Context,
|
||||||
validatorIndices []spec.ValidatorIndex,
|
validatorIndices []spec.ValidatorIndex,
|
||||||
notCurrentSlot bool,
|
notCurrentSlot bool,
|
||||||
) {
|
) {
|
||||||
|
if len(validatorIndices) == 0 {
|
||||||
|
// Nothing to do.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
started := time.Now()
|
started := time.Now()
|
||||||
log.Trace().Uint64("epoch", uint64(epoch)).Msg("Scheduling proposals")
|
log.Trace().Uint64("epoch", uint64(epoch)).Msg("Scheduling proposals")
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,19 @@ func (s *Service) SubmitAttestations(ctx context.Context, attestations []*spec.A
|
||||||
data, err2 := json.Marshal(attestations)
|
data, err2 := json.Marshal(attestations)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
log.Error().Err(err).Msg("Failed to marshal JSON")
|
log.Error().Err(err).Msg("Failed to marshal JSON")
|
||||||
}
|
} else {
|
||||||
log.Warn().Err(err).Str("data", string(data)).Msg("Invalid signature!")
|
log.Warn().Err(err).Str("data", string(data)).Msg("Invalid signature!")
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
log.Warn().Err(err).Msg("Failed to submit attestation")
|
log.Warn().Err(err).Msg("Failed to submit attestation")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Trace().Msg("Submitted attestations")
|
data, err := json.Marshal(attestations)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("Failed to marshal JSON")
|
||||||
|
} else {
|
||||||
|
log.Trace().Str("data", string(data)).Msg("Submitted attestations")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}(ctx, sem, &wg, name, submitter)
|
}(ctx, sem, &wg, name, submitter)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue