Skip to content

Commit b3819dd

Browse files
committed
add get receipts of block
1 parent 258c7a0 commit b3819dd

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

backend/tree.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package backend
1919
import (
2020
"errors"
2121
"sort"
22-
"strconv"
2322
"time"
2423

2524
"github.com/CortexFoundation/CortexTheseus/common"
@@ -133,7 +132,7 @@ func (fs *ChainDB) writeRoot(number uint64, root []byte) error {
133132
if err != nil {
134133
return err
135134
}
136-
e := buk.Put([]byte(strconv.FormatUint(number, 16)), root)
135+
e := buk.Put([]byte(hexutil.EncodeUint64(number)), root)
137136

138137
if e == nil {
139138
log.Debug("Root update", "number", number, "root", common.BytesToHash(root))
@@ -153,7 +152,7 @@ func (fs *ChainDB) GetRoot(number uint64) (root []byte) {
153152
return errors.New("root bucket not exist")
154153
}
155154

156-
v := buk.Get([]byte(strconv.FormatUint(number, 16)))
155+
v := buk.Get([]byte(hexutil.EncodeUint64(number)))
157156
if v == nil {
158157
return errors.New("root value not exist")
159158
}

rpc.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,17 @@ func (m *Monitor) getReceipt(tx string) (receipt types.Receipt, err error) {
160160
return
161161
}
162162

163+
func (m *Monitor) getBlockReceipts(hash string) (receipt []types.Receipt, err error) {
164+
rpcReceiptMeter.Mark(1)
165+
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
166+
defer cancel()
167+
if err = m.cl.CallContext(ctx, &receipt, "ctxc_getBlockReceipts", hash); err != nil {
168+
log.Warn("R array is nil", "R", hash, "err", err)
169+
}
170+
171+
return
172+
}
173+
163174
func (m *Monitor) currentBlock() (uint64, bool, error) {
164175
var (
165176
currentNumber hexutil.Uint64

0 commit comments

Comments
 (0)