mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-03 18:43:46 +00:00
* Create go.yml * Merge from zkrollup and fix conflict * go mod tidy * fix worker_test test case * fix worker_test test case * Delete go.yml * add log content, enable memory trace * add tracer pool handler * Add comments and format code * add evmTrace subscribe api * Move the evmTrace struct. * Fix miner bug. * upgrade evmTrace api * fix bug about evmTracesByHash api * Fix the bug about block.timestamp and remove unnecessary copy. * Update eth/filters/api.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Upgrade comments. * Delete useless code in test file * Update miner/worker.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Change the return result to BlockResult. * Change return type. * Change blockResult to blockResults. * Add ReturnValue. * Update core/rawdb/l2trace.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Update core/rawdb/l2trace.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Update core/types/l2trace.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Add indent to the comment and rm json encoding flag. * Rm json encoding flag. * Update core/rawdb/l2trace.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Rm json encoding flag. * Update ethclient/ethclient.go Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Update eth/filters/api.go Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * Use as the blockResult prefix flag. * Update eth/filters/filter_system.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Update eth/filters/filter_system.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Update ethclient/ethclient.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> * Update eth/filters/api.go Co-authored-by: Haichen Shen <shenhaichen@gmail.com> Co-authored-by: Haichen Shen <shenhaichen@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package rawdb
|
|
|
|
import (
|
|
"github.com/scroll-tech/go-ethereum/common"
|
|
"github.com/scroll-tech/go-ethereum/core/types"
|
|
"github.com/scroll-tech/go-ethereum/ethdb"
|
|
"github.com/scroll-tech/go-ethereum/log"
|
|
"github.com/scroll-tech/go-ethereum/rlp"
|
|
)
|
|
|
|
// ReadBlockResult retrieves all data required by roller.
|
|
func ReadBlockResult(db ethdb.Reader, hash common.Hash) *types.BlockResult {
|
|
data, _ := db.Get(blockResultKey(hash))
|
|
if len(data) == 0 {
|
|
return nil
|
|
}
|
|
var blockResult types.BlockResult
|
|
if err := rlp.DecodeBytes(data, &blockResult); err != nil {
|
|
log.Error("Failed to decode BlockResult", "err", err)
|
|
return nil
|
|
}
|
|
return &blockResult
|
|
}
|
|
|
|
// WriteBlockResult stores blockResult into leveldb.
|
|
func WriteBlockResult(db ethdb.KeyValueWriter, hash common.Hash, blockResult *types.BlockResult) {
|
|
bytes, err := rlp.EncodeToBytes(blockResult)
|
|
if err != nil {
|
|
log.Crit("Failed to RLP encode BlockResult", "err", err)
|
|
}
|
|
db.Put(blockResultKey(hash), bytes)
|
|
}
|
|
|
|
// DeleteBlockResult removes blockResult with a block hash.
|
|
func DeleteBlockResult(db ethdb.KeyValueWriter, hash common.Hash) {
|
|
if err := db.Delete(blockResultKey(hash)); err != nil {
|
|
log.Crit("Failed to delete BlockResult", "err", err)
|
|
}
|
|
}
|