@@ -186,23 +186,23 @@ func NewTxPoolAPI(b Backend) *TxPoolAPI {
186
186
187
187
// Content returns the transactions contained within the transaction pool.
188
188
func (api * TxPoolAPI ) Content () map [string ]map [string ]map [string ]* RPCTransaction {
189
+ pending , queue := api .b .TxPoolContent ()
189
190
content := map [string ]map [string ]map [string ]* RPCTransaction {
190
- "pending" : make (map [string ]map [string ]* RPCTransaction ),
191
- "queued" : make (map [string ]map [string ]* RPCTransaction ),
191
+ "pending" : make (map [string ]map [string ]* RPCTransaction , len ( pending ) ),
192
+ "queued" : make (map [string ]map [string ]* RPCTransaction , len ( queue ) ),
192
193
}
193
- pending , queue := api .b .TxPoolContent ()
194
194
curHeader := api .b .CurrentHeader ()
195
195
// Flatten the pending transactions
196
196
for account , txs := range pending {
197
- dump := make (map [string ]* RPCTransaction )
197
+ dump := make (map [string ]* RPCTransaction , len ( txs ) )
198
198
for _ , tx := range txs {
199
199
dump [fmt .Sprintf ("%d" , tx .Nonce ())] = NewRPCPendingTransaction (tx , curHeader , api .b .ChainConfig ())
200
200
}
201
201
content ["pending" ][account .Hex ()] = dump
202
202
}
203
203
// Flatten the queued transactions
204
204
for account , txs := range queue {
205
- dump := make (map [string ]* RPCTransaction )
205
+ dump := make (map [string ]* RPCTransaction , len ( txs ) )
206
206
for _ , tx := range txs {
207
207
dump [fmt .Sprintf ("%d" , tx .Nonce ())] = NewRPCPendingTransaction (tx , curHeader , api .b .ChainConfig ())
208
208
}
@@ -246,11 +246,11 @@ func (api *TxPoolAPI) Status() map[string]hexutil.Uint {
246
246
// Inspect retrieves the content of the transaction pool and flattens it into an
247
247
// easily inspectable list.
248
248
func (api * TxPoolAPI ) Inspect () map [string ]map [string ]map [string ]string {
249
+ pending , queue := api .b .TxPoolContent ()
249
250
content := map [string ]map [string ]map [string ]string {
250
- "pending" : make (map [string ]map [string ]string ),
251
- "queued" : make (map [string ]map [string ]string ),
251
+ "pending" : make (map [string ]map [string ]string , len ( pending ) ),
252
+ "queued" : make (map [string ]map [string ]string , len ( queue ) ),
252
253
}
253
- pending , queue := api .b .TxPoolContent ()
254
254
255
255
// Define a formatter to flatten a transaction into a string
256
256
format := func (tx * types.Transaction ) string {
@@ -261,15 +261,15 @@ func (api *TxPoolAPI) Inspect() map[string]map[string]map[string]string {
261
261
}
262
262
// Flatten the pending transactions
263
263
for account , txs := range pending {
264
- dump := make (map [string ]string )
264
+ dump := make (map [string ]string , len ( txs ) )
265
265
for _ , tx := range txs {
266
266
dump [fmt .Sprintf ("%d" , tx .Nonce ())] = format (tx )
267
267
}
268
268
content ["pending" ][account .Hex ()] = dump
269
269
}
270
270
// Flatten the queued transactions
271
271
for account , txs := range queue {
272
- dump := make (map [string ]string )
272
+ dump := make (map [string ]string , len ( txs ) )
273
273
for _ , tx := range txs {
274
274
dump [fmt .Sprintf ("%d" , tx .Nonce ())] = format (tx )
275
275
}
0 commit comments