Skip to content

Commit 3b1b8fa

Browse files
committed
Add support for storing and serving heartbeat transaction types (note: this initial commit depends on a non-merged branch of go-algorand-sdk).
1 parent e0fc340 commit 3b1b8fa

File tree

12 files changed

+669
-438
lines changed

12 files changed

+669
-438
lines changed

api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The API is defined using [OpenAPI v2](https://swagger.io/specification/v2/) in *
99
The Makefile will install our fork of **oapi-codegen**, use `make oapi-codegen` to install it directly.
1010

1111
1. Document your changes by editing **indexer.oas2.yml**
12-
2. Regenerate the endpoints by running **generate.sh**. The sources at **generated/** will be updated.
12+
2. Regenerate the endpoints by running **make generate** from the `api` directory. The sources at **generated/** will be updated.
1313
3. Update the implementation in **handlers.go**. It is sometimes useful to consult **generated/routes.go** to make sure the handler properly implements **ServerInterface**.
1414

1515
## What codegen tool is used?

api/converter_utils.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
306306
var assetTransfer *generated.TransactionAssetTransfer
307307
var application *generated.TransactionApplication
308308
var stateProof *generated.TransactionStateProof
309+
var heartbeat *generated.TransactionHeartBeat
309310

310311
switch stxn.Txn.Type {
311312
case sdk.PaymentTx:
@@ -509,6 +510,20 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
509510
StateProofType: uint64Ptr(uint64(stxn.Txn.StateProofType)),
510511
}
511512
stateProof = &proofTxn
513+
case sdk.HeartbeatTx:
514+
hb := stxn.Txn.HeartbeatTxnFields
515+
hbTxn := generated.TransactionHeartBeat{
516+
HbAddress: hb.HbAddress.String(),
517+
HbProof: generated.HbProofFields{
518+
HbPk: byteSliceOmitZeroPtr(hb.HbProof.PK[:]),
519+
HbPk1sig: byteSliceOmitZeroPtr(hb.HbProof.PK1Sig[:]),
520+
HbPk2: byteSliceOmitZeroPtr(hb.HbProof.PK2[:]),
521+
HbPk2sig: byteSliceOmitZeroPtr(hb.HbProof.PK2Sig[:]),
522+
HbSig: byteSliceOmitZeroPtr(hb.HbProof.Sig[:]),
523+
},
524+
HbSeed: hb.HbSeed[:],
525+
}
526+
heartbeat = &hbTxn
512527
}
513528

514529
var localStateDelta *[]generated.AccountStateDelta
@@ -585,6 +600,7 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
585600
PaymentTransaction: payment,
586601
KeyregTransaction: keyreg,
587602
StateProofTransaction: stateProof,
603+
HeartBeatTransaction: heartbeat,
588604
ClosingAmount: uint64Ptr(uint64(stxn.ClosingAmount)),
589605
ConfirmedRound: uint64Ptr(extra.Round),
590606
IntraRoundOffset: uint64Ptr(uint64(extra.Intra)),

api/generate.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

api/generated/common/routes.go

Lines changed: 189 additions & 183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/generated/common/types.go

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)