Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for destructed contracts #22

Open
tpmccallum opened this issue May 25, 2019 · 3 comments
Open

Allow for destructed contracts #22

tpmccallum opened this issue May 25, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@tpmccallum
Copy link
Contributor

Show only the last known state of a contract, which has since been destructed.
Display a flag which shows that the contract has been destructed.

@tpmccallum tpmccallum added the enhancement New feature or request label May 29, 2019
@tpmccallum
Copy link
Contributor Author

We will also need to write a separate process for updating the "yes"/"no" values in the "requiresUpdating" field.

@tpmccallum
Copy link
Contributor Author

tpmccallum commented Jun 4, 2019

The harvest.py maintains a list of contract addresses (which have ABIs and can therefore have their state updated in real-time). When run in the -m state mode the harvest.py file can compare the list of fresh contract addresses (which have ABIs) with the previous round's cached list. If a new contract has been added since the last round then the harvest.py file creates only one new web3 contract instance (as apposed to starting all over and creating all new web3 contract instances). Here is the code.

 
origListOfAddresses = []
for originalItem in originalListOfAddressesAndAbi:
    if originalItem['contractAddress'] not in origListOfAddresses:
        origListOfAddresses.append(originalItem['contractAddress'])
self.fetchContractAddressesWithAbis()
for newItem in self.esAbiAddresses:
    if newItem['contractAddress'] not in origListOfAddresses:
        print("Found a new contract " + newItem['contractAddress'] + ", creating a new web3 instance")
        self.fetchContractInstances(newItem['abiSha3'], newItem['contractAddress'])

If a contract is destructed it will still show up the self.esAbiAddresses (which is updated every block). All we need to do to stop the state updating is to add an additional condition to the function that populates the self.esAbiAddresses. The current function is called fetchContractAddressesWithAbis it produces the following query which we will need to modify slightly; to account for the requiresUpdating field.

{'query': {'bool': {'must_not': [{'exists': {'field': 'byteSha3'}}], 'should': [{'wildcard': {'abiSha3': '0x*'}}]}}, '_source': ['contractAddress', 'abiSha3']}

@tpmccallum
Copy link
Contributor Author

Obviously another separate process with awareness of the contract's destruction will still be required to set the requiresUpdating field in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant