Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IF: Rename set_finalizers types to match eosio.bios and leap names #259

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions libraries/eosiolib/contracts/eosio/instant_finality.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ namespace eosio {
} // extern "C"
} //internal_use_do_not_use

struct abi_finalizer_authority {
struct finalizer_authority {
std::string description;
uint64_t fweight = 0; // weight that this finalizer's vote has for meeting fthreshold
std::vector<char> public_key_g1_affine_le; // Affine little endian
uint64_t weight = 0; // weight that this finalizer's vote has for meeting threshold
std::vector<char> public_key_g1; // Affine little endian non-montgomery g1

EOSLIB_SERIALIZE(abi_finalizer_authority, (description)(fweight)(public_key_g1_affine_le));
EOSLIB_SERIALIZE(finalizer_authority, (description)(weight)(public_key_g1));
};
struct abi_finalizer_policy {
uint64_t fthreshold = 0;
std::vector<abi_finalizer_authority> finalizers;
struct finalizer_policy {
uint64_t threshold = 0;
std::vector<finalizer_authority> finalizers;

EOSLIB_SERIALIZE(abi_finalizer_policy, (fthreshold)(finalizers));
EOSLIB_SERIALIZE(finalizer_policy, (threshold)(finalizers));
};

/**
* Submits a finalizer policy change to Instant Finality
*
* @param finalizer_policy - finalizer policy to be set
*/
inline void set_finalizers( const abi_finalizer_policy& finalizer_policy ) {
inline void set_finalizers( const finalizer_policy& finalizer_policy ) {
for (const auto& finalizer : finalizer_policy.finalizers)
eosio::check(finalizer.public_key_g1_affine_le.size() == sizeof(bls_g1), "public key has a wrong size" );
eosio::check(finalizer.public_key_g1.size() == sizeof(bls_g1), "public key has a wrong size" );
auto packed = eosio::pack(finalizer_policy);
internal_use_do_not_use::set_finalizers(packed.data(), packed.size());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_contracts/instant_finality_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class [[eosio::contract]] instant_finality_tests : public eosio::contract{
using contract::contract;

[[eosio::action]]
void setfinalizer(const eosio::abi_finalizer_policy& finalizer_policy) {
void setfinalizer(const eosio::finalizer_policy& finalizer_policy) {
eosio::set_finalizers(finalizer_policy);
}
};
Loading