-
Notifications
You must be signed in to change notification settings - Fork 870
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
Ibft queries #138
Ibft queries #138
Changes from 4 commits
a7128a1
b3e3ab1
e631b1c
c7e89b2
a2d0395
1cd1667
f6355e7
51cdf98
93aec23
2b758d2
6532e5f
9058360
03545e0
27ff144
ee98d56
682e768
65595f9
f0acc89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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 | ||
* | ||
* 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.controller; | ||
|
||
import org.hyperledger.besu.consensus.clique.CliqueBlockInterface; | ||
import org.hyperledger.besu.consensus.common.BlockInterface; | ||
import org.hyperledger.besu.consensus.common.PoaQueryServiceImpl; | ||
import org.hyperledger.besu.ethereum.chain.Blockchain; | ||
import org.hyperledger.besu.plugin.services.metrics.PoaQueryService; | ||
import org.hyperledger.besu.services.BesuPluginContextImpl; | ||
|
||
public class CliqueQueryFactory implements PluginServiceFactory { | ||
|
||
final Blockchain blockchain; | ||
|
||
public CliqueQueryFactory(final Blockchain blockchain) { | ||
this.blockchain = blockchain; | ||
} | ||
|
||
@Override | ||
public void appendQueries(final BesuPluginContextImpl besuContext) { | ||
final BlockInterface blockInterface = new CliqueBlockInterface(); | ||
|
||
besuContext.addService( | ||
PoaQueryService.class, new PoaQueryServiceImpl(blockInterface, blockchain)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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 | ||
* | ||
* 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.controller; | ||
|
||
import org.hyperledger.besu.consensus.common.BlockInterface; | ||
import org.hyperledger.besu.consensus.ibft.IbftBlockInterface; | ||
import org.hyperledger.besu.consensus.ibft.queries.IbftQueryServiceImpl; | ||
import org.hyperledger.besu.ethereum.chain.Blockchain; | ||
import org.hyperledger.besu.plugin.services.metrics.IbftQueryService; | ||
import org.hyperledger.besu.services.BesuPluginContextImpl; | ||
|
||
public class IbftQueryFactory implements PluginServiceFactory { | ||
|
||
final Blockchain blockchain; | ||
|
||
public IbftQueryFactory(final Blockchain blockchain) { | ||
this.blockchain = blockchain; | ||
} | ||
|
||
@Override | ||
public void appendQueries(final BesuPluginContextImpl besuContext) { | ||
final BlockInterface blockInterface = new IbftBlockInterface(); | ||
|
||
besuContext.addService( | ||
IbftQueryService.class, new IbftQueryServiceImpl(blockInterface, blockchain)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should register the one implementation instance of This ensures users who are currently using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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 | ||
* | ||
* 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.controller; | ||
|
||
import org.hyperledger.besu.services.BesuPluginContextImpl; | ||
|
||
public class NoopPluginServiceFactory implements PluginServiceFactory { | ||
|
||
@Override | ||
public void appendQueries(final BesuPluginContextImpl besuContext) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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 | ||
* | ||
* 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.controller; | ||
|
||
import org.hyperledger.besu.services.BesuPluginContextImpl; | ||
|
||
public interface PluginServiceFactory { | ||
|
||
void appendQueries(BesuPluginContextImpl besuContext); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,17 @@ | |
import org.hyperledger.besu.ethereum.chain.Blockchain; | ||
import org.hyperledger.besu.plugin.data.Address; | ||
import org.hyperledger.besu.plugin.data.BlockHeader; | ||
import org.hyperledger.besu.plugin.services.metrics.PoAMetricsService; | ||
import org.hyperledger.besu.plugin.services.metrics.PoaQueryService; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class PoAMetricServiceImpl implements PoAMetricsService { | ||
public class PoaQueryServiceImpl implements PoaQueryService { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also implement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
private final BlockInterface blockInterface; | ||
private final Blockchain blockchain; | ||
|
||
public PoAMetricServiceImpl(final BlockInterface blockInterface, final Blockchain blockchain) { | ||
public PoaQueryServiceImpl(final BlockInterface blockInterface, final Blockchain blockchain) { | ||
this.blockInterface = blockInterface; | ||
this.blockchain = blockchain; | ||
} | ||
|
@@ -41,4 +41,8 @@ public Collection<Address> getValidatorsForLatestBlock() { | |
public Address getProposerOfBlock(final BlockHeader header) { | ||
return this.blockInterface.getProposerOfBlock(header); | ||
} | ||
|
||
protected Blockchain getBlockchain() { | ||
return blockchain; | ||
} | ||
} |
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.
We should register the one implementation instance of
PoaQueryServiceImpl
under bothPoaQueryService
andPoaMetricsService
to preserve backwards compatibility.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.
done