Skip to content

Commit

Permalink
feat(core-api): getConsensusAlgorithmFamily() on connector API
Browse files Browse the repository at this point in the history
The method is called getConsensusAlgorithmFamily()
because we don't need (for now) the level of granularity
that is provided by having a method that points to the exact
algorithm used by the ledger (can be added later).
Why? Because for now we are mostly interested in whether an
algorithm family guarantees transaction finality or not and this
can be determined just from the family since for example it
does not make much of a difference if you are talking about
Bitcon's or Ethereum 1's proof of work, they both just do not
guarantee transaction finality the same way for all our intents
and purposes at present.

The added benefit of only dealing in families instead of specific
algorithms is that we can hardcode the answers instead of
having to query the ledger or rely on operators to provide
this information via configuration (again, we'll probably end
up needing this in the future anyway, but for the upcoming
work the families should be enough).

Fixes hyperledger#355

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Jan 5, 2021
1 parent 7206b85 commit 477dc7e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
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

0 comments on commit 477dc7e

Please sign in to comment.