Skip to content

Commit

Permalink
refactor: getTransactionByHashHeighter interface renamed to transacti…
Browse files Browse the repository at this point in the history
…onWaiter
  • Loading branch information
randomshinichi committed Jan 21, 2020
1 parent a6b5cb1 commit 30e6487
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion aeternity/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type transactionSender interface {

type broadcastWaitTransactionNodeCapabilities interface {
naet.PostTransactioner
getTransactionByHashHeighter
transactionWaiter
}

type CompileEncoder interface {
Expand Down
13 changes: 6 additions & 7 deletions aeternity/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ func GetChannelsByName(n GetAnythingByNameFunc, name string) (channels []string,
return n(name, "channel")
}

// getTransactionByHashHeighter is used by WaitForTransactionForXBlocks to
// specify that the node/mock node passed in should support
// GetTransactionByHash() and GetHeight()
type getTransactionByHashHeighter interface {
// transactionWaiter is used to poll the node until a given tx is mined, or
// until a certain height is reached.
type transactionWaiter interface {
naet.GetTransactionByHasher
naet.GetHeighter
}
Expand All @@ -81,14 +80,14 @@ func SignBroadcast(tx transactions.Transaction, signingAccount *account.Account,
return
}

txReceipt = NewTxReceipt(&tx, signedTxStr, hash, signature)
txReceipt = NewTxReceipt(tx, signedTxStr, hash, signature)
return
}

// WaitSynchronous blocks until TxReceipt.Watch() reports that a transaction was
// mined/not mined. It is intended as a convenience function since it makes an
// asynchronous operation synchronous.
func WaitSynchronous(txReceipt *TxReceipt, waitBlocks uint64, n getTransactionByHashHeighter) (err error) {
func WaitSynchronous(txReceipt *TxReceipt, waitBlocks uint64, n transactionWaiter) (err error) {
minedChan := make(chan bool)
go txReceipt.Watch(minedChan, waitBlocks, n)
mined := <-minedChan
Expand Down Expand Up @@ -129,7 +128,7 @@ func NewTxReceipt(tx transactions.Transaction, signedTx, hash, signature string)
// after which it errors out via TxReceiptWatchResult. The node polling interval
// can be configured with config.Tuning.ChainPollInterval, which accepts a
// time.Duration.
func (t *TxReceipt) Watch(mined chan bool, waitBlocks uint64, node getTransactionByHashHeighter) {
func (t *TxReceipt) Watch(mined chan bool, waitBlocks uint64, node transactionWaiter) {
nodeHeight, err := node.GetHeight()
if err != nil {
t.Error = err
Expand Down

0 comments on commit 30e6487

Please sign in to comment.