mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
35 lines
913 B
Go
35 lines
913 B
Go
package eth
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/ethereum/go-ethereum/consensus/bor"
|
|
"github.com/ethereum/go-ethereum/core"
|
|
"github.com/ethereum/go-ethereum/event"
|
|
)
|
|
|
|
// GetRootHash returns root hash for given start and end block
|
|
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)
|
|
}
|
|
}
|
|
|
|
if api == nil {
|
|
return "", errors.New("Only available in Bor engine")
|
|
}
|
|
|
|
root, err := api.GetRootHash(starBlockNr, endBlockNr)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return root, nil
|
|
}
|
|
|
|
// SubscribeStateSyncEvent subscribes to state sync event
|
|
func (b *EthAPIBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription {
|
|
return b.eth.BlockChain().SubscribeStateSyncEvent(ch)
|
|
}
|