fix: start cumulative hash with first event hash

This commit is contained in:
Gaze
2024-06-10 01:45:17 +07:00
parent 2c5a6076ff
commit 3603248485

View File

@@ -99,7 +99,12 @@ func (p *Processor) flushBlock(ctx context.Context, blockHeader types.BlockHeade
if err != nil {
return errors.Wrap(err, "failed to get previous indexed block")
}
cumulativeEventHash := sha256.Sum256(append(prevIndexedBlock.CumulativeEventHash[:], eventHash[:]...))
var cumulativeEventHash [32]byte
if len(prevIndexedBlock.CumulativeEventHash) == 0 {
cumulativeEventHash = eventHash
} else {
cumulativeEventHash = sha256.Sum256(append(prevIndexedBlock.CumulativeEventHash[:], eventHash[:]...))
}
if err := brc20DgTx.CreateIndexedBlock(ctx, &entity.IndexedBlock{
Height: blockHeight,
Hash: blockHeader.Hash,