Skip to content

Commit

Permalink
perf: don't copy envelope contents
Browse files Browse the repository at this point in the history
  • Loading branch information
emschwartz committed Nov 1, 2018
1 parent 56cc86f commit 1df2422
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/ilp-packet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const errorToReject = (address: string, error: IlpErrorClass) => {
})
}

export const serializeEnvelope = (type: number, contents: Buffer) => {
export const serializeEnvelope = (type: number, contents: Writer) => {
const writer = new Writer()
writer.writeUInt8(type)
writer.writeVarOctetString(contents)
Expand Down Expand Up @@ -77,7 +77,7 @@ export const serializeIlpPrepare = (json: IlpPrepare) => {
writer.writeVarOctetString(Buffer.from(json.destination, 'ascii'))
writer.writeVarOctetString(json.data)

return serializeEnvelope(Type.TYPE_ILP_PREPARE, writer.getBuffer())
return serializeEnvelope(Type.TYPE_ILP_PREPARE, writer)
}

export const deserializeIlpPrepare = (binary: Buffer): IlpPrepare => {
Expand Down Expand Up @@ -119,7 +119,7 @@ export const serializeIlpFulfill = (json: IlpFulfill) => {
writer.write(json.fulfillment)
writer.writeVarOctetString(json.data)

return serializeEnvelope(Type.TYPE_ILP_FULFILL, writer.getBuffer())
return serializeEnvelope(Type.TYPE_ILP_FULFILL, writer)
}

export const deserializeIlpFulfill = (binary: Buffer): IlpFulfill => {
Expand Down Expand Up @@ -167,7 +167,7 @@ export const serializeIlpReject = (json: IlpReject) => {
writer.writeVarOctetString(Buffer.from(json.message, 'utf8'))
writer.writeVarOctetString(json.data || Buffer.alloc(0))

return serializeEnvelope(Type.TYPE_ILP_REJECT, writer.getBuffer())
return serializeEnvelope(Type.TYPE_ILP_REJECT, writer)
}

export const deserializeIlpReject = (binary: Buffer): IlpReject => {
Expand Down
6 changes: 3 additions & 3 deletions packages/ilp-packet/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ilp-packet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"dependencies": {
"extensible-error": "^1.0.2",
"long": "^4.0.0",
"oer-utils": "^3.1.1"
"oer-utils": "^3.2.0"
}
}

0 comments on commit 1df2422

Please sign in to comment.