Skip to content

Commit

Permalink
use libp2p peer id as snow engine node id
Browse files Browse the repository at this point in the history
  • Loading branch information
bysomeone committed Apr 25, 2024
1 parent a2692e8 commit 93e31f6
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/33cn/chain33/types"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/validators"

libpeer "github.com/libp2p/go-libp2p/core/peer"
)

type vdrSet struct {
Expand Down Expand Up @@ -125,12 +123,8 @@ func (s *vdrSet) toLibp2pID(id ids.NodeID) string {

func (s *vdrSet) toNodeID(id string) (ids.NodeID, error) {

pid, err := libpeer.Decode(id)
if err != nil {
return ids.EmptyNodeID, err
}

nid, err := ids.ToNodeID([]byte(pid)[:20])
shortID := id[:10] + id[len(id)-10:]
nid, err := ids.ToNodeID([]byte(shortID))
if err != nil {
return ids.EmptyNodeID, err
}
Expand Down

0 comments on commit 93e31f6

Please sign in to comment.