Class SelectorsStateManager
java.lang.Object
org.hyperledger.besu.plugin.services.txselection.SelectorsStateManager
Manages the state of transaction selectors (including the plugin transaction selector
PluginTransactionSelector) during the block creation process. Some selectors have a state, for
example the amount of gas used by selected pending transactions so far, and changes made to the
state must be only commited after the evaluated pending transaction has been definitely selected
for inclusion, until that point it will be always possible to rollback the changes to the state
and return the previous commited state.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA function that create a duplicate of the input object. -
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty selectors state manager, here to make javadoc linter happy. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled at the start of block selection, when the initialization is done, to prepare a new working state based on the initial state.voidcommit()Commit the current working state and prepare a new working state based on the just commited state<S, D extends SelectorsStateManager.StateDuplicator<S>>
voidcreateSelectorState(TransactionSelector selector, S initialState, D duplicator) Create, initialize and track the state for a selector.<T> TgetSelectorCommittedState(TransactionSelector selector) Get the commited state for the specified selector<T> TgetSelectorWorkingState(TransactionSelector selector) Get the working state for the specified selectorvoidrollback()Discards the current working state and prepare a new working state based on the just commited state<T> voidsetSelectorWorkingState(TransactionSelector selector, T newState) set the working state for the specified selector
-
Constructor Details
-
SelectorsStateManager
public SelectorsStateManager()Create an empty selectors state manager, here to make javadoc linter happy.
-
-
Method Details
-
createSelectorState
public <S, D extends SelectorsStateManager.StateDuplicator<S>> void createSelectorState(TransactionSelector selector, S initialState, D duplicator) Create, initialize and track the state for a selector.Call to this method must be performed before the block selection is stated with
blockSelectionStarted(), otherwise it fails.- Type Parameters:
S- the type of the selector stateD- the type of the state duplicator- Parameters:
selector- the selectorinitialState- the initial value of the stateduplicator- the state duplicator
-
blockSelectionStarted
public void blockSelectionStarted()Called at the start of block selection, when the initialization is done, to prepare a new working state based on the initial state.After this method is called, it is not possible to call anymore
createSelectorState(TransactionSelector, Object, StateDuplicator) -
getSelectorWorkingState
Get the working state for the specified selector- Type Parameters:
T- the type of the selector state- Parameters:
selector- the selector- Returns:
- the working state of the selector
-
setSelectorWorkingState
set the working state for the specified selector- Type Parameters:
T- the type of the selector state- Parameters:
selector- the selectornewState- the new state
-
getSelectorCommittedState
Get the commited state for the specified selector- Type Parameters:
T- the type of the selector state- Parameters:
selector- the selector- Returns:
- the commited state of the selector
-
commit
public void commit()Commit the current working state and prepare a new working state based on the just commited state -
rollback
public void rollback()Discards the current working state and prepare a new working state based on the just commited state
-