Skip to content

Commit

Permalink
add finalizer policy
Browse files Browse the repository at this point in the history
  • Loading branch information
fschoell committed Jul 14, 2024
1 parent 0d4658e commit 2d2fcc1
Show file tree
Hide file tree
Showing 5 changed files with 1,209 additions and 1,203 deletions.
36 changes: 21 additions & 15 deletions codec/antelope/spring_v1/eos_to_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,29 @@ func FinalityDataToDEOS(in *FinalityData) *pbantelope.FinalityData {
BaseDigest: in.BaseDigest,
}

if in.ProposedFinalizerPolicy != nil {
finalizerPolicy := &pbantelope.FinalizerPolicy{
Generation: in.ProposedFinalizerPolicy.Generation,
Threshold: in.ProposedFinalizerPolicy.Threshold,
Finalizers: nil,
}
if in.PendingFinalizerPolicy != nil {
res.PendingFinalizerPolicy = FinalizerPolicyToDEOS(in.PendingFinalizerPolicy)
}

finalizers := make([]*pbantelope.FinalizerAuthority, 0, len(finalizerPolicy.Finalizers))
for _, finalizer := range finalizerPolicy.Finalizers {
finalizers = append(finalizers, &pbantelope.FinalizerAuthority{
Description: finalizer.Description,
Weight: finalizer.Weight,
PublicKey: finalizer.PublicKey,
})
}
finalizerPolicy.Finalizers = finalizers
return res
}

func FinalizerPolicyToDEOS(in *FinalizerPolicy) *pbantelope.FinalizerPolicy {
res := &pbantelope.FinalizerPolicy{
Generation: in.Generation,
Threshold: in.Threshold,
Finalizers: nil,
}

finalizers := make([]*pbantelope.FinalizerAuthority, 0, len(res.Finalizers))
for _, finalizer := range res.Finalizers {
finalizers = append(finalizers, &pbantelope.FinalizerAuthority{
Description: finalizer.Description,
Weight: finalizer.Weight,
PublicKey: finalizer.PublicKey,
})
}
res.Finalizers = finalizers

return res
}
Expand Down
2 changes: 1 addition & 1 deletion codec/antelope/spring_v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type FinalityData struct {
FinalOnStrongQCBlockNum uint32 `json:"final_on_strong_qc_block_num"`
ActionMroot eos.Checksum256 `json:"action_mroot"`
BaseDigest eos.Checksum256 `json:"base_digest"`
ProposedFinalizerPolicy *FinalizerPolicy `json:"proposed_finalizer_policy,omitempty" eos:"optional"`
PendingFinalizerPolicy *FinalizerPolicy `json:"pending_finalizer_policy,omitempty" eos:"optional"`
}

type FinalizerPolicy struct {
Expand Down
2 changes: 1 addition & 1 deletion proto/sf/antelope/type/v1/type.proto
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ message FinalityData {
uint32 final_on_strong_qc_block_num = 4;
bytes action_mroot = 5;
bytes base_digest = 6;
FinalizerPolicy proposed_finalizer_policy = 7;
FinalizerPolicy pending_finalizer_policy = 7;
}

message FinalizerPolicy {
Expand Down
4 changes: 2 additions & 2 deletions types/pb/last_generate.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
generate.sh - Sun Jul 14 17:31:31 CEST 2024 - work
streamingfast/firehose-antelope/proto revision: ae61561
generate.sh - Sun Jul 14 17:41:06 CEST 2024 - work
streamingfast/firehose-antelope/proto revision: 0d4658e
Loading

0 comments on commit 2d2fcc1

Please sign in to comment.