Skip to content

Commit a085cbd

Browse files
authored
Merge pull request #2411 from CortexFoundation/dev
prealloc map for the txpool api
2 parents 8498990 + cc21bca commit a085cbd

13 files changed

Lines changed: 2854 additions & 33 deletions

File tree

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0
2525
github.com/dop251/goja v0.0.0-20250624190929-4d26883d182a
2626
github.com/ethereum/c-kzg-4844 v1.0.3
27-
github.com/ethereum/go-ethereum v1.15.11
27+
github.com/ethereum/go-ethereum v1.16.0
2828
github.com/ethereum/go-verkle v0.2.2
2929
github.com/ferranbt/fastssz v0.1.4
3030
github.com/fjl/gencodec v0.1.0
@@ -239,7 +239,7 @@ require (
239239
github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235 // indirect
240240
github.com/yusufpapurcu/wmi v1.2.4 // indirect
241241
github.com/zeebo/xxh3 v1.0.3-0.20230502181907-3808c706a06a // indirect
242-
go.etcd.io/bbolt v1.4.1 // indirect
242+
go.etcd.io/bbolt v1.4.2 // indirect
243243
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
244244
go.opentelemetry.io/otel v1.37.0 // indirect
245245
go.opentelemetry.io/otel/metric v1.37.0 // indirect
@@ -251,7 +251,7 @@ require (
251251
gopkg.in/yaml.v2 v2.4.0 // indirect
252252
gopkg.in/yaml.v3 v3.0.1 // indirect
253253
lukechampine.com/blake3 v1.4.1 // indirect
254-
modernc.org/libc v1.66.1 // indirect
254+
modernc.org/libc v1.66.2 // indirect
255255
modernc.org/mathutil v1.7.1 // indirect
256256
modernc.org/memory v1.11.0 // indirect
257257
modernc.org/sqlite v1.38.0 // indirect

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97
457457
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
458458
github.com/ethereum/c-kzg-4844 v1.0.3 h1:IEnbOHwjixW2cTvKRUlAAUOeleV7nNM/umJR+qy4WDs=
459459
github.com/ethereum/c-kzg-4844 v1.0.3/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
460-
github.com/ethereum/go-ethereum v1.15.11 h1:JK73WKeu0WC0O1eyX+mdQAVHUV+UR1a9VB/domDngBU=
461-
github.com/ethereum/go-ethereum v1.15.11/go.mod h1:mf8YiHIb0GR4x4TipcvBUPxJLw1mFdmxzoDi11sDRoI=
460+
github.com/ethereum/go-ethereum v1.16.0 h1:Acf8FlRmcSWEJm3lGjlnKTdNgFvF9/l28oQ8Q6HDj1o=
461+
github.com/ethereum/go-ethereum v1.16.0/go.mod h1:ngYIvmMAYdo4sGW9cGzLvSsPGhDOOzL0jK5S5iXpj0g=
462462
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
463463
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
464464
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
@@ -1293,8 +1293,8 @@ go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
12931293
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
12941294
go.etcd.io/bbolt v1.3.5-0.20200424005604-a8af23b57f67/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
12951295
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
1296-
go.etcd.io/bbolt v1.4.1 h1:5mOV+HWjIPLEAlUGMsveaUvK2+byZMFOzojoi7bh7uI=
1297-
go.etcd.io/bbolt v1.4.1/go.mod h1:c8zu2BnXWTu2XM4XcICtbGSl9cFwsXtcf9zLt2OncM8=
1296+
go.etcd.io/bbolt v1.4.2 h1:IrUHp260R8c+zYx/Tm8QZr04CX+qWS5PGfPdevhdm1I=
1297+
go.etcd.io/bbolt v1.4.2/go.mod h1:Is8rSHO/b4f3XigBC0lL0+4FwAQv3HXEEIgFMuKHceM=
12981298
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
12991299
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
13001300
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
@@ -1760,18 +1760,18 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
17601760
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
17611761
lukechampine.com/blake3 v1.4.1 h1:I3Smz7gso8w4/TunLKec6K2fn+kyKtDxr/xcQEN84Wg=
17621762
lukechampine.com/blake3 v1.4.1/go.mod h1:QFosUxmjB8mnrWFSNwKmvxHpfY72bmD2tQ0kBMM3kwo=
1763-
modernc.org/cc/v4 v4.26.1 h1:+X5NtzVBn0KgsBCBe+xkDC7twLb/jNVj9FPgiwSQO3s=
1764-
modernc.org/cc/v4 v4.26.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
1763+
modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM=
1764+
modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
17651765
modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU=
17661766
modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE=
1767-
modernc.org/fileutil v1.3.3 h1:3qaU+7f7xxTUmvU1pJTZiDLAIoJVdUSSauJNHg9yXoA=
1768-
modernc.org/fileutil v1.3.3/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
1767+
modernc.org/fileutil v1.3.8 h1:qtzNm7ED75pd1C7WgAGcK4edm4fvhtBsEiI/0NQ54YM=
1768+
modernc.org/fileutil v1.3.8/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
17691769
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
17701770
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
1771-
modernc.org/goabi0 v0.0.3 h1:y81b9r3asCh6Xtse6Nz85aYGB0cG3M3U6222yap1KWI=
1772-
modernc.org/goabi0 v0.0.3/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
1773-
modernc.org/libc v1.66.1 h1:4uQsntXbVyAgrV+j6NhKvDiUypoJL48BWQx6sy9y8ok=
1774-
modernc.org/libc v1.66.1/go.mod h1:AiZxInURfEJx516LqEaFcrC+X38rt9G7+8ojIXQKHbo=
1771+
modernc.org/goabi0 v0.1.2 h1:9mfG19tFBypPnlSKRAjI5nXGMLmVy+jLyKNVKsMzt/8=
1772+
modernc.org/goabi0 v0.1.2/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
1773+
modernc.org/libc v1.66.2 h1:JCBxlJzZOIwZY54fzjHN3Wsn8Ty5PUTPr/xioRkmecI=
1774+
modernc.org/libc v1.66.2/go.mod h1:ceIGzvXxP+JV3pgVjP9avPZo6Chlsfof2egXBH3YT5Q=
17751775
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
17761776
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
17771777
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=

internal/ctxcapi/api.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,23 @@ func NewPublicTxPoolAPI(b Backend) *PublicTxPoolAPI {
110110

111111
// Content returns the transactions contained within the transaction pool.
112112
func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction {
113+
pending, queue := s.b.TxPoolContent()
113114
content := map[string]map[string]map[string]*RPCTransaction{
114-
"pending": make(map[string]map[string]*RPCTransaction),
115-
"queued": make(map[string]map[string]*RPCTransaction),
115+
"pending": make(map[string]map[string]*RPCTransaction, len(pending)),
116+
"queued": make(map[string]map[string]*RPCTransaction, len(queue)),
116117
}
117-
pending, queue := s.b.TxPoolContent()
118118

119119
// Flatten the pending transactions
120120
for account, txs := range pending {
121-
dump := make(map[string]*RPCTransaction)
121+
dump := make(map[string]*RPCTransaction, len(txs))
122122
for _, tx := range txs {
123123
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx)
124124
}
125125
content["pending"][account.Hex()] = dump
126126
}
127127
// Flatten the queued transactions
128128
for account, txs := range queue {
129-
dump := make(map[string]*RPCTransaction)
129+
dump := make(map[string]*RPCTransaction, len(txs))
130130
for _, tx := range txs {
131131
dump[fmt.Sprintf("%d", tx.Nonce())] = newRPCPendingTransaction(tx)
132132
}
@@ -170,11 +170,11 @@ func (s *PublicTxPoolAPI) Status() map[string]hexutil.Uint {
170170
// Inspect retrieves the content of the transaction pool and flattens it into an
171171
// easily inspectable list.
172172
func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string]string {
173+
pending, queue := s.b.TxPoolContent()
173174
content := map[string]map[string]map[string]string{
174-
"pending": make(map[string]map[string]string),
175-
"queued": make(map[string]map[string]string),
175+
"pending": make(map[string]map[string]string, len(pending)),
176+
"queued": make(map[string]map[string]string, len(queue)),
176177
}
177-
pending, queue := s.b.TxPoolContent()
178178

179179
// Define a formatter to flatten a transaction into a string
180180
var format = func(tx *types.Transaction) string {
@@ -185,15 +185,15 @@ func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string]string {
185185
}
186186
// Flatten the pending transactions
187187
for account, txs := range pending {
188-
dump := make(map[string]string)
188+
dump := make(map[string]string, len(txs))
189189
for _, tx := range txs {
190190
dump[fmt.Sprintf("%d", tx.Nonce())] = format(tx)
191191
}
192192
content["pending"][account.Hex()] = dump
193193
}
194194
// Flatten the queued transactions
195195
for account, txs := range queue {
196-
dump := make(map[string]string)
196+
dump := make(map[string]string, len(txs))
197197
for _, tx := range txs {
198198
dump[fmt.Sprintf("%d", tx.Nonce())] = format(tx)
199199
}

vendor/github.com/ethereum/go-ethereum/AUTHORS

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.etcd.io/bbolt/.go-version

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.etcd.io/bbolt/bolt_aix.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.etcd.io/bbolt/bolt_android.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.etcd.io/bbolt/bolt_solaris.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.etcd.io/bbolt/tx.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)