2020-08-12 13:47:59 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/core/types"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/rlp"
|
|
|
|
)
|
|
|
|
|
|
|
|
type EthBackend struct {
|
|
|
|
Backend
|
|
|
|
}
|
|
|
|
|
|
|
|
type Backend interface {
|
|
|
|
TxPool() *TxPool
|
|
|
|
Etherbase() (common.Address, error)
|
2020-08-18 17:22:49 +00:00
|
|
|
NetVersion() (uint64, error)
|
2020-09-03 07:51:19 +00:00
|
|
|
BloomIndexer() *ChainIndexer
|
2020-08-12 13:47:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewEthBackend(eth Backend) *EthBackend {
|
|
|
|
return &EthBackend{eth}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (back *EthBackend) AddLocal(signedtx []byte) ([]byte, error) {
|
|
|
|
tx := new(types.Transaction)
|
|
|
|
if err := rlp.DecodeBytes(signedtx, tx); err != nil {
|
|
|
|
return common.Hash{}.Bytes(), err
|
|
|
|
}
|
|
|
|
|
|
|
|
return tx.Hash().Bytes(), back.TxPool().AddLocal(tx)
|
|
|
|
}
|
2020-09-03 07:51:19 +00:00
|
|
|
|
|
|
|
func (back *EthBackend) BloomStatus() (uint64, uint64, common.Hash) {
|
|
|
|
return back.Backend.BloomIndexer().Sections()
|
|
|
|
}
|