|
@ -52,9 +52,9 @@ func BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) { |
|
|
func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTx, error) { |
|
|
func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTx, error) { |
|
|
|
|
|
|
|
|
// subscribe to tx being committed in block
|
|
|
// subscribe to tx being committed in block
|
|
|
appendTxResCh := make(chan *tmsp.Response, 1) |
|
|
|
|
|
|
|
|
appendTxResCh := make(chan types.EventDataTx, 1) |
|
|
eventSwitch.AddListenerForEvent("rpc", types.EventStringTx(tx), func(data events.EventData) { |
|
|
eventSwitch.AddListenerForEvent("rpc", types.EventStringTx(tx), func(data events.EventData) { |
|
|
appendTxResCh <- data.(*tmsp.Response) |
|
|
|
|
|
|
|
|
appendTxResCh <- data.(types.EventDataTx) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
// broadcast the tx and register checktx callback
|
|
|
// broadcast the tx and register checktx callback
|
|
@ -84,11 +84,10 @@ func BroadcastTxCommit(tx types.Tx) (*ctypes.ResultBroadcastTx, error) { |
|
|
// The tx was included in a block.
|
|
|
// The tx was included in a block.
|
|
|
// NOTE we don't return an error regardless of the AppendTx code;
|
|
|
// NOTE we don't return an error regardless of the AppendTx code;
|
|
|
// clients must check this to see if they need to send a new tx!
|
|
|
// clients must check this to see if they need to send a new tx!
|
|
|
r := appendTxRes.GetAppendTx() |
|
|
|
|
|
return &ctypes.ResultBroadcastTx{ |
|
|
return &ctypes.ResultBroadcastTx{ |
|
|
Code: r.Code, |
|
|
|
|
|
Data: r.Data, |
|
|
|
|
|
Log: r.Log, |
|
|
|
|
|
|
|
|
Code: appendTxRes.Code, |
|
|
|
|
|
Data: appendTxRes.Result, |
|
|
|
|
|
Log: appendTxRes.Log, |
|
|
}, nil |
|
|
}, nil |
|
|
case <-timer.C: |
|
|
case <-timer.C: |
|
|
r := checkTxR |
|
|
r := checkTxR |
|
|