Skip to content

crypto: Add a way to go from pubkey to route#2574

Merged
xla merged 1 commit intodevelopfrom
dev/add_amino_route
Oct 9, 2018
Merged

crypto: Add a way to go from pubkey to route#2574
xla merged 1 commit intodevelopfrom
dev/add_amino_route

Conversation

@ValarDragon
Copy link
Contributor

This is intended for use in a future PR for #2414

  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md - n/a imo

This is intended for use in a future PR for #2414
@codecov-io
Copy link

Codecov Report

Merging #2574 into develop will decrease coverage by <.01%.
The diff coverage is 75%.

@@            Coverage Diff             @@
##           develop   #2574      +/-   ##
==========================================
- Coverage     61.3%   61.3%   -0.01%     
==========================================
  Files          202     202              
  Lines        16734   16688      -46     
==========================================
- Hits         10259   10230      -29     
+ Misses        5607    5593      -14     
+ Partials       868     865       -3
Impacted Files Coverage Δ
crypto/encoding/amino/amino.go 82.75% <75%> (-2.96%) ⬇️
crypto/random.go 55.55% <0%> (-15.28%) ⬇️
libs/db/remotedb/remotedb.go 36.84% <0%> (-4.69%) ⬇️
consensus/reactor.go 71.57% <0%> (-0.52%) ⬇️
p2p/key.go 70.21% <0%> (ø) ⬆️
tools/tm-bench/main.go 0% <0%> (ø) ⬆️
libs/events/events.go 96.8% <0%> (+0.73%) ⬆️
p2p/peer.go 62.73% <0%> (+3.72%) ⬆️

Copy link
Contributor

@xla xla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 :octocat: :shipit: 🍡

@xla xla requested a review from liamsi October 9, 2018 12:16
RegisterAmino(cdc)

// TODO: Have amino provide a way to go from concrete struct to route directly.
// Its currently a private API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not happened already: please open an issue in amino too and link all relevant issues / PRs.

Copy link
Contributor

@liamsi liamsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

)

var cdc = amino.NewCodec()
var routeTable = make(map[reflect.Type]string, 3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't u think this deserve a comment? with an example entry ed25519 -> tendermint/XXX/ed25519

func PubkeyAminoRoute(cdc *amino.Codec, key crypto.PubKey) (string, error) {
route, ok := routeTable[reflect.TypeOf(key)]
if !ok {
return "", errors.New("Pubkey type not known")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we return a bool instead of error? it will simplify the code drastically

return routeTable[reflect.TypeOf(key)]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ff

cboh4 pushed a commit to scrtlabs/tendermint that referenced this pull request Apr 7, 2025
tendermint#2574)

…ks (backport tendermint#2467) (tendermint#2515)

Manual backport of cometbft/cometbft#2467

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants