refactor: Decouple router and handlers (#31)

* refactor: decouple router to allow adding custom log and input data handlers

* feat: refactor handlers

* devops: update service build args

* chore: cleanup unecessary files/code
This commit is contained in:
2024-09-18 17:35:57 +03:00
committed by GitHub
parent 6cb5ea4f02
commit efc84970cc
32 changed files with 1103 additions and 1224 deletions

View File

@@ -11,7 +11,7 @@ import (
"github.com/grassrootseconomics/celo-tracker/db"
"github.com/grassrootseconomics/celo-tracker/internal/cache"
"github.com/grassrootseconomics/celo-tracker/internal/chain"
"github.com/grassrootseconomics/celo-tracker/internal/router"
"github.com/grassrootseconomics/celo-tracker/pkg/router"
)
type (
@@ -61,9 +61,9 @@ func (p *Processor) ProcessBlock(ctx context.Context, blockNumber uint64) error
return err
}
if exists {
if err := p.router.RouteSuccessTx(
if err := p.router.ProcessLog(
ctx,
router.SuccessTx{
router.LogPayload{
Log: log,
Timestamp: block.Time(),
},
@@ -89,9 +89,9 @@ func (p *Processor) ProcessBlock(ctx context.Context, blockNumber uint64) error
return fmt.Errorf("transaction decode error: tx %s: %v", receipt.TxHash.Hex(), err)
}
if err := p.router.RouteRevertTx(
if err := p.router.ProcessInputData(
ctx,
router.RevertTx{
router.InputDataPayload{
From: from.Hex(),
InputData: common.Bytes2Hex(tx.Data()),
Block: blockNumber,