diff --git a/tracer/firehose_tracer.go b/tracer/firehose_tracer.go index 31db26d..00f1ca3 100644 --- a/tracer/firehose_tracer.go +++ b/tracer/firehose_tracer.go @@ -1,11 +1,12 @@ package tracer import ( + "encoding/base64" "fmt" - "time" pbacme "github.com/streamingfast/dummy-blockchain/pb/sf/acme/type/v1" "github.com/streamingfast/dummy-blockchain/types" + "google.golang.org/protobuf/proto" ) var _ Tracer = &FirehoseTracer{} @@ -29,33 +30,30 @@ func (t *FirehoseTracer) OnBlockEnd(blk *types.Block, finalBlockHeader *types.Bl header := t.activeBlock.Header - // previousNum := uint64(0) - // if header.PreviousNum != nil { - // previousNum = *header.PreviousNum - // } - - // previousHash := "" - // if header.PreviousHash != nil { - // previousHash = *header.PreviousHash - // } - - // blockPayload, err := proto.Marshal(t.activeBlock) - // if err != nil { - // panic(fmt.Errorf("unable to marshal block: %w", err)) - // } - - blockTime := time.Unix(0, int64(header.Timestamp)) - fmt.Println(blockTime) - - // fmt.Printf("FIRE BLOCK %d %s %d %s %d %d %s\n", - // header.Height, - // header.Hash, - // previousNum, - // previousHash, - // header.FinalNum, - // header.Timestamp, - // base64.StdEncoding.EncodeToString(blockPayload), - // ) + previousNum := uint64(0) + if header.PreviousNum != nil { + previousNum = *header.PreviousNum + } + + previousHash := "" + if header.PreviousHash != nil { + previousHash = *header.PreviousHash + } + + blockPayload, err := proto.Marshal(t.activeBlock) + if err != nil { + panic(fmt.Errorf("unable to marshal block: %w", err)) + } + + fmt.Printf("FIRE BLOCK %d %s %d %s %d %d %s\n", + header.Height, + header.Hash, + previousNum, + previousHash, + header.FinalNum, + header.Timestamp, + base64.StdEncoding.EncodeToString(blockPayload), + ) t.activeBlock = nil t.activeTrx = nil