Skip to content

Commit e22c31d

Browse files
committed
fix: rename to committee_indices to match Rust impl
1 parent 1115cf6 commit e22c31d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/root.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const std = @import("std");
22
const testing = std.testing;
33
pub const PubkeyIndexMap = @import("./pubkey_index_map.zig").PubkeyIndexMap;
4-
pub const ComputeIndices = @import("./compute_indices.zig");
5-
pub const ComputeShuffledIndex = ComputeIndices.ComputeShuffledIndex;
4+
pub const CommitteeIndices = @import("./committee_indices.zig");
5+
pub const ComputeShuffledIndex = CommitteeIndices.ComputeShuffledIndex;
66

77
export fn add(a: i32, b: i32) i32 {
88
return a + b;

src/root_c_abi.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub const PubkeyIndexMap = @import("pubkey_index_map.zig").PubkeyIndexMap;
44
const PUBKEY_INDEX_MAP_KEY_SIZE = @import("pubkey_index_map.zig").PUBKEY_INDEX_MAP_KEY_SIZE;
55
const innerShuffleList = @import("shuffle.zig").innerShuffleList;
66
const SEED_SIZE = @import("shuffle.zig").SEED_SIZE;
7-
const compute_indices = @import("compute_indices.zig");
7+
const committee_indices = @import("committee_indices.zig");
88
const ErrorCode = @import("error.zig").ErrorCode;
99
const NOT_FOUND_INDEX = @import("error.zig").NOT_FOUND_INDEX;
1010
const ERROR_INDEX = @import("error.zig").ERROR_INDEX;
@@ -264,26 +264,26 @@ export fn doShuffleList(active_indices: [*c]u32, len: usize, seed: [*c]u8, seed_
264264
export fn computeProposerIndexElectra(seed: [*c]u8, seed_len: usize, active_indices: [*c]u32, active_indices_len: usize, effective_balance_increments: [*c]u16, effective_balance_increments_len: usize, max_effective_balance_electra: u64, effective_balance_increment: u32, rounds: u32) u32 {
265265
const allocator = gpa.allocator();
266266
// TODO: is it better to define a Result struct with code and value
267-
const proposer_index = compute_indices.computeProposerIndexElectra(allocator, seed[0..seed_len], active_indices[0..active_indices_len], effective_balance_increments[0..effective_balance_increments_len], max_effective_balance_electra, effective_balance_increment, rounds) catch return ERROR_INDEX;
267+
const proposer_index = committee_indices.computeProposerIndexElectra(allocator, seed[0..seed_len], active_indices[0..active_indices_len], effective_balance_increments[0..effective_balance_increments_len], max_effective_balance_electra, effective_balance_increment, rounds) catch return ERROR_INDEX;
268268
return proposer_index;
269269
}
270270

271-
export fn computeProposerIndex(seed: [*c]u8, seed_len: usize, active_indices: [*c]u32, active_indices_len: usize, effective_balance_increments: [*c]u16, effective_balance_increments_len: usize, rand_byte_count: compute_indices.ByteCount, max_effective_balance: u64, effective_balance_increment: u32, rounds: u32) u32 {
271+
export fn computeProposerIndex(seed: [*c]u8, seed_len: usize, active_indices: [*c]u32, active_indices_len: usize, effective_balance_increments: [*c]u16, effective_balance_increments_len: usize, rand_byte_count: committee_indices.ByteCount, max_effective_balance: u64, effective_balance_increment: u32, rounds: u32) u32 {
272272
const allocator = gpa.allocator();
273273
// TODO: is it better to define a Result struct with code and value
274-
const proposer_index = compute_indices.computeProposerIndex(allocator, seed[0..seed_len], active_indices[0..active_indices_len], effective_balance_increments[0..effective_balance_increments_len], rand_byte_count, max_effective_balance, effective_balance_increment, rounds) catch return ERROR_INDEX;
274+
const proposer_index = committee_indices.computeProposerIndex(allocator, seed[0..seed_len], active_indices[0..active_indices_len], effective_balance_increments[0..effective_balance_increments_len], rand_byte_count, max_effective_balance, effective_balance_increment, rounds) catch return ERROR_INDEX;
275275
return proposer_index;
276276
}
277277

278278
export fn computeSyncCommitteeIndicesElectra(seed: [*c]u8, seed_len: usize, active_indices: [*c]u32, active_indices_len: usize, effective_balance_increments: [*c]u16, effective_balance_increments_len: usize, max_effective_balance_electra: u64, effective_balance_increment: u32, rounds: u32, out: [*c]u32, out_len: usize) c_uint {
279279
const allocator = gpa.allocator();
280-
compute_indices.computeSyncCommitteeIndicesElectra(allocator, seed[0..seed_len], active_indices[0..active_indices_len], effective_balance_increments[0..effective_balance_increments_len], max_effective_balance_electra, effective_balance_increment, rounds, out[0..out_len]) catch return ErrorCode.Error;
280+
committee_indices.computeSyncCommitteeIndicesElectra(allocator, seed[0..seed_len], active_indices[0..active_indices_len], effective_balance_increments[0..effective_balance_increments_len], max_effective_balance_electra, effective_balance_increment, rounds, out[0..out_len]) catch return ErrorCode.Error;
281281
return ErrorCode.Success;
282282
}
283283

284-
export fn computeSyncCommitteeIndices(seed: [*c]u8, seed_len: usize, active_indices: [*c]u32, active_indices_len: usize, effective_balance_increments: [*c]u16, effective_balance_increments_len: usize, rand_byte_count: compute_indices.ByteCount, max_effective_balance: u64, effective_balance_increment: u32, rounds: u32, out: [*c]u32, out_len: usize) c_uint {
284+
export fn computeSyncCommitteeIndices(seed: [*c]u8, seed_len: usize, active_indices: [*c]u32, active_indices_len: usize, effective_balance_increments: [*c]u16, effective_balance_increments_len: usize, rand_byte_count: committee_indices.ByteCount, max_effective_balance: u64, effective_balance_increment: u32, rounds: u32, out: [*c]u32, out_len: usize) c_uint {
285285
const allocator = gpa.allocator();
286-
compute_indices.computeSyncCommitteeIndices(allocator, seed[0..seed_len], active_indices[0..active_indices_len], effective_balance_increments[0..effective_balance_increments_len], rand_byte_count, max_effective_balance, effective_balance_increment, rounds, out[0..out_len]) catch return ErrorCode.Error;
286+
committee_indices.computeSyncCommitteeIndices(allocator, seed[0..seed_len], active_indices[0..active_indices_len], effective_balance_increments[0..effective_balance_increments_len], rand_byte_count, max_effective_balance, effective_balance_increment, rounds, out[0..out_len]) catch return ErrorCode.Error;
287287
return ErrorCode.Success;
288288
}
289289

0 commit comments

Comments
 (0)