Add Ethereum Classic specific handling in GetTransaction
This commit is contained in:
parent
61177c3750
commit
c96c357013
@ -8,7 +8,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/golang/glog"
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
)
|
)
|
||||||
@ -76,6 +75,12 @@ type rpcReceipt struct {
|
|||||||
Logs []*rpcLog `json:"logs"`
|
Logs []*rpcLog `json:"logs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type rpcEtcReceipt struct {
|
||||||
|
GasUsed string `json:"gasUsed"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
Logs []*rpcLog `json:"logs"`
|
||||||
|
}
|
||||||
|
|
||||||
type completeTransaction struct {
|
type completeTransaction struct {
|
||||||
Tx *rpcTransaction `json:"tx"`
|
Tx *rpcTransaction `json:"tx"`
|
||||||
Receipt *rpcReceipt `json:"receipt,omitempty"`
|
Receipt *rpcReceipt `json:"receipt,omitempty"`
|
||||||
@ -178,14 +183,8 @@ func (p *EthereumParser) GetAddrDescFromAddress(address string) (bchain.AddressD
|
|||||||
address = address[2:]
|
address = address[2:]
|
||||||
}
|
}
|
||||||
if len(address) != EthereumTypeAddressDescriptorLen*2 {
|
if len(address) != EthereumTypeAddressDescriptorLen*2 {
|
||||||
if len(address) != 0 {
|
|
||||||
glog.Warning("Ignoring address ", address)
|
|
||||||
}
|
|
||||||
return nil, bchain.ErrAddressMissing
|
return nil, bchain.ErrAddressMissing
|
||||||
}
|
}
|
||||||
if len(address)&1 == 1 {
|
|
||||||
address = "0" + address
|
|
||||||
}
|
|
||||||
return hex.DecodeString(address)
|
return hex.DecodeString(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -529,7 +529,7 @@ func (b *EthereumRPC) GetTransaction(txid string) (*bchain.Tx, error) {
|
|||||||
return nil, errors.Annotatef(err, "txid %v", txid)
|
return nil, errors.Annotatef(err, "txid %v", txid)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// non mempool tx - we must read the block header to get the block time
|
// non mempool tx - read the block header to get the block time
|
||||||
raw, err := b.getBlockRaw(tx.BlockHash, 0, false)
|
raw, err := b.getBlockRaw(tx.BlockHash, 0, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -545,9 +545,24 @@ func (b *EthereumRPC) GetTransaction(txid string) (*bchain.Tx, error) {
|
|||||||
return nil, errors.Annotatef(err, "txid %v", txid)
|
return nil, errors.Annotatef(err, "txid %v", txid)
|
||||||
}
|
}
|
||||||
var receipt rpcReceipt
|
var receipt rpcReceipt
|
||||||
err = b.rpc.CallContext(ctx, &receipt, "eth_getTransactionReceipt", hash)
|
if b.isETC {
|
||||||
if err != nil {
|
var etcReceipt rpcEtcReceipt
|
||||||
return nil, errors.Annotatef(err, "txid %v", txid)
|
err = b.rpc.CallContext(ctx, &etcReceipt, "eth_getTransactionReceipt", hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Annotatef(err, "txid %v", txid)
|
||||||
|
}
|
||||||
|
receipt.GasUsed = etcReceipt.GasUsed
|
||||||
|
receipt.Logs = etcReceipt.Logs
|
||||||
|
if etcReceipt.Status == 0 {
|
||||||
|
receipt.Status = "0x0"
|
||||||
|
} else {
|
||||||
|
receipt.Status = "0x1"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err = b.rpc.CallContext(ctx, &receipt, "eth_getTransactionReceipt", hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Annotatef(err, "txid %v", txid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
n, err := ethNumber(tx.BlockNumber)
|
n, err := ethNumber(tx.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -72,9 +72,7 @@ func (d *RocksDB) GetAddrDescContracts(addrDesc bchain.AddressDescriptor) (*Addr
|
|||||||
})
|
})
|
||||||
buf = buf[eth.EthereumTypeAddressDescriptorLen+l:]
|
buf = buf[eth.EthereumTypeAddressDescriptorLen+l:]
|
||||||
}
|
}
|
||||||
return &AddrContracts{
|
return &AddrContracts{EthTxs: et, Contracts: c}, nil
|
||||||
EthTxs: et,
|
|
||||||
Contracts: c}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func findContractInAddressContracts(contract bchain.AddressDescriptor, contracts []AddrContract) (int, bool) {
|
func findContractInAddressContracts(contract bchain.AddressDescriptor, contracts []AddrContract) (int, bool) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user