Skip to content
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

feat(core-api): getConsensusAlgorithmFamily() on connector API #415

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
],
"components": {
"schemas": {
"ConsensusAlgorithmFamily": {
"type": "string",
"description": "Enumerates a list of consensus algorithm families in existence. Does not intend to be an exhaustive list, just a practical one, meaning that we only include items here that are relevant to Hyperledger Cactus in fulfilling its own duties. This can be extended later as more sophisticated features of Cactus get implemented. This enum is meant to be first and foremest a useful abstraction for achieving practical tasks, not an encyclopedia and therefore we ask of everyone that this to be extended only in ways that serve a practical purpose for the runtime behavior of Cactus or Cactus plugins in general. The bottom line is that we can accept this enum being not 100% accurate as long as it 100% satisfies what it was designed to do.",
"enum": [
"org.hyperledger.cactus.consensusalgorithm.PROOF_OF_AUTHORITY",
"org.hyperledger.cactus.consensusalgorithm.PROOF_OF_STAKE",
"org.hyperledger.cactus.consensusalgorithm.PROOF_OF_WORK"
]
},
"PrimaryKey": {
"type": "string",
"minLength": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ export interface CactusNodeMeta {
*/
publicKeyPem: string;
}
/**
* Enumerates a list of consensus algorithm families in existence. Does not intend to be an exhaustive list, just a practical one, meaning that we only include items here that are relevant to Hyperledger Cactus in fulfilling its own duties. This can be extended later as more sophisticated features of Cactus get implemented. This enum is meant to be first and foremest a useful abstraction for achieving practical tasks, not an encyclopedia and therefore we ask of everyone that this to be extended only in ways that serve a practical purpose for the runtime behavior of Cactus or Cactus plugins in general. The bottom line is that we can accept this enum being not 100% accurate as long as it 100% satisfies what it was designed to do.
* @export
* @enum {string}
*/
export enum ConsensusAlgorithmFamily {
AUTHORITY = 'org.hyperledger.cactus.consensusalgorithm.PROOF_OF_AUTHORITY',
STAKE = 'org.hyperledger.cactus.consensusalgorithm.PROOF_OF_STAKE',
WORK = 'org.hyperledger.cactus.consensusalgorithm.PROOF_OF_WORK'
}

/**
*
* @export
Expand Down
22 changes: 22 additions & 0 deletions packages/cactus-core-api/src/main/typescript/openapi-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ export const CACTUS_OPEN_API_JSON: OpenAPIV3.Document = {
],
components: {
schemas: {
ConsensusAlgorithmFamily: {
type: "string",
description:
"Enumerates a list of consensus algorithm families in " +
"existence. Does not intend to be an exhaustive list, just a " +
"practical one, meaning that we only include items here that are " +
"relevant to Hyperledger Cactus in fulfilling its own duties. " +
"This can be extended later as more sophisticated features " +
"of Cactus get implemented. " +
"This enum is meant to be first and foremest a useful abstraction " +
"for achieving practical tasks, not an encyclopedia and therefore " +
"we ask of everyone that this to be extended only in ways that " +
"serve a practical purpose for the runtime behavior of Cactus or " +
"Cactus plugins in general. The bottom line is that we can accept " +
"this enum being not 100% accurate as long as it 100% satisfies " +
"what it was designed to do.",
enum: [
"org.hyperledger.cactus.consensusalgorithm.PROOF_OF_AUTHORITY",
"org.hyperledger.cactus.consensusalgorithm.PROOF_OF_STAKE",
"org.hyperledger.cactus.consensusalgorithm.PROOF_OF_WORK",
],
},
PrimaryKey: {
type: "string",
minLength: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ICactusPlugin } from "../i-cactus-plugin";
import { ConsensusAlgorithmFamily } from "../../generated/openapi/typescript-axios/api";

/**
* Common interface to be implemented by plugins which are implementing the connection to ledgers.
Expand All @@ -21,4 +22,12 @@ export interface IPluginLedgerConnector<
* type of ledger this connectir is targeted at.
*/
transact(options?: TransactIn): Promise<TransactOut>;

/**
* Returns the family of algorithms in which the consensus algorithm used
* by the ledger (this connector is associated with) belongs in.
*
* @see {ConsensusAlgorithmFamily}
*/
getConsensusAlgorithmFamily(): Promise<ConsensusAlgorithmFamily>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ContractSendMethod } from "web3-eth-contract";
import { TransactionReceipt } from "web3-eth";

import {
ConsensusAlgorithmFamily,
IPluginLedgerConnector,
IWebServiceEndpoint,
IPluginWebService,
Expand Down Expand Up @@ -168,6 +169,12 @@ export class PluginLedgerConnectorBesu
return PluginAspect.LEDGER_CONNECTOR;
}

public async getConsensusAlgorithmFamily(): Promise<
ConsensusAlgorithmFamily
> {
return ConsensusAlgorithmFamily.AUTHORITY;
}

public async invokeContract(
req: InvokeContractV1Request
): Promise<InvokeContractV1Response> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { Optional } from "typescript-optional";

import {
ConsensusAlgorithmFamily,
IPluginLedgerConnector,
PluginAspect,
IPluginWebService,
Expand Down Expand Up @@ -116,6 +117,12 @@ export class PluginLedgerConnectorFabric
return Optional.empty();
}

public async getConsensusAlgorithmFamily(): Promise<
ConsensusAlgorithmFamily
> {
return ConsensusAlgorithmFamily.AUTHORITY;
}

/**
* FIXME: Implement this feature of the connector.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ContractSendMethod } from "web3-eth-contract";
import { TransactionReceipt } from "web3-eth";

import {
ConsensusAlgorithmFamily,
IPluginLedgerConnector,
IWebServiceEndpoint,
IPluginWebService,
Expand Down Expand Up @@ -152,6 +153,12 @@ export class PluginLedgerConnectorQuorum
return PluginAspect.LEDGER_CONNECTOR;
}

public async getConsensusAlgorithmFamily(): Promise<
ConsensusAlgorithmFamily
> {
return ConsensusAlgorithmFamily.AUTHORITY;
}

public async invokeContract(
req: InvokeContractV1Request
): Promise<InvokeContractV1Response> {
Expand Down