Skip to content

Commit

Permalink
refactor: BroadcastTransaction() helper becomes part of Ae struct, so…
Browse files Browse the repository at this point in the history
… aeClient.BroadcastTransaction()
  • Loading branch information
randomshinichi committed Mar 26, 2019
1 parent 528eba0 commit adb1b7f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions aeternity/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func SpendTxStr(sender, recipient string, amount, fee utils.BigInt, message stri
}

// BroadcastTransaction recalculates the transaction hash and sends the transaction to the node.
func BroadcastTransaction(nodeClient *apiclient.Node, txSignedBase64 string) (err error) {
func (ae *Ae) BroadcastTransaction(txSignedBase64 string) (err error) {
// Get back to RLP to calculate txhash
txRLP, _ := Decode(txSignedBase64)

Expand All @@ -124,7 +124,7 @@ func BroadcastTransaction(nodeClient *apiclient.Node, txSignedBase64 string) (er
signedEncodedTxHash := Encode(PrefixTransactionHash, rlpTxHashRaw)

// send it to the network
err = postTransaction(nodeClient, txSignedBase64, signedEncodedTxHash)
err = postTransaction(ae.Node, txSignedBase64, signedEncodedTxHash)
return
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func broadcastFunc(cmd *cobra.Command, args []string) (err error) {
}

aeCli := NewAeCli()
err = aeternity.BroadcastTransaction(aeCli.Node, txSignedBase64)
err = aeCli.BroadcastTransaction(txSignedBase64)
if err != nil {
errFinal := fmt.Errorf("Error while broadcasting transaction: %v", err)
return errFinal
Expand Down
4 changes: 2 additions & 2 deletions integration_test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestSpendTxWithNode(t *testing.T) {
fmt.Println(signedBase64TxMsg)

// send the signed transaction to the node
err = aeternity.BroadcastTransaction(aeCli.Node, signedBase64TxMsg)
err = aeCli.BroadcastTransaction(signedBase64TxMsg)
if err != nil {
t.Fatalf("Error while broadcasting transaction: %v", err)
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestSpendTxLargeWithNode(t *testing.T) {
fmt.Println(signedBase64TxMsg)

// send the signed transaction to the node
err = aeternity.BroadcastTransaction(aeCli.Node, signedBase64TxMsg)
err = aeCli.BroadcastTransaction(signedBase64TxMsg)
if err != nil {
t.Fatalf("Error while broadcasting transaction: %v", err)
}
Expand Down

0 comments on commit adb1b7f

Please sign in to comment.