Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add module level docs
Browse files Browse the repository at this point in the history
febo committed Sep 24, 2024
1 parent 037da97 commit 0f91631
Showing 8 changed files with 16 additions and 11 deletions.
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::{
@@ -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);
@@ -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());
}
@@ -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>();
}
}

@@ -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>();

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};
1 change: 0 additions & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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]

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::{
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;

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,
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;

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.

0 comments on commit 0f91631

Please sign in to comment.