cloud functions - handle 2 digit chainIDs

This commit is contained in:
justinschuldt 2022-03-14 13:32:46 -05:00 committed by Justin Schuldt
parent 6e32dbe403
commit 57c06dea11
3 changed files with 8 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import (
"log"
"net/http"
"strconv"
"strings"
"sync"
"time"
@ -79,7 +80,8 @@ func fetchAddressRowsInInterval(tbl *bigtable.Table, ctx context.Context, prefix
t.DestinationAddress = transformHexAddressToNative(chainIdStringToType(t.DestinationChain), t.DestinationAddress)
}
t.LeavingChain = row.Key()[:1]
keyParts := strings.Split(row.Key(), ":")
t.LeavingChain = keyParts[0]
rows = append(rows, *t)
}

View File

@ -11,6 +11,7 @@ import (
"log"
"net/http"
"strconv"
"strings"
"sync"
"time"
@ -90,7 +91,8 @@ func fetchTransferRowsInInterval(tbl *bigtable.Table, ctx context.Context, prefi
}
}
t.LeavingChain = row.Key()[:1]
keyParts := strings.Split(row.Key(), ":")
t.LeavingChain = keyParts[0]
rows = append(rows, *t)
}

View File

@ -271,13 +271,13 @@ func Recent(w http.ResponseWriter, r *http.Request) {
// create the rowkey prefix for querying, and the keySegments to use for indexing results.
prefix := ""
if forChain != "" {
prefix = forChain
prefix = forChain + ":"
if groupBy == "" {
// groupBy was not set, but forChain was, so set the keySegments to index by chain
keySegments = 1
}
if forAddress != "" {
prefix = forChain + ":" + forAddress
prefix = forChain + forAddress
if groupBy == "" {
// groupBy was not set, but forAddress was, so set the keySegments to index by address
keySegments = 2