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

Commit

Permalink
Merge branch 'master' into dependency-update
Browse files Browse the repository at this point in the history
  • Loading branch information
pdyraga committed Dec 30, 2020
2 parents e0316a1 + e6f7f20 commit 298cbb1
Show file tree
Hide file tree
Showing 6 changed files with 7,901 additions and 422 deletions.
20 changes: 15 additions & 5 deletions pkg/ecdsa/tss/protocol_announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
cecdsa "crypto/ecdsa"
"encoding/hex"
"fmt"
"strings"
"time"

"github.com/keep-network/keep-core/pkg/net"
Expand Down Expand Up @@ -40,6 +41,14 @@ func AnnounceProtocol(

receivedMemberIDs := make(map[string]MemberID) // member address -> memberID

markAnnounced := func(memberID MemberID, memberAddress string) {
receivedMemberIDs[strings.ToLower(memberAddress)] = memberID
}
hasAnnounced := func(memberAddress string) bool {
_, ok := receivedMemberIDs[strings.ToLower(memberAddress)]
return ok
}

go func() {
for {
select {
Expand All @@ -56,16 +65,17 @@ func AnnounceProtocol(
keepAddress,
err,
)
continue
}
memberAddress := hex.EncodeToString(publicKeyToAddressFn(*publicKey))
receivedMemberIDs[memberAddress] = msg.SenderID

memberAddress := "0x" + hex.EncodeToString(publicKeyToAddressFn(*publicKey))
logger.Infof(
"member [0x%v] from keep [%v] announced its presence",
"member [%s] from keep [%s] announced its presence",
memberAddress,
keepAddress,
)

markAnnounced(msg.SenderID, memberAddress)
if len(receivedMemberIDs) == len(keepMemberAddresses) {
cancel()
}
Expand Down Expand Up @@ -102,9 +112,9 @@ func AnnounceProtocol(
switch ctx.Err() {
case context.DeadlineExceeded:
for _, member := range keepMemberAddresses {
if _, ok := receivedMemberIDs[member]; !ok {
if !hasAnnounced(member) {
logger.Errorf(
"member [0x%v] has not announced its presence for keep [%v]; "+
"member [%s] has not announced its presence for keep [%s]; "+
"check if keep client for that operator is active and "+
"connected",
member,
Expand Down
16 changes: 8 additions & 8 deletions pkg/ecdsa/tss/protocol_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func readyProtocol(
if err != nil {
logger.Errorf(
"could not convert member ID to address for "+
"a member of keep [%v]: [%v]",
"a member of keep [%s]: [%v]",
group.groupID,
err,
)
Expand All @@ -67,7 +67,7 @@ func readyProtocol(
readyMembers[memberAddress] = true

logger.Infof(
"member [0x%v] from keep [%v] announced its readiness",
"member [%s] from keep [%s] announced its readiness",
memberAddress,
group.groupID,
)
Expand Down Expand Up @@ -114,15 +114,15 @@ func readyProtocol(
if err != nil {
logger.Errorf(
"could not convert member ID to address for a member of "+
"keep [%v]: [%v]",
"keep [%s]: [%v]",
group.groupID,
err,
)
continue
}
if ok := readyMembers[memberAddress]; !ok {
if !readyMembers[memberAddress] {
logger.Errorf(
"member [0x%v] has not announced its readiness for keep [%v]; "+
"member [%s] has not announced its readiness for keep [%s]; "+
"check if keep client for that operator is active and "+
"connected",
memberAddress,
Expand All @@ -149,11 +149,11 @@ func memberIDToAddress(
pubKey, err := memberID.PublicKey()
if err != nil {
return "", fmt.Errorf(
"could not get public key for member with ID [%v]: [%v]",
memberID.String(),
"could not get public key for member with ID [%s]: [%v]",
memberID,
err,
)
}

return hex.EncodeToString(publicKeyToAddressFn(*pubKey)), nil
return "0x" + hex.EncodeToString(publicKeyToAddressFn(*pubKey)), nil
}
Loading

0 comments on commit 298cbb1

Please sign in to comment.