Document fire-and-forget transaction mode

Add godoc to Create and CreateBulk explaining they return immediately
without waiting for block inclusion. Update package-level example to show
both fire-and-forget and wait-for-block patterns. Add Transaction Modes
section to README with code examples.
This commit is contained in:
2026-02-17 13:24:35 -05:00
parent c3d6d017df
commit 4dabbcd23a
3 changed files with 93 additions and 31 deletions

View File

@@ -16,6 +16,10 @@ func NewTransactionClient(c *client.Client) *TransactionClient {
return &TransactionClient{client: c}
}
// Create submits a new transaction and returns immediately with the assigned transaction ID.
// It does NOT wait for the transaction to be included in a block. Block processing happens
// asynchronously on a ~5-second cycle. If you need the block ID (e.g. for interchain
// verification), poll Get until Header.BlockId is populated.
func (tc *TransactionClient) Create(ctx context.Context, req *models.TransactionCreateRequest) (*models.TransactionCreateResponse, error) {
var resp models.TransactionCreateResponse
err := tc.client.Post(ctx, "/api/v1/transaction", models.ContentTypeJSON, req, &resp)
@@ -25,6 +29,10 @@ func (tc *TransactionClient) Create(ctx context.Context, req *models.Transaction
return &resp, nil
}
// CreateBulk submits multiple transactions and returns immediately with the assigned transaction IDs.
// It does NOT wait for the transactions to be included in a block. Block processing happens
// asynchronously on a ~5-second cycle. If you need block IDs, poll Get for each transaction
// until Header.BlockId is populated.
func (tc *TransactionClient) CreateBulk(ctx context.Context, req *models.TransactionBulkRequest) (*models.TransactionBulkResponse, error) {
var resp models.TransactionBulkResponse
err := tc.client.Post(ctx, "/api/v1/transaction/bulk", models.ContentTypeJSON, req, &resp)