Skip to main content

TxPoolController

Struct TxPoolController 

Source
pub struct TxPoolController { /* private fields */ }
Expand description

Controller to the tx-pool service.

The Controller is internally reference-counted and can be freely cloned. A Controller can be obtained when tx-pool service construct.

Implementations§

Source§

impl TxPoolController

Source

pub fn service_started(&self) -> bool

Return whether tx-pool service is started

Source

pub fn handle(&self) -> &Handle

Return reference of tokio runtime handle

Source

pub fn get_block_template( &self, bytes_limit: Option<u64>, proposals_limit: Option<u64>, max_version: Option<Version>, ) -> Result<Result<BlockTemplate, AnyError>, AnyError>

Generate and return block_template

Source

pub fn notify_new_uncle(&self, uncle: UncleBlockView) -> Result<(), AnyError>

Notify new uncle

Source

pub fn update_tx_pool_for_reorg( &self, detached_blocks: VecDeque<BlockView>, attached_blocks: VecDeque<BlockView>, detached_proposal_id: HashSet<ProposalShortId>, snapshot: Arc<Snapshot>, ) -> Result<(), AnyError>

Make tx-pool consistent after a reorg, by re-adding or recursively erasing detached block transactions from the tx-pool, and also removing any other transactions from the tx-pool that are no longer valid given the new tip/height.

Source

pub fn submit_local_tx( &self, tx: TransactionView, ) -> Result<Result<(), Reject>, AnyError>

Submit local tx to tx-pool

Source

pub fn test_accept_tx( &self, tx: TransactionView, ) -> Result<Result<EntryCompleted, Reject>, AnyError>

test if a tx can be accepted by tx-pool Won’t be broadcasted to network won’t be insert to tx-pool

Source

pub fn remove_local_tx(&self, tx_hash: Byte32) -> Result<bool, AnyError>

Remove tx from tx-pool

Source

pub async fn submit_remote_tx( &self, tx: TransactionView, declared_cycles: Cycle, peer: PeerIndex, ) -> Result<(), AnyError>

Submit remote tx with declared cycles and origin to tx-pool

Source

pub fn notify_txs(&self, txs: Vec<TransactionView>) -> Result<(), AnyError>

Receive txs from network, try to add txs to tx-pool

Source

pub async fn notify_txs_async( &self, txs: Vec<TransactionView>, ) -> Result<(), AnyError>

Receive txs from network, try to add txs to tx-pool

Source

pub fn get_tx_pool_info(&self) -> Result<TxPoolInfo, AnyError>

Return tx-pool information

Source

pub fn get_live_cell( &self, out_point: OutPoint, with_data: bool, ) -> Result<CellStatus, AnyError>

Return tx-pool information

Source

pub async fn fresh_proposals_filter( &self, proposals: Vec<ProposalShortId>, ) -> Result<Vec<ProposalShortId>, AnyError>

Return fresh proposals

Source

pub fn get_tx_status( &self, hash: Byte32, ) -> Result<Result<(TxStatus, Option<Cycle>), AnyError>, AnyError>

Return tx_status for rpc (get_transaction verbosity = 1)

Source

pub fn get_transaction_with_status( &self, hash: Byte32, ) -> Result<Result<TransactionWithStatus, AnyError>, AnyError>

Return transaction_with_status for rpc (get_transaction verbosity = 2)

Source

pub async fn fetch_txs( &self, short_ids: HashSet<ProposalShortId>, ) -> Result<HashMap<ProposalShortId, TransactionView>, AnyError>

Mainly used for compact block reconstruction and block proposal pre-broadcasting Orphan/conflicted/etc transactions that are returned for compact block reconstruction.

Source

pub async fn fetch_txs_with_cycles( &self, short_ids: HashSet<ProposalShortId>, ) -> Result<Vec<(ProposalShortId, (TransactionView, Cycle))>, AnyError>

Return txs with cycles Mainly for relay transactions

Source

pub fn clear_pool(&self, new_snapshot: Arc<Snapshot>) -> Result<(), AnyError>

Clears the tx-pool, removing all txs, update snapshot.

Source

pub fn clear_verify_queue(&self) -> Result<(), AnyError>

Clears the tx-verify-queue.

Source

pub fn get_all_entry_info(&self) -> Result<TxPoolEntryInfo, AnyError>

Returns information about all transactions in the pool.

Source

pub fn get_all_ids(&self) -> Result<TxPoolIds, AnyError>

Returns the IDs of all transactions in the pool.

Source

pub fn get_tx_detail( &self, tx_hash: Byte32, ) -> Result<PoolTxDetailInfo, AnyError>

query the details of a transaction in the pool

Source

pub fn save_pool(&self) -> Result<(), AnyError>

Saves tx pool into disk.

Source

pub fn update_ibd_state(&self, in_ibd: bool) -> Result<(), AnyError>

Updates IBD state.

Source

pub fn estimate_fee_rate( &self, estimate_mode: EstimateMode, enable_fallback: bool, ) -> Result<Result<FeeRate, AnyError>, AnyError>

Estimates fee rate.

Source

pub fn suspend_chunk_process(&self) -> Result<(), AnyError>

Sends suspend chunk process cmd

Source

pub fn continue_chunk_process(&self) -> Result<(), AnyError>

Sends continue chunk process cmd

Source

pub fn submit_local_test_tx( &self, tx: TransactionView, ) -> Result<Result<(), Reject>, AnyError>

Submit local test tx to tx-pool, this tx will be put into verify queue directly.

Source

pub fn get_total_recent_reject_num(&self) -> Result<Option<u64>, AnyError>

get total recent reject num

Trait Implementations§

Source§

impl Clone for TxPoolController

Source§

fn clone(&self) -> TxPoolController

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Cast to trait Any
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,