You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
998 B

package core
import (
"fmt"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
)
//-----------------------------------------------------------------------------
// Note: tx must be signed
func BroadcastTx(tx types.Tx) (*ctypes.Receipt, error) {
err := mempoolReactor.BroadcastTx(tx)
if err != nil {
return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
}
txHash := types.TxId(mempoolReactor.Mempool.GetState().ChainID, tx)
var createsContract uint8
var contractAddr []byte
// check if creates new contract
if callTx, ok := tx.(*types.CallTx); ok {
if len(callTx.Address) == 0 {
createsContract = 1
contractAddr = state.NewContractAddress(callTx.Input.Address, uint64(callTx.Input.Sequence))
}
}
return &ctypes.Receipt{txHash, createsContract, contractAddr}, nil
}
func ListUnconfirmedTxs() ([]types.Tx, error) {
return mempoolReactor.Mempool.GetProposalTxs(), nil
}