worker: some code enhancement on work.go #1174
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The code of work.go is critical for BSC block generation.
Try to do some code enhancement for it:
1.the resubmit intervalAdjust code was for PoW consensus, can be deleted.
2.change the work interrupt from atomic check to channel communication.
Rationale
With PoW, there will be a periodic timer to check if it is the time to stop packing transaction and start calculating the desired hash value, since other miner could succeed in hash compute if it spends too much time packing transactions.
It will commit the current fruit to calculate root at a reasonable time.
And it will schedule a new work to get a big block if new transaction was received.
When there are too many transactions in the TxPool, the interval of the resubmit timer would be increased and vice versa.
But it is not needed with PoS consensus, since the block interval is determined in PoS and there is already a timer to stop packing for too long.
Example
None
Changes
Remove unused worker code for BSC.