Skip to content

Commit

Permalink
change time.Time to int64 (#19)
Browse files Browse the repository at this point in the history
* change time.Time to int64

* fix
  • Loading branch information
ToniRamirezM authored Sep 14, 2023
1 parent 4c686f2 commit b6532da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func runServer(*cli.Context) error {
log.Info(">> App begin")

// Create stream server
s, err := datastreamer.New(1337, StSequencer, "streamfile.bin")
s, err := datastreamer.New(6900, StSequencer, "streamfile.bin")
if err != nil {
os.Exit(1)
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func runServer(*cli.Context) error {
l2block := db.L2Block{
BatchNumber: 1,
L2BlockNumber: 1000,
Timestamp: time.Now(),
Timestamp: time.Now().Unix(),
GlobalExitRoot: [32]byte{10, 11, 12, 13, 14},
Coinbase: [20]byte{20, 21, 22, 23, 24},
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func runServer(*cli.Context) error {

func runClient(*cli.Context) error {
// Create client
c, err := datastreamer.NewClient("127.0.0.1:1337", StSequencer)
c, err := datastreamer.NewClient("127.0.0.1:6900", StSequencer)
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion tool/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package db
import (
"context"
"fmt"
"time"

"github.com/0xPolygonHermez/zkevm-data-streamer/log"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -70,18 +71,20 @@ func scanL2Block(row pgx.Row) (*L2Block, error) {
var (
gerStr string
coinbaseStr string
timestamp time.Time
)
if err := row.Scan(
&l2Block.BatchNumber,
&l2Block.L2BlockNumber,
&l2Block.Timestamp,
&timestamp,
&gerStr,
&coinbaseStr,
); err != nil {
return &l2Block, err
}
l2Block.GlobalExitRoot = common.HexToHash(gerStr)
l2Block.Coinbase = common.HexToAddress(coinbaseStr)
l2Block.Timestamp = timestamp.Unix()
return &l2Block, nil
}

Expand Down
3 changes: 1 addition & 2 deletions tool/db/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package db

import (
"time"
"unsafe"

"github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer"
Expand All @@ -21,7 +20,7 @@ const (
type L2Block struct {
BatchNumber uint64
L2BlockNumber uint64
Timestamp time.Time
Timestamp int64
GlobalExitRoot common.Hash
Coinbase common.Address
}
Expand Down
4 changes: 4 additions & 0 deletions tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func start(cliCtx *cli.Context) error {
}

streamServer.SetEntriesDefinition(entriesDefinition)
err = streamServer.Start()
if err != nil {
log.Fatal(err)
}

// Connect to the database
stateSqlDB, err := db.NewSQLDB(c.StateDB)
Expand Down

0 comments on commit b6532da

Please sign in to comment.