mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package eth
|
|
|
|
import (
|
|
"context"
|
|
|
|
ethereum "github.com/maticnetwork/bor"
|
|
"github.com/maticnetwork/bor/common"
|
|
"github.com/maticnetwork/bor/consensus/bor"
|
|
"github.com/maticnetwork/bor/core/rawdb"
|
|
"github.com/maticnetwork/bor/core/types"
|
|
)
|
|
|
|
func (b *EthAPIBackend) GetRootHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64) (string, error) {
|
|
var api *bor.API
|
|
for _, _api := range b.eth.Engine().APIs(b.eth.BlockChain()) {
|
|
if _api.Namespace == "bor" {
|
|
api = _api.Service.(*bor.API)
|
|
}
|
|
}
|
|
|
|
root, err := api.GetRootHash(starBlockNr, endBlockNr)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return root, nil
|
|
}
|
|
|
|
func (b *EthAPIBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) {
|
|
receipt := b.eth.blockchain.GetBorReceiptByHash(hash)
|
|
if receipt == nil {
|
|
return nil, ethereum.NotFound
|
|
}
|
|
|
|
return receipt, nil
|
|
}
|
|
|
|
func (b *EthAPIBackend) GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]*types.Log, error) {
|
|
receipt := b.eth.blockchain.GetBorReceiptByHash(hash)
|
|
if receipt == nil {
|
|
return nil, nil
|
|
}
|
|
return receipt.Logs, nil
|
|
}
|
|
|
|
func (b *EthAPIBackend) GetBorBlockTransaction(ctx context.Context, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) {
|
|
tx, blockHash, blockNumber, index := rawdb.ReadBorTransaction(b.eth.ChainDb(), hash)
|
|
return tx, blockHash, blockNumber, index, nil
|
|
}
|