mirror of https://github.com/hyperledger/besu
add plugin API to enable plugins to validate transaction before they are added to the transaction pool
Signed-off-by: Stefan <stefan.pingel@consensys.net>TransactionValidatorService
parent
35385611ae
commit
b0b5cf91db
@ -0,0 +1,35 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* 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.services; |
||||
|
||||
import org.hyperledger.besu.plugin.services.TransactionValidatorService; |
||||
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionValidatorFactory; |
||||
|
||||
/** The Transaction Selection service implementation. */ |
||||
public class TransactionValidatorServiceImpl implements TransactionValidatorService { |
||||
|
||||
private PluginTransactionValidatorFactory factory; |
||||
|
||||
@Override |
||||
public PluginTransactionValidatorFactory get() { |
||||
return factory; |
||||
} |
||||
|
||||
@Override |
||||
public void registerTransactionValidatorFactory( |
||||
final PluginTransactionValidatorFactory transactionValidatorFactory) { |
||||
factory = transactionValidatorFactory; |
||||
} |
||||
} |
@ -0,0 +1,39 @@ |
||||
/* |
||||
* Copyright Hyperledger Besu Contributors. |
||||
* |
||||
* 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.plugin.services; |
||||
|
||||
import org.hyperledger.besu.plugin.Unstable; |
||||
import org.hyperledger.besu.plugin.services.txvalidator.PluginTransactionValidatorFactory; |
||||
|
||||
/** Transaction validator for addition of transactions to the transaction pool */ |
||||
@Unstable |
||||
public interface TransactionValidatorService extends BesuService { |
||||
|
||||
/** |
||||
* Returns the transaction validator factory |
||||
* |
||||
* @return the transaction validator factory |
||||
*/ |
||||
PluginTransactionValidatorFactory get(); |
||||
|
||||
/** |
||||
* Registers the transaction validator factory with the service |
||||
* |
||||
* @param transactionPoolFilterFactory transaction validator factory to be used |
||||
*/ |
||||
void registerTransactionValidatorFactory( |
||||
PluginTransactionValidatorFactory transactionPoolFilterFactory); |
||||
} |
@ -0,0 +1,33 @@ |
||||
/* |
||||
* Copyright Hyperledger Besu Contributors. |
||||
* |
||||
* 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.plugin.services.txvalidator; |
||||
|
||||
import org.hyperledger.besu.datatypes.Transaction; |
||||
import org.hyperledger.besu.plugin.Unstable; |
||||
|
||||
/** Interface for the transaction validator */ |
||||
@Unstable |
||||
public interface PluginTransactionValidator { |
||||
|
||||
/** |
||||
* Method called to decide whether a transaction can be added to the transaction pool. |
||||
* |
||||
* @param transaction candidate transaction |
||||
* @return true if the transaction can be added, false otherwise |
||||
*/ |
||||
boolean validateTransaction(final Transaction transaction); |
||||
; |
||||
} |
@ -0,0 +1,30 @@ |
||||
/* |
||||
* Copyright Hyperledger Besu Contributors. |
||||
* |
||||
* 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.plugin.services.txvalidator; |
||||
|
||||
import org.hyperledger.besu.plugin.Unstable; |
||||
|
||||
/** Interface for a factory that creates transaction validators */ |
||||
@Unstable |
||||
public interface PluginTransactionValidatorFactory { |
||||
|
||||
/** |
||||
* Create a transaction validator |
||||
* |
||||
* @return the transaction validator |
||||
*/ |
||||
PluginTransactionValidator create(); |
||||
} |
Loading…
Reference in new issue