Skip to content

Commit

Permalink
feat: add Firehose logs
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Dec 13, 2023
1 parent c820312 commit d3b00ba
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,48 @@ func (b *Blockchain) Store(block *core.Block, blockCommitments *core.BlockCommit
if err := verifyBlock(txn, block); err != nil {
return err
}

// Firehose integration
// TODO: add runtime option to toggle this on and off
{

Check failure on line 345 in blockchain/blockchain.go

View workflow job for this annotation

GitHub Actions / lint

unnecessaryBlock: block doesn't have definitions, can be simply deleted (gocritic)
fmt.Printf("FIRE BLOCK_BEGIN %d\n", block.Number)

for ind_tx, tx := range block.Transactions {

Check failure on line 348 in blockchain/blockchain.go

View workflow job for this annotation

GitHub Actions / lint

ST1003: should not use underscores in Go names; range var ind_tx should be indTx (stylecheck)
fmt.Printf("FIRE BEGIN_TRX 0x%X ", tx.Hash().Bytes())

switch tx.(type) {
case *core.DeployTransaction:
fmt.Println("DEPLOY")
case *core.InvokeTransaction:
fmt.Println("INVOKE_FUNCTION")
case *core.DeclareTransaction:
fmt.Println("DECLARE")
case *core.DeployAccountTransaction:
fmt.Println("DEPLOY_ACCOUNT")
case *core.L1HandlerTransaction:
fmt.Println("L1_HANDLER")
default:
panic("not a transaction")
}

receipt := block.Receipts[ind_tx]

for ind_event, event := range receipt.Events {

Check failure on line 368 in blockchain/blockchain.go

View workflow job for this annotation

GitHub Actions / lint

ST1003: should not use underscores in Go names; range var ind_event should be indEvent (stylecheck)
fmt.Printf("FIRE TRX_BEGIN_EVENT 0x%X 0x%X\n", tx.Hash().Bytes(), event.From.Bytes())

for _, key := range event.Keys {
fmt.Printf("FIRE TRX_EVENT_KEY 0x%X %d 0x%X\n", tx.Hash().Bytes(), ind_event, key.Bytes())
}

for _, data := range event.Data {
fmt.Printf("FIRE TRX_EVENT_DATA 0x%X %d 0x%X\n", tx.Hash().Bytes(), ind_event, data.Bytes())
}
}
}

fmt.Printf("FIRE BLOCK_END %d 0x%X 0x%X %d %d\n", block.Number, block.Hash.Bytes(), block.ParentHash.Bytes(), block.Timestamp, len(block.Transactions))

Check failure on line 381 in blockchain/blockchain.go

View workflow job for this annotation

GitHub Actions / lint

line is 154 characters (lll)
}

if err := core.NewState(txn).Update(block.Number, stateUpdate, newClasses); err != nil {
return err
}
Expand Down

0 comments on commit d3b00ba

Please sign in to comment.