pub struct AddressTable { /* private fields */ }Expand description
Tracks addresses for compact index-based referencing in the command stream.
Each address is assigned a sequential index in insertion order
(0..MAX_INDEXED_ADDRESSES − 1). Sentinel indices (0xFC–0xFF) resolve
to the 4 protocol roles (PM / SELF / WETH / NATIVE) without SET_ADDRESS or
TLOAD, saving ~476 gas per use. The table is built during preprocessing
and referenced during execution.
Implementations§
Source§impl AddressTable
impl AddressTable
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a new table. NATIVE_ADDRESS (address(0)) always resolves to
SENTINEL_NATIVE without an explicit Self::add — the table is
pre-seeded with sentinel_map[NATIVE_ADDRESS] = 0xFF (and the same for
ZERO_ADDRESS, the same address).
Sourcepub fn with_sentinels(
weth: Option<Address>,
executor: Option<Address>,
pool_manager: Option<Address>,
) -> Self
pub fn with_sentinels( weth: Option<Address>, executor: Option<Address>, pool_manager: Option<Address>, ) -> Self
Build a table pre-seeded with the protocol sentinels: pool_manager
→ SENTINEL_PM, executor → SENTINEL_SELF, weth →
SENTINEL_WETH. Any None sentinel is simply not registered.
Sourcepub fn add(&mut self, addr: Address) -> Result<u8, EncoderError>
pub fn add(&mut self, addr: Address) -> Result<u8, EncoderError>
Add an address, returning its index. Idempotent for duplicates.
Sentinel addresses (WETH, PM, executor, NATIVE) return their fixed sentinel index without adding to the table.
§Errors
Returns EncoderError::AddressTableFull if the table already holds
MAX_INDEXED_ADDRESSES entries and addr is neither a sentinel nor
already present.
Trait Implementations§
Source§impl Debug for AddressTable
impl Debug for AddressTable
Auto Trait Implementations§
impl Freeze for AddressTable
impl RefUnwindSafe for AddressTable
impl Send for AddressTable
impl Sync for AddressTable
impl Unpin for AddressTable
impl UnsafeUnpin for AddressTable
impl UnwindSafe for AddressTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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