Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #457 from keep-network/nope
Browse files Browse the repository at this point in the history
Do not attempt to generate key if it is available in the registry
  • Loading branch information
nkuba authored May 17, 2020
2 parents a6f37e2 + bdb9411 commit ba1c172
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ func checkAwaitingKeyGenerationForKeep(
return nil
}

// If the key material is stored in the registry it means that the key
// generation succeeded and public key transaction has been submitted.
// There are two scenarios possible:
// - public key submission transactions are still mining,
// - conflicting public key has been submitted.
// In both cases, the client should not attempt to generate the key again.
if keepsRegistry.HasSigner(keep) {
logger.Warningf(
"keep public key is not registered on-chain but key material "+
"is stored on disk; skipping key generation; PLEASE INSPECT "+
"PUBLIC KEY SUBMISSION TRANSACTION FOR KEEP [%v]",
keep.String(),
)
return nil
}

members, err := ethereumChain.GetMembers(keep)
if err != nil {
return err
Expand Down
10 changes: 10 additions & 0 deletions pkg/registry/keeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ func (k *Keeps) GetSigners(keepAddress common.Address) ([]*tss.ThresholdSigner,
return signers, nil
}

// HasSigner returns true if at least one signer exists in the registry
// for the keep with the given addres.
func (k *Keeps) HasSigner(keepAddress common.Address) bool {
k.myKeepsMutex.RLock()
defer k.myKeepsMutex.RUnlock()

_, has := k.myKeeps[keepAddress]
return has
}

// GetKeepsAddresses returns addresses of all registered keeps.
func (k *Keeps) GetKeepsAddresses() []common.Address {
k.myKeepsMutex.RLock()
Expand Down

0 comments on commit ba1c172

Please sign in to comment.