@@ -142,12 +142,12 @@ to the request inside the innermost layer of the onion. Here is a (simplified) d
142142 Returned value in Web3.py
143143
144144
145- The middlewares are maintained in ``Web3.middleware_stack ``. See
145+ The middlewares are maintained in ``Web3.middleware_onion ``. See
146146below for the API.
147147
148148When specifying middlewares in a list, or retrieving the list of middlewares, they will
149149be returned in the order of outermost layer first and innermost layer last. In the above
150- example, that means that ``list(w3.middleware_stack ) `` would return the middlewares in
150+ example, that means that ``list(w3.middleware_onion ) `` would return the middlewares in
151151the order of: ``[2, 1, 0] ``.
152152
153153See "Internals: :ref: `internals__middlewares `" for a deeper dive to how middlewares work.
@@ -157,7 +157,7 @@ Middleware Stack API
157157
158158To add or remove items in different layers, use the following API:
159159
160- .. py :method :: Web3.middleware_stack .add(middleware, name = None )
160+ .. py :method :: Web3.middleware_onion .add(middleware, name = None )
161161
162162 Middleware will be added to the outermost layer. That means the new middleware will modify the
163163 request first, and the response last. You can optionally name it with any hashable object,
@@ -166,27 +166,27 @@ To add or remove items in different layers, use the following API:
166166 .. code-block :: python
167167
168168 >> > w3 = Web3(... )
169- >> > w3.middleware_stack .add(web3.middleware.pythonic_middleware)
169+ >> > w3.middleware_onion .add(web3.middleware.pythonic_middleware)
170170 # or
171- >> > w3.middleware_stack .add(web3.middleware.pythonic_middleware, ' pythonic' )
171+ >> > w3.middleware_onion .add(web3.middleware.pythonic_middleware, ' pythonic' )
172172
173- .. py :method :: Web3.middleware_stack .inject(middleware, name = None , layer = None )
173+ .. py :method :: Web3.middleware_onion .inject(middleware, name = None , layer = None )
174174
175175 Inject a named middleware to an arbitrary layer.
176176
177177 The current implementation only supports injection at the innermost or
178178 outermost layers. Note that injecting to the outermost layer is equivalent to calling
179- :meth: `Web3.middleware_stack .add ` .
179+ :meth: `Web3.middleware_onion .add ` .
180180
181181 .. code-block :: python
182182
183183 # Either of these will put the pythonic middleware at the innermost layer
184184 >> > w3 = Web3(... )
185- >> > w3.middleware_stack .inject(web3.middleware.pythonic_middleware, layer = 0 )
185+ >> > w3.middleware_onion .inject(web3.middleware.pythonic_middleware, layer = 0 )
186186 # or
187- >> > w3.middleware_stack .inject(web3.middleware.pythonic_middleware, ' pythonic' , layer = 0 )
187+ >> > w3.middleware_onion .inject(web3.middleware.pythonic_middleware, ' pythonic' , layer = 0 )
188188
189- .. py :method :: Web3.middleware_stack .remove(middleware)
189+ .. py :method :: Web3.middleware_onion .remove(middleware)
190190
191191 Middleware will be removed from whatever layer it was in. If you added the middleware with
192192 a name, use the name to remove it. If you added the middleware as an object, use the object
@@ -195,11 +195,11 @@ To add or remove items in different layers, use the following API:
195195 .. code-block :: python
196196
197197 >> > w3 = Web3(... )
198- >> > w3.middleware_stack .remove(web3.middleware.pythonic_middleware)
198+ >> > w3.middleware_onion .remove(web3.middleware.pythonic_middleware)
199199 # or
200- >> > w3.middleware_stack .remove(' pythonic' )
200+ >> > w3.middleware_onion .remove(' pythonic' )
201201
202- .. py :method :: Web3.middleware_stack .replace(old_middleware, new_middleware)
202+ .. py :method :: Web3.middleware_onion .replace(old_middleware, new_middleware)
203203
204204 Middleware will be replaced from whatever layer it was in. If the middleware was named, it will
205205 continue to have the same name. If it was un-named, then you will now reference it with the new
@@ -210,25 +210,25 @@ To add or remove items in different layers, use the following API:
210210 >> > from web3.middleware import pythonic_middleware, attrdict_middleware
211211 >> > w3 = Web3(... )
212212
213- >> > w3.middleware_stack .replace(pythonic_middleware, attrdict_middleware)
213+ >> > w3.middleware_onion .replace(pythonic_middleware, attrdict_middleware)
214214 # this is now referenced by the new middleware object, so to remove it:
215- >> > w3.middleware_stack .remove(attrdict_middleware)
215+ >> > w3.middleware_onion .remove(attrdict_middleware)
216216
217217 # or, if it was named
218218
219- >> > w3.middleware_stack .replace(' pythonic' , attrdict_middleware)
219+ >> > w3.middleware_onion .replace(' pythonic' , attrdict_middleware)
220220 # this is still referenced by the original name, so to remove it:
221- >> > w3.middleware_stack .remove(' pythonic' )
221+ >> > w3.middleware_onion .remove(' pythonic' )
222222
223- .. py :method :: Web3.middleware_stack .clear()
223+ .. py :method :: Web3.middleware_onion .clear()
224224
225225 Empty all the middlewares, including the default ones.
226226
227227 .. code-block :: python
228228
229229 >> > w3 = Web3(... )
230- >> > w3.middleware_stack .clear()
231- >> > assert len (w3.middleware_stack ) == 0
230+ >> > w3.middleware_onion .clear()
231+ >> > assert len (w3.middleware_onion ) == 0
232232
233233
234234 Optional Middleware
@@ -244,7 +244,7 @@ Web3 ships with non-default middleware, for your custom use. In addition to the
244244 .. warning ::
245245 This will
246246 *replace * the default middlewares. To keep the default functionality,
247- either use ``middleware_stack .add() `` from above, or add the default middlewares to your list of
247+ either use ``middleware_onion .add() `` from above, or add the default middlewares to your list of
248248 new middlewares.
249249
250250Below is a list of built-in middleware, which is not enabled by default.
@@ -266,7 +266,7 @@ Stalecheck
266266 .. code-block :: python
267267
268268 two_day_stalecheck = make_stalecheck_middleware(60 * 60 * 24 * 2 )
269- web3.middleware_stack .add(two_day_stalecheck)
269+ web3.middleware_onion .add(two_day_stalecheck)
270270
271271 If the latest block in the blockchain is older than 2 days in this example, then the
272272 middleware will raise a ``StaleBlockchain `` exception on every call except
@@ -352,7 +352,7 @@ unique IPC location and loads the middleware:
352352 >> > from web3.middleware import geth_poa_middleware
353353
354354 # inject the poa compatibility middleware to the innermost layer
355- >> > w3.middleware_stack .inject(geth_poa_middleware, layer = 0 )
355+ >> > w3.middleware_onion .inject(geth_poa_middleware, layer = 0 )
356356
357357 # confirm that the connection succeeded
358358 >> > w3.version.node
@@ -383,7 +383,7 @@ retrieved using JSON-RPC endpoints that don't rely on server state.
383383 >> > from web3 import Web3, EthereumTesterProvider
384384 >> > w3 = Web3(EthereumTesterProvider)
385385 >> > from web3.middleware import local_filter_middleware
386- >> > w3.middleware_stack .add(local_filter_middleware())
386+ >> > w3.middleware_onion .add(local_filter_middleware())
387387
388388 # Normal block and log filter apis behave as before.
389389 >> > block_filter = w3.eth.filter(" latest" )
@@ -412,6 +412,6 @@ This middleware automatically captures transactions, signs them, and sends them
412412 >> > from web3.middleware import construct_sign_and_send_raw_middleware
413413 >> > from eth_account import Account
414414 >> > acct = Account.create(' KEYSMASH FJAFJKLDSKF7JKFDJ 1530' )
415- >> > w3.middleware_stack .add(construct_sign_and_send_raw_middleware(acct))
415+ >> > w3.middleware_onion .add(construct_sign_and_send_raw_middleware(acct))
416416 >> > w3.eth.defaultAccount = acct.address
417417 # Now you can send a tx from acct.address without having to build and sign each raw transaction
0 commit comments