Skip to content

Commit

Permalink
fix(leader-schedule): Fix random number generator to match rust imple…
Browse files Browse the repository at this point in the history
…mentation and filter vote accounts with zero stake (#211)

* Implement random sampler identical to rust

* Filter vote accounts with zero stake

* Add comment for uintLessThanRust

* Address PR comments
  • Loading branch information
yewman authored Jul 26, 2024
1 parent 541a5b8 commit 35d8b4e
Show file tree
Hide file tree
Showing 2 changed files with 240 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/accountsdb/snapshots.zig
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub const VoteAccounts = struct {
var staked_nodes = std.AutoArrayHashMap(Pubkey, u64).init(allocator);
var iter = vote_accounts.iterator();
while (iter.next()) |vote_entry| {
if (vote_entry.value_ptr[0] == 0) continue;
const vote_state = try vote_entry.value_ptr[1].voteState();
const node_entry = try staked_nodes.getOrPut(vote_state.node_pubkey);
if (!node_entry.found_existing) {
Expand Down
Loading

0 comments on commit 35d8b4e

Please sign in to comment.