Stop indexing contracts of ETH zero address
This commit is contained in:
parent
341bf331c1
commit
8c4fcf4441
@ -513,6 +513,7 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto
|
|||||||
// filter only transactions of this contract
|
// filter only transactions of this contract
|
||||||
filter.Vout = i + 1
|
filter.Vout = i + 1
|
||||||
}
|
}
|
||||||
|
validContract := true
|
||||||
ci, err := w.chain.EthereumTypeGetErc20ContractInfo(c.Contract)
|
ci, err := w.chain.EthereumTypeGetErc20ContractInfo(c.Contract)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, 0, 0, 0, errors.Annotatef(err, "EthereumTypeGetErc20ContractInfo %v", c.Contract)
|
return nil, nil, nil, 0, 0, 0, errors.Annotatef(err, "EthereumTypeGetErc20ContractInfo %v", c.Contract)
|
||||||
@ -524,9 +525,10 @@ func (w *Worker) getEthereumTypeAddressBalances(addrDesc bchain.AddressDescripto
|
|||||||
ci.Contract = addresses[0]
|
ci.Contract = addresses[0]
|
||||||
ci.Name = addresses[0]
|
ci.Name = addresses[0]
|
||||||
}
|
}
|
||||||
|
validContract = false
|
||||||
}
|
}
|
||||||
// do not read contract balances etc in case of Basic option
|
// do not read contract balances etc in case of Basic option
|
||||||
if option != Basic {
|
if option != Basic && validContract {
|
||||||
b, err = w.chain.EthereumTypeGetErc20ContractBalance(addrDesc, c.Contract)
|
b, err = w.chain.EthereumTypeGetErc20ContractBalance(addrDesc, c.Contract)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// return nil, nil, nil, errors.Annotatef(err, "EthereumTypeGetErc20ContractBalance %v %v", addrDesc, c.Contract)
|
// return nil, nil, nil, errors.Annotatef(err, "EthereumTypeGetErc20ContractBalance %v %v", addrDesc, c.Contract)
|
||||||
|
|||||||
@ -130,7 +130,9 @@ func parseErc20NumericProperty(contractDesc bchain.AddressDescriptor, data strin
|
|||||||
return &n
|
return &n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glog.Warning("Cannot parse '", data, "' for contract ", contractDesc)
|
if glog.V(1) {
|
||||||
|
glog.Warning("Cannot parse '", data, "' for contract ", contractDesc)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +152,9 @@ func parseErc20StringProperty(contractDesc bchain.AddressDescriptor, data string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glog.Warning("Cannot parse '", data, "' for contract ", contractDesc)
|
if glog.V(1) {
|
||||||
|
glog.Warning("Cannot parse '", data, "' for contract ", contractDesc)
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,9 +181,6 @@ func (b *EthereumRPC) EthereumTypeGetErc20ContractInfo(contractDesc bchain.Addre
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if name == "" {
|
|
||||||
name = address
|
|
||||||
}
|
|
||||||
contract = &bchain.Erc20Contract{
|
contract = &bchain.Erc20Contract{
|
||||||
Contract: address,
|
Contract: address,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
|
||||||
"github.com/bsm/go-vlq"
|
vlq "github.com/bsm/go-vlq"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
"github.com/tecbot/gorocksdb"
|
"github.com/tecbot/gorocksdb"
|
||||||
@ -93,6 +93,15 @@ func findContractInAddressContracts(contract bchain.AddressDescriptor, contracts
|
|||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isZeroAddress(addrDesc bchain.AddressDescriptor) bool {
|
||||||
|
for _, b := range addrDesc {
|
||||||
|
if b != 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (d *RocksDB) addToAddressesAndContractsEthereumType(addrDesc bchain.AddressDescriptor, btxID []byte, index int32, contract bchain.AddressDescriptor, addresses addressesMap, addressContracts map[string]*AddrContracts, addTxCount bool) error {
|
func (d *RocksDB) addToAddressesAndContractsEthereumType(addrDesc bchain.AddressDescriptor, btxID []byte, index int32, contract bchain.AddressDescriptor, addresses addressesMap, addressContracts map[string]*AddrContracts, addTxCount bool) error {
|
||||||
var err error
|
var err error
|
||||||
strAddrDesc := string(addrDesc)
|
strAddrDesc := string(addrDesc)
|
||||||
@ -115,20 +124,23 @@ func (d *RocksDB) addToAddressesAndContractsEthereumType(addrDesc bchain.Address
|
|||||||
ac.NonContractTxs++
|
ac.NonContractTxs++
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// locate the contract and set i to the index in the array of contracts
|
// do not store contracts for 0x0000000000000000000000000000000000000000 address
|
||||||
i, found := findContractInAddressContracts(contract, ac.Contracts)
|
if !isZeroAddress(addrDesc) {
|
||||||
if !found {
|
// locate the contract and set i to the index in the array of contracts
|
||||||
i = len(ac.Contracts)
|
i, found := findContractInAddressContracts(contract, ac.Contracts)
|
||||||
ac.Contracts = append(ac.Contracts, AddrContract{Contract: contract})
|
if !found {
|
||||||
}
|
i = len(ac.Contracts)
|
||||||
// index 0 is for ETH transfers, contract indexes start with 1
|
ac.Contracts = append(ac.Contracts, AddrContract{Contract: contract})
|
||||||
if index < 0 {
|
}
|
||||||
index = ^int32(i + 1)
|
// index 0 is for ETH transfers, contract indexes start with 1
|
||||||
} else {
|
if index < 0 {
|
||||||
index = int32(i + 1)
|
index = ^int32(i + 1)
|
||||||
}
|
} else {
|
||||||
if addTxCount {
|
index = int32(i + 1)
|
||||||
ac.Contracts[i].Txs++
|
}
|
||||||
|
if addTxCount {
|
||||||
|
ac.Contracts[i].Txs++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
counted := addToAddressesMap(addresses, strAddrDesc, btxID, index)
|
counted := addToAddressesMap(addresses, strAddrDesc, btxID, index)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user