-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/rc/v1.4.0' into dataTrieTracker-…
…refactor # Conflicts: # go.mod
- Loading branch information
Showing
29 changed files
with
300 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
libp2pCrypto "github.com/libp2p/go-libp2p-core/crypto" | ||
"github.com/libp2p/go-libp2p-core/peer" | ||
) | ||
|
||
type p2pConverter struct{} | ||
|
||
// NewP2pConverter creates a new instance of p2p converter | ||
func NewP2pConverter() *p2pConverter { | ||
return &p2pConverter{} | ||
} | ||
|
||
// Len return zero | ||
func (p *p2pConverter) Len() int { | ||
return 0 | ||
} | ||
|
||
// Decode does nothing | ||
func (p *p2pConverter) Decode(humanReadable string) ([]byte, error) { | ||
return nil, fmt.Errorf("not implemented") | ||
} | ||
|
||
// Encode encodes a byte array representing public key as peer ID string | ||
func (p *p2pConverter) Encode(pkBytes []byte) string { | ||
pubKey, err := libp2pCrypto.UnmarshalSecp256k1PublicKey(pkBytes) | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
id, err := peer.IDFromPublicKey(pubKey) | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
return id.Pretty() | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (p *p2pConverter) IsInterfaceNil() bool { | ||
return p == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.