impl: Cleanup EthTxHashManager handling
This commit is contained in:
parent
60dbd59aa0
commit
e194cbc715
@ -257,14 +257,11 @@ func (a *EthModule) EthGetTransactionByHash(ctx context.Context, txHash *ethtype
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c := cid.Undef
|
c, err := a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(*txHash)
|
||||||
if a.EthTxHashManager != nil { // todo rm checks
|
if err != nil {
|
||||||
var err error
|
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||||
c, err = a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(*txHash)
|
|
||||||
if err != nil {
|
|
||||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This isn't an eth transaction we have the mapping for, so let's look it up as a filecoin message
|
// This isn't an eth transaction we have the mapping for, so let's look it up as a filecoin message
|
||||||
if c == cid.Undef {
|
if c == cid.Undef {
|
||||||
c = txHash.ToCid()
|
c = txHash.ToCid()
|
||||||
@ -306,25 +303,22 @@ func (a *EthModule) EthGetMessageCidByTransactionHash(ctx context.Context, txHas
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c := cid.Undef
|
c, err := a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(*txHash)
|
||||||
if a.EthTxHashManager != nil {
|
// We fall out of the first condition and continue
|
||||||
var err error
|
if errors.Is(err, ethhashlookup.ErrNotFound) {
|
||||||
c, err = a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(*txHash)
|
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||||
// We fall out of the first condition and continue
|
} else if err != nil {
|
||||||
if errors.Is(err, ethhashlookup.ErrNotFound) {
|
return nil, xerrors.Errorf("database error: %w", err)
|
||||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
} else {
|
||||||
} else if err != nil {
|
return &c, nil
|
||||||
return nil, xerrors.Errorf("database error: %w", err)
|
|
||||||
} else {
|
|
||||||
return &c, nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This isn't an eth transaction we have the mapping for, so let's try looking it up as a filecoin message
|
// This isn't an eth transaction we have the mapping for, so let's try looking it up as a filecoin message
|
||||||
if c == cid.Undef {
|
if c == cid.Undef {
|
||||||
c = txHash.ToCid()
|
c = txHash.ToCid()
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := a.StateAPI.Chain.GetSignedMessage(ctx, c)
|
_, err = a.StateAPI.Chain.GetSignedMessage(ctx, c)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// This is an Eth Tx, Secp message, Or BLS message in the mpool
|
// This is an Eth Tx, Secp message, Or BLS message in the mpool
|
||||||
return &c, nil
|
return &c, nil
|
||||||
@ -369,14 +363,11 @@ func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender ethtypes.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) {
|
func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) {
|
||||||
c := cid.Undef
|
c, err := a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(txHash)
|
||||||
if a.EthTxHashManager != nil {
|
if err != nil {
|
||||||
var err error
|
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
||||||
c, err = a.EthTxHashManager.TransactionHashLookup.GetCidFromHash(txHash)
|
|
||||||
if err != nil {
|
|
||||||
log.Debug("could not find transaction hash %s in lookup table", txHash.String())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This isn't an eth transaction we have the mapping for, so let's look it up as a filecoin message
|
// This isn't an eth transaction we have the mapping for, so let's look it up as a filecoin message
|
||||||
if c == cid.Undef {
|
if c == cid.Undef {
|
||||||
c = txHash.ToCid()
|
c = txHash.ToCid()
|
||||||
|
@ -19,15 +19,6 @@ import (
|
|||||||
|
|
||||||
func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRepo, fx.Lifecycle, *store.ChainStore, *stmgr.StateManager, EventAPI, *messagepool.MessagePool, full.StateAPI, full.ChainAPI, full.MpoolAPI) (*full.EthModule, error) {
|
func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRepo, fx.Lifecycle, *store.ChainStore, *stmgr.StateManager, EventAPI, *messagepool.MessagePool, full.StateAPI, full.ChainAPI, full.MpoolAPI) (*full.EthModule, error) {
|
||||||
return func(mctx helpers.MetricsCtx, r repo.LockedRepo, lc fx.Lifecycle, cs *store.ChainStore, sm *stmgr.StateManager, evapi EventAPI, mp *messagepool.MessagePool, stateapi full.StateAPI, chainapi full.ChainAPI, mpoolapi full.MpoolAPI) (*full.EthModule, error) {
|
return func(mctx helpers.MetricsCtx, r repo.LockedRepo, lc fx.Lifecycle, cs *store.ChainStore, sm *stmgr.StateManager, evapi EventAPI, mp *messagepool.MessagePool, stateapi full.StateAPI, chainapi full.ChainAPI, mpoolapi full.MpoolAPI) (*full.EthModule, error) {
|
||||||
em := &full.EthModule{
|
|
||||||
Chain: cs,
|
|
||||||
Mpool: mp,
|
|
||||||
StateManager: sm,
|
|
||||||
ChainAPI: chainapi,
|
|
||||||
MpoolAPI: mpoolapi,
|
|
||||||
StateAPI: stateapi,
|
|
||||||
}
|
|
||||||
|
|
||||||
dbPath, err := r.SqlitePath()
|
dbPath, err := r.SqlitePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -49,8 +40,6 @@ func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRep
|
|||||||
TransactionHashLookup: transactionHashLookup,
|
TransactionHashLookup: transactionHashLookup,
|
||||||
}
|
}
|
||||||
|
|
||||||
em.EthTxHashManager = ðTxHashManager
|
|
||||||
|
|
||||||
const ChainHeadConfidence = 1
|
const ChainHeadConfidence = 1
|
||||||
|
|
||||||
ctx := helpers.LifecycleCtx(mctx, lc)
|
ctx := helpers.LifecycleCtx(mctx, lc)
|
||||||
@ -75,6 +64,16 @@ func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRep
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return em, nil
|
return &full.EthModule{
|
||||||
|
Chain: cs,
|
||||||
|
Mpool: mp,
|
||||||
|
StateManager: sm,
|
||||||
|
|
||||||
|
ChainAPI: chainapi,
|
||||||
|
MpoolAPI: mpoolapi,
|
||||||
|
StateAPI: stateapi,
|
||||||
|
|
||||||
|
EthTxHashManager: ðTxHashManager,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user