Skip to content

Commit

Permalink
docs: possible OOM errors on syscalls (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
XuJiandong authored Sep 12, 2024
1 parent 1a4135e commit 0f5aa2f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/high_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ fn load_data<F: Fn(&mut [u8], usize) -> Result<usize, SysError>>(
/// ```
/// let cell_output = load_cell(0, Source::Input).unwrap();
/// ```
///
/// **Note:** This function can panic if the underlying data is too large,
/// potentially causing an out-of-memory error.
pub fn load_cell(index: usize, source: Source) -> Result<CellOutput, SysError> {
let data = load_data(|buf, offset| syscalls::load_cell(buf, offset, index, source))?;

Expand Down Expand Up @@ -150,6 +153,9 @@ pub fn load_header(index: usize, source: Source) -> Result<Header, SysError> {
/// ```
/// let witness = load_witness(0, Source::Input).unwrap();
/// ```
///
/// **Note:** This function can panic if the underlying data is too large,
/// potentially causing an out-of-memory error.
pub fn load_witness(index: usize, source: Source) -> Result<Vec<u8>, SysError> {
load_data(|buf, offset| syscalls::load_witness(buf, offset, index, source))
}
Expand All @@ -168,6 +174,9 @@ pub fn load_witness(index: usize, source: Source) -> Result<Vec<u8>, SysError> {
/// ```
/// let witness_args = load_witness_args(0, Source::Input).unwrap();
/// ```
///
/// **Note:** This function can panic if the underlying data is too large,
/// potentially causing an out-of-memory error.
pub fn load_witness_args(index: usize, source: Source) -> Result<WitnessArgs, SysError> {
let data = load_data(|buf, offset| syscalls::load_witness(buf, offset, index, source))?;

Expand All @@ -186,6 +195,9 @@ pub fn load_witness_args(index: usize, source: Source) -> Result<WitnessArgs, Sy
/// ```
/// let tx = load_transaction().unwrap();
/// ```
///
/// **Note:** This function can panic if the underlying data is too large,
/// potentially causing an out-of-memory error.
pub fn load_transaction() -> Result<Transaction, SysError> {
let data = load_data(|buf, offset| syscalls::load_transaction(buf, offset))?;

Expand Down Expand Up @@ -470,6 +482,9 @@ pub fn load_input_out_point(index: usize, source: Source) -> Result<OutPoint, Sy
/// ```
/// let data = load_cell_data(index, source).unwrap();
/// ```
///
/// **Note:** This function can panic if the underlying data is too large,
/// potentially causing an out-of-memory error.
pub fn load_cell_data(index: usize, source: Source) -> Result<Vec<u8>, SysError> {
load_data(|buf, offset| syscalls::load_cell_data(buf, offset, index, source))
}
Expand Down

0 comments on commit 0f5aa2f

Please sign in to comment.