wormhole/event_database
jschuldt ce22a18101 Event database init script
Add new folder, 'event_database', containing a
Go script for initializing a BigTable table
and querying it for events.

Change-Id: I8ffda2e3ef43bf2faa9fc6eaf53efa019a3fecff
2021-08-05 12:53:56 +00:00
..
README.md Event database init script 2021-08-05 12:53:56 +00:00
database.go Event database init script 2021-08-05 12:53:56 +00:00
database_query.go Event database init script 2021-08-05 12:53:56 +00:00
database_setup.go Event database init script 2021-08-05 12:53:56 +00:00
go.mod Event database init script 2021-08-05 12:53:56 +00:00
go.sum Event database init script 2021-08-05 12:53:56 +00:00

README.md

Initializing BigTable instance

Once you've created a BigTable instance and a Service Account key, these Go scripts can create the table and column families to save event data.

Pass your BigTable connection info via args:

  • the Google Cloud projectID
  • BigTable instance name
  • the path to a GCP Service Account with appropriate permissions

Invoke the script with the DB config options and -setupDB to create the table and column families, if they do not already exist. If they do already exists when the script runs, it will do nothing.

go run . \
  -project your-GCP-projectID \
  -instance your-BigTable-instance-name \
  -keyFilePath ./service-account-key.json \
  -setupDB

Querying BigTable

Lookup a row by the EmitterChain:TxID:

go run . \
  -project wormhole-315720 \
  -instance wormhole-dev \
  -keyFilePath ./bigtable-admin.json \
  -queryRowKey ethereum:0xf15fe0e6dedef169a25696c577bfddf3d35707210ac641108646d7cfe507f174

Lookup all rows with a timestamp >= queryPreviousMinutes ago:

go run . \
  -project wormhole-315720 \
  -instance wormhole-dev \
  -keyFilePath ./bigtable-admin.json \
  -queryPreviousMinutes 120