pub struct BlockAssembler { /* private fields */ }
Expand description

| Generate a new block, without valid | proof-of-work |

Implementations§

source§

impl BlockAssembler

source

pub fn new_with_options( chainstate: &mut ChainState, mempool: &TxMemPool, params: &ChainParams, options: &Options ) -> Self

source

pub fn new( chainstate: &mut ChainState, mempool: &TxMemPool, params: &ChainParams ) -> Self

source

pub fn reset_block(&mut self)

| Clear the block’s state and prepare | for assembling a new block |

source

pub fn create_new_block( &mut self, script_pub_key_in: &Script ) -> Box<BlockTemplate>

| Construct a new block template with | coinbase to scriptPubKeyIn |

source

pub fn only_unconfirmed(&mut self, test_set: &mut TxMemPoolSetEntries)

| Remove confirmed (inBlock) entries | from given set |

source

pub fn test_package(&self, package_size: u64, package_sig_ops_cost: i64) -> bool

| Test if a new package would “fit” in the | block |

source

pub fn test_package_transactions(&self, package: &TxMemPoolSetEntries) -> bool

| Perform checks on each transaction | in a package: locktime, premature-witness, | serialized size (if necessary) | | These checks should always succeed, | and they’re here only as an extra check | in case of suboptimal node configuration |

| Perform transaction-level checks before adding | to block: | | - transaction finality (locktime) | | - premature witness (in case segwit | transactions are added to mempool before | segwit activation)

source

pub fn add_to_block(&mut self, iter: TxMemPoolTxIter)

| Add a tx to the block |

source

pub fn update_packages_for_added( &mut self, already_added: &TxMemPoolSetEntries, map_modified_tx: &mut IndexedModifiedTransactionSet ) -> i32

| Add descendants of given transactions | to mapModifiedTx with ancestor state | updated assuming given transactions | are inBlock. Returns number of updated | descendants. |

source

pub fn skip_map_tx_entry( &mut self, it: TxMemPoolTxIter, map_modified_tx: &mut IndexedModifiedTransactionSet, failed_tx: &mut TxMemPoolSetEntries ) -> bool

| Return true if given transaction from | mapTx has already been evaluated, or | if the transaction’s cached data in | mapTx is incorrect. | | Skip entries in mapTx that are already in | a block or are present in mapModifiedTx (which | implies that the mapTx ancestor state is stale | due to ancestor inclusion in the block) | | Also skip transactions that we’ve already | failed to add. This can happen if we consider | a transaction in mapModifiedTx and it fails: we | can then potentially consider it again while | walking mapTx. It’s currently guaranteed to | fail again, but as a belt-and-suspenders check | we put it in failedTx and avoid re-evaluation, | since the re-evaluation would be using cached | size/sigops/fee values that are not actually | correct.

source

pub fn sort_for_block( &mut self, package: &TxMemPoolSetEntries, sorted_entries: &mut Vec<TxMemPoolTxIter> )

| Sort the package in an order that is valid | to appear in a block |

source

pub fn add_package_txs( &mut self, n_packages_selected: &mut i32, n_descendants_updated: &mut i32 )

| Add transactions based on feerate including | unconfirmed ancestors | | Increments nPackagesSelected / nDescendantsUpdated | with corresponding statistics from | the package selection (for logging | statistics). |

| This transaction selection algorithm orders the | mempool based on feerate of a transaction | including all unconfirmed ancestors. | | Since we don’t remove transactions from the | mempool as we select them for block inclusion, | we need an alternate method of updating the | feerate of a transaction with its | not-yet-selected ancestors as we go. | | This is accomplished by walking the in-mempool | descendants of selected transactions and | storing a temporary modified state in | mapModifiedTxs. | | Each time through the loop, we compare the best | transaction in mapModifiedTxs with the next | transaction in the mempool to decide what | transaction package to work on next.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, U> CastInto<U> for Twhere U: CastFrom<T>,

§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> StaticUpcast<T> for T

§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V