-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Save/load spork cache #2206
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
Save/load spork cache #2206
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should serialize mapSporks too to avoid inconsistency, smth like this UdjinM6@75d2d14
|
Oooops, looks like I messed up in my own suggestion 🙈 pls see the fix UdjinM6@926e37b This reminds me however that it would be nice to have rpc tests here 😉 Test scenario could be smth like: start 2 connected nodes, send spork from one of them and make sure it propagated to another one, stop them, start one of them again and also the 3rd (clean) node, make sure 3rd node has correct sporks too (i.e. old node loaded sporks and propagated them on sync request from the 3rd one). |
|
Sorry, I've tried to check it in debugger in testnet, but have had a sync issues and didn't test it in details, it's my bad.( You are right, I should add the tests to this PR. |
|
Needs rebase, pls see #2213 |
|
|
||
| bool CSporkManager::GetSporkByHash(const uint256& hash, CSporkMessage &sporkRet) | ||
| { | ||
| const auto it = mapSporksByHash.find(hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should protect via cs here as well I think.
qa/rpc-tests/sporks.py
Outdated
| connect_nodes(self.nodes[0], 1) | ||
|
|
||
| def get_test_spork_state(self, node): | ||
| info = node.spork('show') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use spork active instead
| self.set_test_spork_state(self.nodes[0], False) | ||
| start = time() | ||
| sent = False | ||
| while True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add a small timeout between rpc calls in while True loops e.g. sleep(0.1)
| connect_nodes(self.nodes[1], 2) | ||
| start = time() | ||
| sent = False | ||
| while True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
UdjinM6
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
utACK
Save/load sporks set with their states in cache file (sporks.dat) to reload them after dashd restart, just like we already do for masternodes, governance, instantsend etc.