Conversation
Codecov Report❌ Patch coverage is
... and 22 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sobeston
left a comment
There was a problem hiding this comment.
Seems good, just a couple nits
ea02a7e to
a50cff4
Compare
InKryption
left a comment
There was a problem hiding this comment.
A couple minor comments. Love too see the cruft dismantled.
|
|
||
| const Two = @import("Two.zig"); | ||
| const Rooted = @import("Rooted.zig"); | ||
| const Unrooted = @import("Unrooted.zig"); |
There was a problem hiding this comment.
While I'm personally not hard-set on this, the generally established convention for sig is to import these kinds of things through qualified references, ie
| const Unrooted = @import("Unrooted.zig"); | |
| const sig = @import("../../sig.zig"); | |
| const Two = sig.accounts_db.Two; | |
| const Rooted = Two.Rooted; | |
| const Unrooted = Two.Unrooted; |
Given the brevity of Two.Rooted, could consider just removing those aliases as well - I leave that up to you
| const random = prng.random(); | ||
|
|
||
| // Generate random pubkeys | ||
| var pubkeys = try allocator.alloc(Pubkey, n_accounts); |
There was a problem hiding this comment.
Prefer const by default. No reason for this slice to be in a mutable variable.
| } | ||
|
|
||
| // Generate random accounts | ||
| var accounts = try allocator.alloc(AccountSharedData, n_accounts); |
| const allocator = std.testing.allocator; | ||
| _ = allocator; |
| const encoded_data: sig.rpc.methods.GetAccountInfo.Response.Value.Data = | ||
| switch (encoding) { | ||
| .base64 => blk: { | ||
| const encoded_len = std.base64.standard.Encoder.calcSize(raw_data.len); | ||
| const encoded_buf = try alloc.alloc(u8, encoded_len); | ||
| _ = std.base64.standard.Encoder.encode(encoded_buf, raw_data); | ||
| break :blk .{ .encoded = .{ encoded_buf, .base64 } }; | ||
| }, | ||
| .base58 => return error.UnsupportedEncoding, | ||
| .@"base64+zstd" => return error.UnsupportedEncoding, | ||
| .jsonParsed => return error.UnsupportedEncoding, | ||
| }; |
There was a problem hiding this comment.
Fwiw, in cases like these, I find a local alias can help:
| const encoded_data: sig.rpc.methods.GetAccountInfo.Response.Value.Data = | |
| switch (encoding) { | |
| .base64 => blk: { | |
| const encoded_len = std.base64.standard.Encoder.calcSize(raw_data.len); | |
| const encoded_buf = try alloc.alloc(u8, encoded_len); | |
| _ = std.base64.standard.Encoder.encode(encoded_buf, raw_data); | |
| break :blk .{ .encoded = .{ encoded_buf, .base64 } }; | |
| }, | |
| .base58 => return error.UnsupportedEncoding, | |
| .@"base64+zstd" => return error.UnsupportedEncoding, | |
| .jsonParsed => return error.UnsupportedEncoding, | |
| }; | |
| const GetAccountInfoResp = sig.rpc.methods.GetAccountInfo.Response; | |
| const base64_encoder = std.base64.standard.Encoder; | |
| const encoded_data: GetAccountInfoResp.Value.Data = switch (encoding) { | |
| .base64 => blk: { | |
| const encoded_len = base64_encoder.calcSize(raw_data.len); | |
| const encoded_buf = try alloc.alloc(u8, encoded_len); | |
| _ = base64_encoder.encode(encoded_buf, raw_data); | |
| break :blk .{ .encoded = .{ encoded_buf, .base64 } }; | |
| }, | |
| .base58 => return error.UnsupportedEncoding, | |
| .@"base64+zstd" => return error.UnsupportedEncoding, | |
| .jsonParsed => return error.UnsupportedEncoding, | |
| }; |
Note: base64_encoder.calcSize is not guaranteed to yield the exact size, only an upper bound. The exact-sized buffer is what is returned by encode, so maybe realloc the original encoded_buf so that's resized down to the concrete length before returning it.
Remove AccountsDB v1, use only AccountsDB v2 (Two.zig)
Summary
Deleted Files (v1 code)
Key Changes
Not Yet Implemented in v2
The following v1 features are not yet available in v2: