Skip to content

Commit

Permalink
Filtering specific transaction for resolving error
Browse files Browse the repository at this point in the history
# Conflicts:
#	cmd/bt/main.go
  • Loading branch information
ArnaudBger committed Jan 29, 2024
1 parent 874d5ee commit 57515f5
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions cmd/bt/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package main

import (
"bytes"
"context"
"fmt"
"log"

"cloud.google.com/go/bigtable"
googleBigtable "cloud.google.com/go/bigtable"
"github.com/mr-tron/base58"
"github.com/streamingfast/firehose-solana/block/fetcher"
"github.com/streamingfast/logging"
"go.uber.org/zap"
)

func main() {
Expand All @@ -15,18 +21,38 @@ func main() {
panic(err)
}

tbl := client.Open("blocks")
filter := bigtable.ColumnFilter(".*proto$")
var logger, tracer = logging.PackageLogger("foo", "main")
logging.InstantiateLoggers(logging.WithDefaultLevel(zap.DebugLevel))

blockReader := fetcher.NewBigtableReader(client, 10, logger, tracer)

table := client.Open("blocks")
btRange := bigtable.NewRange(fmt.Sprintf("%016x", 140_000_000), "")

err = table.ReadRows(ctx, btRange, func(row bigtable.Row) bool {
block, _, err := blockReader.ProcessRow(row)
if err != nil {
panic(err)
}

//4xiPVLxJgpct8RKpVCV91x9aLYkfTwBayBw2JMFqw166a5atZgjSzYaSKqHVGpzGDLSgYYGdxdXeXFJkQCz6V7f5
signatureBytes, err := base58.Decode("4sKtga1XVH6Q1g9JEXYwoTD8h9QU4DswKqsxu8JvPH2aMQT9ipKi6WCyYatH9DYRgMf6RCi8ZDPAmg1w1ZT1hJEs")
if err != nil {
fmt.Errorf("base58.Decode: %w", err)
}

for _, transaction := range block.Transactions {
if bytes.Equal(transaction.Transaction.Signatures[0], signatureBytes) {
fmt.Println("found")
for _, balance := range transaction.Meta.PostTokenBalances {
fmt.Println("Balance data :", balance)
}
}
}

return false
})

err = tbl.ReadRows(
ctx,
bigtable.RowRange{},
func(row bigtable.Row) bool {
log.Println(row.Key())
return false
},
bigtable.RowFilter(filter),
)
if err != nil {
log.Fatalf("Could not read rows: %v", err)
}
Expand Down

0 comments on commit 57515f5

Please sign in to comment.