Skip to content

Commit

Permalink
Add noteSize and noteCommitment to getBlock RPC (#3665)
Browse files Browse the repository at this point in the history
  • Loading branch information
danield9tqh authored Mar 17, 2023
1 parent 8b76569 commit efc65f2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ironfish/src/rpc/routes/chain/getBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type GetBlockResponse = {
previousBlockHash: string
sequence: number
timestamp: number
noteSize: number
noteCommitment: string
transactions: Array<{
fee: string
hash: string
Expand Down Expand Up @@ -57,6 +59,8 @@ export const GetBlockResponseSchema: yup.ObjectSchema<GetBlockResponse> = yup
previousBlockHash: yup.string().defined(),
sequence: yup.number().defined(),
timestamp: yup.number().defined(),
noteSize: yup.number().defined(),
noteCommitment: yup.string().defined(),
transactions: yup
.array(
yup
Expand Down Expand Up @@ -124,6 +128,10 @@ router.register<typeof GetBlockRequestSchema, GetBlockResponse>(
throw new ValidationError(error)
}

if (header.noteSize === null) {
throw new ValidationError('Block header was saved to database without a note size')
}

const block = await node.chain.getBlock(header)
if (!block) {
throw new ValidationError(`No block with header ${header.hash.toString('hex')}`)
Expand Down Expand Up @@ -154,6 +162,8 @@ router.register<typeof GetBlockRequestSchema, GetBlockResponse>(
previousBlockHash: header.previousBlockHash.toString('hex'),
sequence: Number(header.sequence),
timestamp: header.timestamp.valueOf(),
noteSize: header.noteSize,
noteCommitment: header.noteCommitment.toString('hex'),
transactions: transactions,
},
metadata: {
Expand Down

0 comments on commit efc65f2

Please sign in to comment.