This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CliqueMiningTracker to make some things easier
Tests are still written with a full blockchain - which is semi-useful.
- Loading branch information
tmohay
committed
Dec 5, 2018
1 parent
29d08bc
commit 2aa45b8
Showing
4 changed files
with
151 additions
and
58 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...nsus/clique/src/main/java/tech/pegasys/pantheon/consensus/clique/CliqueMiningTracker.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,40 @@ | ||
/* | ||
* Copyright 2018 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 | ||
* | ||
* http://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. | ||
*/ | ||
package tech.pegasys.pantheon.consensus.clique; | ||
|
||
import tech.pegasys.pantheon.ethereum.ProtocolContext; | ||
import tech.pegasys.pantheon.ethereum.core.Address; | ||
import tech.pegasys.pantheon.ethereum.core.BlockHeader; | ||
|
||
public class CliqueMiningTracker { | ||
|
||
private final Address localAddress; | ||
private final ProtocolContext<CliqueContext> protocolContext; | ||
|
||
public CliqueMiningTracker( | ||
final Address localAddress, final ProtocolContext<CliqueContext> protocolContext) { | ||
this.localAddress = localAddress; | ||
this.protocolContext = protocolContext; | ||
} | ||
|
||
public boolean isProposerAfter(final BlockHeader header) { | ||
final Address nextProposer = | ||
CliqueHelpers.getProposerForBlockAfter( | ||
header, protocolContext.getConsensusState().getVoteTallyCache()); | ||
return localAddress.equals(nextProposer); | ||
} | ||
|
||
public boolean canMakeBlockNextRound(final BlockHeader header) { | ||
return CliqueHelpers.addressIsAllowedToProduceNextBlock(localAddress, protocolContext, header); | ||
} | ||
} |
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