ckb_script/
cost_model.rs

1//! CKB VM cost model.
2//!
3//! The cost model assign cycles to instructions.
4
5/// How many bytes can transfer when VM costs one cycle.
6// 0.25 cycles per byte
7pub const BYTES_PER_CYCLE: u64 = 4;
8
9/// Calculates how many cycles spent to load the specified number of bytes.
10pub fn transferred_byte_cycles(bytes: u64) -> u64 {
11    // Compiler will optimize the divisin here to shifts.
12    bytes.div_ceil(BYTES_PER_CYCLE)
13}