mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 08:51:08 +03:00
Expose max_tx_weight
API (#3407)
Add API for getting max transaction weight Co-authored-by: Nym Seddon <unseddd@shh.xyz>
This commit is contained in:
parent
880f9adcd3
commit
6a12155738
1 changed files with 10 additions and 4 deletions
|
@ -17,10 +17,10 @@
|
|||
//! should be used sparingly.
|
||||
|
||||
use crate::consensus::{
|
||||
graph_weight, valid_header_version, HeaderInfo, BASE_EDGE_BITS, BLOCK_TIME_SEC,
|
||||
COINBASE_MATURITY, CUT_THROUGH_HORIZON, DAY_HEIGHT, DEFAULT_MIN_EDGE_BITS,
|
||||
DIFFICULTY_ADJUST_WINDOW, INITIAL_DIFFICULTY, MAX_BLOCK_WEIGHT, PROOFSIZE,
|
||||
SECOND_POW_EDGE_BITS, STATE_SYNC_THRESHOLD,
|
||||
graph_weight, valid_header_version, HeaderInfo, BASE_EDGE_BITS, BLOCK_KERNEL_WEIGHT,
|
||||
BLOCK_OUTPUT_WEIGHT, BLOCK_TIME_SEC, COINBASE_MATURITY, CUT_THROUGH_HORIZON, DAY_HEIGHT,
|
||||
DEFAULT_MIN_EDGE_BITS, DIFFICULTY_ADJUST_WINDOW, INITIAL_DIFFICULTY, MAX_BLOCK_WEIGHT,
|
||||
PROOFSIZE, SECOND_POW_EDGE_BITS, STATE_SYNC_THRESHOLD,
|
||||
};
|
||||
use crate::core::block::HeaderVersion;
|
||||
use crate::pow::{
|
||||
|
@ -320,6 +320,12 @@ pub fn max_block_weight() -> usize {
|
|||
}
|
||||
}
|
||||
|
||||
/// Maximum allowed transaction weight (1 weight unit ~= 32 bytes)
|
||||
pub fn max_tx_weight() -> u64 {
|
||||
let coinbase_weight = BLOCK_OUTPUT_WEIGHT + BLOCK_KERNEL_WEIGHT;
|
||||
max_block_weight().saturating_sub(coinbase_weight) as u64
|
||||
}
|
||||
|
||||
/// Horizon at which we can cut-through and do full local pruning
|
||||
pub fn cut_through_horizon() -> u32 {
|
||||
match get_chain_type() {
|
||||
|
|
Loading…
Reference in a new issue