Skip to content

Commit

Permalink
Get block works with ledgerHash or ledgerVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
micahriggan committed Nov 20, 2019
1 parent 741efbe commit 887b603
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/bitcore-node/src/modules/ripple/api/csp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export class RippleStateProvider extends InternalStateProvider implements CSP.IC

async getBlock(params: CSP.GetBlockParams) {
const client = await this.getClient(params.network);
const ledger = await client.getLedger({ includeTransactions: true, ledgerHash: params.blockId });
const isHash = params.blockId && params.blockId.length == 64;
const query = isHash ? { ledgerHash: params.blockId } : { ledgerVersion: Number(params.blockId) };
const ledger = await client.getLedger({ includeTransactions: true, ...query });
return this.transformLedger(ledger, params.network);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export declare namespace CSP {
getBalanceForAddress(
params: GetBalanceForAddressParams
): Promise<{ confirmed: number; unconfirmed: number; balance: number }>;
getBlock(params: GetBlockParams): Promise<any>;
getBlock(params: GetBlockParams): Promise<IBlock>;
getBlockBeforeTime(params: GetBlockBeforeTimeParams): Promise<IBlock>;
streamBlocks(params: StreamBlocksParams): any;
getFee(params: GetEstimateSmartFeeParams): any;
Expand Down

0 comments on commit 887b603

Please sign in to comment.