export MakeRowKey in bigtablewriter.go (#650)

So it can be used elsewhere, in cloud functions.
This commit is contained in:
Justin Schuldt 2021-12-27 12:21:47 -06:00 committed by GitHub
parent 43d858772a
commit 9656cca4f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -28,7 +28,7 @@ type bigTableWriter struct {
}
// rowKey returns a string with the input vales delimited by colons.
func makeRowKey(emitterChain vaa.ChainID, emitterAddress vaa.Address, sequence uint64) string {
func MakeRowKey(emitterChain vaa.ChainID, emitterAddress vaa.Address, sequence uint64) string {
// left-pad the sequence with zeros to 16 characters, because bigtable keys are stored lexicographically
return fmt.Sprintf("%d:%s:%016d", emitterChain, emitterAddress, sequence)
}
@ -92,7 +92,7 @@ func BigTableWriter(events *AttestationEventReporter, connectionConfig *BigTable
bigtable.ColumnFilter("EmitterAddress"))
conditionalMutation := bigtable.NewCondMutation(filter, nil, mutation)
rowKey := makeRowKey(msg.VAA.EmitterChain, msg.VAA.EmitterAddress, msg.VAA.Sequence)
rowKey := MakeRowKey(msg.VAA.EmitterChain, msg.VAA.EmitterAddress, msg.VAA.Sequence)
err := tbl.Apply(ctx, rowKey, conditionalMutation)
if err != nil {
logger.Warn("Failed to write message publication to BigTable",
@ -119,7 +119,7 @@ func BigTableWriter(events *AttestationEventReporter, connectionConfig *BigTable
bigtable.ColumnFilter("SignedVAA"))
conditionalMutation := bigtable.NewCondMutation(filter, nil, mutation)
rowKey := makeRowKey(msg.EmitterChain, msg.EmitterAddress, msg.Sequence)
rowKey := MakeRowKey(msg.EmitterChain, msg.EmitterAddress, msg.Sequence)
err := tbl.Apply(ctx, rowKey, conditionalMutation)
if err != nil {
logger.Warn("Failed to write persistence info to BigTable",