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

Add module level docs #16

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 6 additions & 8 deletions sdk/src/entrypoint.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! Macros and functions for defining the program entrypoint and setting up
//! global handlers.

use core::{alloc::Layout, mem::size_of, ptr::null_mut, slice::from_raw_parts};

use crate::{
Expand Down Expand Up @@ -150,11 +153,7 @@ pub unsafe fn deserialize<'a, const MAX_ACCOUNTS: usize>(

let processed = if total_accounts > 0 {
// number of accounts to process (limited to MAX_ACCOUNTS)
let processed = if total_accounts > MAX_ACCOUNTS {
MAX_ACCOUNTS
} else {
total_accounts
};
let processed = core::cmp::min(total_accounts, MAX_ACCOUNTS);

for i in 0..processed {
let duplicate = *(input.add(offset) as *const u8);
Expand All @@ -171,7 +170,7 @@ pub unsafe fn deserialize<'a, const MAX_ACCOUNTS: usize>(

accounts[i].write(AccountInfo { raw: account_info });
} else {
offset += 8;
offset += core::mem::size_of::<u64>();
// duplicate account, clone the original pointer
accounts[i].write(accounts[duplicate as usize].assume_init_ref().clone());
}
Expand All @@ -191,7 +190,7 @@ pub unsafe fn deserialize<'a, const MAX_ACCOUNTS: usize>(
offset += (offset as *const u8).align_offset(BPF_ALIGN_OF_U128);
offset += core::mem::size_of::<u64>();
} else {
offset += 8;
offset += core::mem::size_of::<u64>();
}
}

Expand All @@ -202,7 +201,6 @@ pub unsafe fn deserialize<'a, const MAX_ACCOUNTS: usize>(
};

// instruction data
#[allow(clippy::cast_ptr_alignment)]
let instruction_data_len = *(input.add(offset) as *const u64) as usize;
offset += core::mem::size_of::<u64>();

Expand Down
2 changes: 2 additions & 0 deletions sdk/src/instruction.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Instruction types.

use core::marker::PhantomData;

use crate::{account_info::AccountInfo, pubkey::Pubkey};
Expand Down
1 change: 0 additions & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//!
//! [`solana-sdk`]: https://docs.rs/solana-sdk/latest/solana_sdk/
//! [`solana-program`]: https://docs.rs/solana-program/latest/solana_program/
//!

#![no_std]

Expand Down
2 changes: 2 additions & 0 deletions sdk/src/program.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Cross-program invocation helpers.

use core::mem::MaybeUninit;

use crate::{
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/pubkey.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Public key type and functions.

/// maximum length of derived `Pubkey` seed
pub const MAX_SEED_LEN: usize = 32;

Expand Down
2 changes: 2 additions & 0 deletions sdk/src/syscalls.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Syscall functions.

use crate::{
instruction::{AccountMeta, ProcessedSiblingInstruction},
pubkey::Pubkey,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/sysvars/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Provides access to system accounts.
//! Provides access to cluster system accounts.

use crate::program_error::ProgramError;

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/sysvars/rent.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This account contains the current cluster rent
//! This account contains the current cluster rent.
//!
//! This is required for the rent sysvar implementation.

Expand Down