Commit d01a371d authored by Hamdi Allam's avatar Hamdi Allam

fix etl

parent 496d7ef4
...@@ -77,10 +77,10 @@ func (l1Etl *L1ETL) Start(ctx context.Context) error { ...@@ -77,10 +77,10 @@ func (l1Etl *L1ETL) Start(ctx context.Context) error {
// Index incoming batches // Index incoming batches
case batch := <-l1Etl.etlBatches: case batch := <-l1Etl.etlBatches:
// Pull out only L1 blocks that have emitted a log ( <= batch.Headers ) // Pull out only L1 blocks that have emitted a log ( <= batch.Headers )
l1BlockHeaders := make([]*database.L1BlockHeader, 0, len(batch.Headers)) l1BlockHeaders := make([]database.L1BlockHeader, 0, len(batch.Headers))
for i := range batch.Headers { for i := range batch.Headers {
if _, ok := batch.HeadersWithLog[batch.Headers[i].Hash()]; ok { if _, ok := batch.HeadersWithLog[batch.Headers[i].Hash()]; ok {
l1BlockHeaders = append(l1BlockHeaders, &database.L1BlockHeader{BlockHeader: database.BlockHeaderFromHeader(&batch.Headers[i])}) l1BlockHeaders = append(l1BlockHeaders, database.L1BlockHeader{BlockHeader: database.BlockHeaderFromHeader(&batch.Headers[i])})
} }
} }
...@@ -89,10 +89,10 @@ func (l1Etl *L1ETL) Start(ctx context.Context) error { ...@@ -89,10 +89,10 @@ func (l1Etl *L1ETL) Start(ctx context.Context) error {
continue continue
} }
l1ContractEvents := make([]*database.L1ContractEvent, len(batch.Logs)) l1ContractEvents := make([]database.L1ContractEvent, len(batch.Logs))
for i := range batch.Logs { for i := range batch.Logs {
timestamp := batch.HeaderMap[batch.Logs[i].BlockHash].Time timestamp := batch.HeaderMap[batch.Logs[i].BlockHash].Time
l1ContractEvents[i] = &database.L1ContractEvent{ContractEvent: database.ContractEventFromLog(&batch.Logs[i], timestamp)} l1ContractEvents[i] = database.L1ContractEvent{ContractEvent: database.ContractEventFromLog(&batch.Logs[i], timestamp)}
} }
// Continually try to persist this batch. If it fails after 10 attempts, we simply error out // Continually try to persist this batch. If it fails after 10 attempts, we simply error out
......
...@@ -67,15 +67,15 @@ func (l2Etl *L2ETL) Start(ctx context.Context) error { ...@@ -67,15 +67,15 @@ func (l2Etl *L2ETL) Start(ctx context.Context) error {
// Index incoming batches // Index incoming batches
case batch := <-l2Etl.etlBatches: case batch := <-l2Etl.etlBatches:
// We're indexing every L2 block. // We're indexing every L2 block.
l2BlockHeaders := make([]*database.L2BlockHeader, len(batch.Headers)) l2BlockHeaders := make([]database.L2BlockHeader, len(batch.Headers))
for i := range batch.Headers { for i := range batch.Headers {
l2BlockHeaders[i] = &database.L2BlockHeader{BlockHeader: database.BlockHeaderFromHeader(&batch.Headers[i])} l2BlockHeaders[i] = database.L2BlockHeader{BlockHeader: database.BlockHeaderFromHeader(&batch.Headers[i])}
} }
l2ContractEvents := make([]*database.L2ContractEvent, len(batch.Logs)) l2ContractEvents := make([]database.L2ContractEvent, len(batch.Logs))
for i := range batch.Logs { for i := range batch.Logs {
timestamp := batch.HeaderMap[batch.Logs[i].BlockHash].Time timestamp := batch.HeaderMap[batch.Logs[i].BlockHash].Time
l2ContractEvents[i] = &database.L2ContractEvent{ContractEvent: database.ContractEventFromLog(&batch.Logs[i], timestamp)} l2ContractEvents[i] = database.L2ContractEvent{ContractEvent: database.ContractEventFromLog(&batch.Logs[i], timestamp)}
} }
// Continually try to persist this batch. If it fails after 5 attempts, we simply error out // Continually try to persist this batch. If it fails after 5 attempts, we simply error out
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment