-
Notifications
You must be signed in to change notification settings - Fork 818
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add totalDiffculty to BlockPropagated events. (#97)
* Add totalDiffculty to BlockPropagated events. The chain head block can be contentious with many fork blocks (ommers) propagating on the network. We should add a totalDifficulty to make it easier to see which block is most likely the current head. - added `BlockPropagated` interface in `plugin-api`. - updated `BesuEvents.onBlockPropagated` method to take a `BlockPropagated` instead of a `BlockHeader`. - created `BlockPropagatedSubscriber` in `BlockBroadcaster`. - changed type of `BlockBroadcaster.blockPropagatedSubscribers` from `Consumer<Block>` to `BlockPropagatedSubscriber`. - updated unit tests accordingly to all changes. - updated known hash in `build.gradle` file of `plugin-api`: new value is `4SAeaZIJMsDvUK5Wp2RzU8TlHacslALnM/4yvVhsMtY=` Signed-off-by: Abdelhamid Bakhta <[email protected]>
- Loading branch information
1 parent
b4f1bec
commit 5e819fe
Showing
8 changed files
with
91 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
plugin-api/src/main/java/org/hyperledger/besu/plugin/data/PropagatedBlockContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.plugin.data; | ||
|
||
import org.hyperledger.besu.plugin.Unstable; | ||
|
||
/** The minimum set of data for a PropagatedBlockContext. */ | ||
@Unstable | ||
public interface PropagatedBlockContext { | ||
|
||
/** | ||
* A {@link BlockHeader} object. | ||
* | ||
* @return A {@link BlockHeader} | ||
*/ | ||
BlockHeader getBlockHeader(); | ||
|
||
/** | ||
* A scalar value corresponding to the total difficulty. | ||
* | ||
* @return A scalar value corresponding to the total difficulty. | ||
*/ | ||
Quantity getTotalDifficulty(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters