rpc: cleanup, more tests, working http and jsonrpc

This commit is contained in:
Ethan Buchman
2015-03-29 18:02:03 -07:00
parent 6e81e8a848
commit fb90d5bc92
6 changed files with 465 additions and 223 deletions
+6 -6
View File
@@ -12,29 +12,29 @@ import (
type Receipt struct {
TxHash []byte
CreatesContract bool
CreatesContract uint8
ContractAddr []byte
}
// pass pointer?
// Note: tx must be signed
func BroadcastTx(tx types.Tx) (*Receipt, error) {
func BroadcastTx(tx types.Tx) (Receipt, error) {
err := mempoolReactor.BroadcastTx(tx)
if err != nil {
return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
return Receipt{}, fmt.Errorf("Error broadcasting transaction: %v", err)
}
txHash := merkle.HashFromBinary(tx)
var createsContract bool
var createsContract uint8
var contractAddr []byte
// check if creates new contract
if callTx, ok := tx.(*types.CallTx); ok {
if callTx.Address == nil {
createsContract = true
createsContract = 1
contractAddr = state.NewContractAddress(callTx.Input.Address, uint64(callTx.Input.Sequence))
}
}
return &Receipt{txHash, createsContract, contractAddr}, nil
return Receipt{txHash, createsContract, contractAddr}, nil
}
/*