mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 11:24:31 +00:00
Use Ord for ForkName in pubsub
This commit is contained in:
@@ -158,18 +158,19 @@ impl<E: EthSpec> PubsubMessage<E> {
|
|||||||
GossipKind::BeaconAggregateAndProof => {
|
GossipKind::BeaconAggregateAndProof => {
|
||||||
let signed_aggregate_and_proof =
|
let signed_aggregate_and_proof =
|
||||||
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
|
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
|
||||||
Some(ForkName::Base)
|
Some(&fork_name) => {
|
||||||
| Some(ForkName::Altair)
|
if fork_name >= ForkName::Electra {
|
||||||
| Some(ForkName::Bellatrix)
|
SignedAggregateAndProof::Electra(
|
||||||
| Some(ForkName::Capella)
|
|
||||||
| Some(ForkName::Deneb) => SignedAggregateAndProof::Base(
|
|
||||||
SignedAggregateAndProofBase::from_ssz_bytes(data)
|
|
||||||
.map_err(|e| format!("{:?}", e))?,
|
|
||||||
),
|
|
||||||
Some(ForkName::Electra) => SignedAggregateAndProof::Electra(
|
|
||||||
SignedAggregateAndProofElectra::from_ssz_bytes(data)
|
SignedAggregateAndProofElectra::from_ssz_bytes(data)
|
||||||
.map_err(|e| format!("{:?}", e))?,
|
.map_err(|e| format!("{:?}", e))?,
|
||||||
),
|
)
|
||||||
|
} else {
|
||||||
|
SignedAggregateAndProof::Base(
|
||||||
|
SignedAggregateAndProofBase::from_ssz_bytes(data)
|
||||||
|
.map_err(|e| format!("{:?}", e))?,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"Unknown gossipsub fork digest: {:?}",
|
"Unknown gossipsub fork digest: {:?}",
|
||||||
@@ -184,18 +185,19 @@ impl<E: EthSpec> PubsubMessage<E> {
|
|||||||
GossipKind::Attestation(subnet_id) => {
|
GossipKind::Attestation(subnet_id) => {
|
||||||
let attestation =
|
let attestation =
|
||||||
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
|
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
|
||||||
Some(ForkName::Base)
|
Some(&fork_name) => {
|
||||||
| Some(ForkName::Altair)
|
if fork_name >= ForkName::Electra {
|
||||||
| Some(ForkName::Bellatrix)
|
Attestation::Electra(
|
||||||
| Some(ForkName::Capella)
|
|
||||||
| Some(ForkName::Deneb) => Attestation::Base(
|
|
||||||
AttestationBase::from_ssz_bytes(data)
|
|
||||||
.map_err(|e| format!("{:?}", e))?,
|
|
||||||
),
|
|
||||||
Some(ForkName::Electra) => Attestation::Electra(
|
|
||||||
AttestationElectra::from_ssz_bytes(data)
|
AttestationElectra::from_ssz_bytes(data)
|
||||||
.map_err(|e| format!("{:?}", e))?,
|
.map_err(|e| format!("{:?}", e))?,
|
||||||
),
|
)
|
||||||
|
} else {
|
||||||
|
Attestation::Base(
|
||||||
|
AttestationBase::from_ssz_bytes(data)
|
||||||
|
.map_err(|e| format!("{:?}", e))?,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"Unknown gossipsub fork digest: {:?}",
|
"Unknown gossipsub fork digest: {:?}",
|
||||||
@@ -281,18 +283,19 @@ impl<E: EthSpec> PubsubMessage<E> {
|
|||||||
GossipKind::AttesterSlashing => {
|
GossipKind::AttesterSlashing => {
|
||||||
let attester_slashing =
|
let attester_slashing =
|
||||||
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
|
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
|
||||||
Some(ForkName::Base)
|
Some(&fork_name) => {
|
||||||
| Some(ForkName::Altair)
|
if fork_name >= ForkName::Electra {
|
||||||
| Some(ForkName::Bellatrix)
|
AttesterSlashing::Electra(
|
||||||
| Some(ForkName::Capella)
|
|
||||||
| Some(ForkName::Deneb) => AttesterSlashing::Base(
|
|
||||||
AttesterSlashingBase::from_ssz_bytes(data)
|
|
||||||
.map_err(|e| format!("{:?}", e))?,
|
|
||||||
),
|
|
||||||
Some(ForkName::Electra) => AttesterSlashing::Electra(
|
|
||||||
AttesterSlashingElectra::from_ssz_bytes(data)
|
AttesterSlashingElectra::from_ssz_bytes(data)
|
||||||
.map_err(|e| format!("{:?}", e))?,
|
.map_err(|e| format!("{:?}", e))?,
|
||||||
),
|
)
|
||||||
|
} else {
|
||||||
|
AttesterSlashing::Base(
|
||||||
|
AttesterSlashingBase::from_ssz_bytes(data)
|
||||||
|
.map_err(|e| format!("{:?}", e))?,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"Unknown gossipsub fork digest: {:?}",
|
"Unknown gossipsub fork digest: {:?}",
|
||||||
|
|||||||
Reference in New Issue
Block a user