Skip to content

Commit

Permalink
add some documentation to TransactionBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestofIranon committed Feb 19, 2020
1 parent edaa975 commit 1030e45
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions transaction_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"
)

// TransactionBuilder is used to construct Transactions. The state is mutable through the various setter functions.
type TransactionBuilder struct {
pb *proto.TransactionBody

Expand All @@ -22,6 +23,8 @@ func newTransactionBuilder() TransactionBuilder {
return builder
}

// Build validates and finalizes the transaction's state and prepares it for execution, returning a Transaction.
// The inner state becomes immutable, however it can still be signed after building.
func (builder TransactionBuilder) Build(client *Client) (Transaction, error) {
if client != nil && !builder.noTXFee {
builder.SetMaxTransactionFee(client.maxTransactionFee)
Expand Down Expand Up @@ -61,6 +64,8 @@ func (builder TransactionBuilder) Build(client *Client) (Transaction, error) {
return Transaction{pb, transactionIDFromProto(builder.pb.TransactionID)}, nil
}

// Execute is a short hand function to build and execute a transaction. It first calls build on the TransactionBuilder
// and as long as validation passes it will then execute the resulting Transaction.
func (builder TransactionBuilder) Execute(client *Client) (TransactionID, error) {
tx, err := builder.Build(client)

Expand Down

0 comments on commit 1030e45

Please sign in to comment.