fix: add getBlocksSince Connection method
This commit is contained in:
committed by
Michael Vines
parent
df886a7a40
commit
086eb6f8b8
@@ -365,6 +365,11 @@ const GetTotalSupplyRpcResult = jsonRpcResult('number');
|
||||
*/
|
||||
const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult('number');
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getBlocksSince" message
|
||||
*/
|
||||
const GetBlocksSinceRpcResult = jsonRpcResult(struct.list(['number']));
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getRecentBlockhash" message
|
||||
*/
|
||||
@@ -853,6 +858,19 @@ export class Connection {
|
||||
return res.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a list of rooted blocks from the cluster
|
||||
*/
|
||||
async getBlocksSince(slot: number): Promise<Array<number>> {
|
||||
const unsafeRes = await this._rpcRequest('getBlocksSince', [slot]);
|
||||
const res = GetBlocksSinceRpcResult(unsafeRes);
|
||||
if (res.error) {
|
||||
throw new Error(res.error.message);
|
||||
}
|
||||
assert(typeof res.result !== 'undefined');
|
||||
return res.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request an allocation of lamports to the specified account
|
||||
*/
|
||||
|
@@ -445,7 +445,7 @@ export class Transaction {
|
||||
const PUBKEY_LENGTH = 32;
|
||||
const SIGNATURE_LENGTH = 64;
|
||||
|
||||
function isCreditDebit(
|
||||
function isWritable(
|
||||
i: number,
|
||||
numRequiredSignatures: number,
|
||||
numReadonlySignedAccounts: number,
|
||||
@@ -530,7 +530,7 @@ export class Transaction {
|
||||
isSigner: transaction.signatures.some(
|
||||
keyObj => keyObj.publicKey.toString() === pubkey.toString(),
|
||||
),
|
||||
isWritable: isCreditDebit(
|
||||
isWritable: isWritable(
|
||||
j,
|
||||
numRequiredSignatures,
|
||||
numReadonlySignedAccounts,
|
||||
|
Reference in New Issue
Block a user