Skip to content

Commit 713b6a1

Browse files
committed
Simplify GossipTopic -> String conversion (#3722)
## Proposed Changes With a few different changes to the gossip topics in flight (light clients, Capella, 4844, etc) I think this simplification makes sense. I noticed it while plumbing through a new Capella topic.
1 parent 0517884 commit 713b6a1

File tree

1 file changed

+2
-23
lines changed
  • beacon_node/lighthouse_network/src/types

1 file changed

+2
-23
lines changed

beacon_node/lighthouse_network/src/types/topics.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -172,29 +172,8 @@ impl From<GossipTopic> for Topic {
172172

173173
impl From<GossipTopic> for String {
174174
fn from(topic: GossipTopic) -> String {
175-
let encoding = match topic.encoding {
176-
GossipEncoding::SSZSnappy => SSZ_SNAPPY_ENCODING_POSTFIX,
177-
};
178-
179-
let kind = match topic.kind {
180-
GossipKind::BeaconBlock => BEACON_BLOCK_TOPIC.into(),
181-
GossipKind::BeaconAggregateAndProof => BEACON_AGGREGATE_AND_PROOF_TOPIC.into(),
182-
GossipKind::VoluntaryExit => VOLUNTARY_EXIT_TOPIC.into(),
183-
GossipKind::ProposerSlashing => PROPOSER_SLASHING_TOPIC.into(),
184-
GossipKind::AttesterSlashing => ATTESTER_SLASHING_TOPIC.into(),
185-
GossipKind::Attestation(index) => format!("{}{}", BEACON_ATTESTATION_PREFIX, *index,),
186-
GossipKind::SignedContributionAndProof => SIGNED_CONTRIBUTION_AND_PROOF_TOPIC.into(),
187-
GossipKind::SyncCommitteeMessage(index) => {
188-
format!("{}{}", SYNC_COMMITTEE_PREFIX_TOPIC, *index)
189-
}
190-
};
191-
format!(
192-
"/{}/{}/{}/{}",
193-
TOPIC_PREFIX,
194-
hex::encode(topic.fork_digest),
195-
kind,
196-
encoding
197-
)
175+
// Use the `Display` implementation below.
176+
topic.to_string()
198177
}
199178
}
200179

0 commit comments

Comments
 (0)