Skip to content

Commit

Permalink
implement pendingExtrinsics (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci authored Dec 20, 2022
1 parent 0456a23 commit 4bbb211
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/blockchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export class Blockchain {
return this.#head
}

get pendingExtrinsics(): HexString[] {
return this.#txpool.pendingExtrinsics
}

async getBlockAt(number?: number): Promise<Block | undefined> {
if (number === undefined) {
return this.head
Expand Down
4 changes: 4 additions & 0 deletions src/blockchain/txpool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class TxPool {
this.#inherentProvider = inherentProvider
}

get pendingExtrinsics(): HexString[] {
return this.#pool
}

submitExtrinsic(extrinsic: HexString) {
this.#pool.push(extrinsic)

Expand Down
4 changes: 3 additions & 1 deletion src/rpc/substrate/author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const handlers: Handlers = {
author_unwatchExtrinsic: async (_context, [subid], { unsubscribe }) => {
unsubscribe(subid)
},
author_pendingExtrinsics: async (_context) => [],
author_pendingExtrinsics: async (context) => {
return context.chain.pendingExtrinsics
},
}

export default handlers

0 comments on commit 4bbb211

Please sign in to comment.