Skip to content

Commit 41da4b2

Browse files
authored
Merge pull request #2349 from CortexFoundation/dev
fix retrieval of pending block
2 parents 6124dae + 515303f commit 41da4b2

7 files changed

Lines changed: 24 additions & 6 deletions

File tree

client/ctxc_client.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb
124124
}
125125

126126
type rpcBlock struct {
127-
Hash common.Hash `json:"hash"`
127+
Hash *common.Hash `json:"hash"`
128128
Transactions []rpcTransaction `json:"transactions"`
129129
UncleHashes []common.Hash `json:"uncles"`
130130
}
@@ -146,6 +146,11 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...any) (*ty
146146
if err := json.Unmarshal(raw, &body); err != nil {
147147
return nil, err
148148
}
149+
// Pending blocks don't return a block hash, compute it for sender caching.
150+
if body.Hash == nil {
151+
tmp := head.Hash()
152+
body.Hash = &tmp
153+
}
149154
// Quick-verify transaction and uncle lists. This mostly helps with debugging the server.
150155
if head.UncleHash == types.EmptyUncleHash && len(body.UncleHashes) > 0 {
151156
return nil, fmt.Errorf("server returned non-empty uncle list but block header indicates no uncles")
@@ -187,7 +192,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...any) (*ty
187192
txs := make([]*types.Transaction, len(body.Transactions))
188193
for i, tx := range body.Transactions {
189194
if tx.From != nil {
190-
setSenderFromServer(tx.tx, *tx.From, body.Hash)
195+
setSenderFromServer(tx.tx, *tx.From, *body.Hash)
191196
}
192197
txs[i] = tx.tx
193198
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.0 // indirect
254-
modernc.org/libc v1.64.1 // indirect
254+
modernc.org/libc v1.65.0 // indirect
255255
modernc.org/mathutil v1.7.1 // indirect
256256
modernc.org/memory v1.10.0 // indirect
257257
modernc.org/sqlite v1.37.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,8 +1823,8 @@ modernc.org/libc v1.19.0/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0=
18231823
modernc.org/libc v1.20.3/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0=
18241824
modernc.org/libc v1.21.4/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI=
18251825
modernc.org/libc v1.21.5/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI=
1826-
modernc.org/libc v1.64.1 h1:EnFXu9N9epQohXMH+h1/w3SxHVGozuPjbux5KVFf5bM=
1827-
modernc.org/libc v1.64.1/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs=
1826+
modernc.org/libc v1.65.0 h1:e183gLDnAp9VJh6gWKdTy0CThL9Pt7MfcR/0bgb7Y1Y=
1827+
modernc.org/libc v1.65.0/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs=
18281828
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
18291829
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
18301830
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=

vendor/modernc.org/libc/etc.go

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

vendor/modernc.org/libc/libc_musl.go

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

vendor/modernc.org/libc/pthread.go

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

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ gopkg.in/yaml.v3
13491349
lukechampine.com/blake3
13501350
lukechampine.com/blake3/bao
13511351
lukechampine.com/blake3/guts
1352-
# modernc.org/libc v1.64.1
1352+
# modernc.org/libc v1.65.0
13531353
## explicit; go 1.23.0
13541354
modernc.org/libc
13551355
modernc.org/libc/errno

0 commit comments

Comments
 (0)