Skip to content

Commit 182dc7b

Browse files
committed
lint fix
1 parent 19d78c0 commit 182dc7b

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

packages/synapse-core/src/piece/internal/hasher.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class Hasher {
4141

4242
/** Append bytes to the hasher. */
4343
write(bytes: Uint8Array): this {
44-
const { buffer, offset, layers } = this
44+
const { buffer, layers } = this
4545
const leaves = layers[0]
4646
const { length } = bytes
4747

@@ -51,16 +51,16 @@ export class Hasher {
5151
}
5252

5353
// Not enough for a quad yet: stash in the buffer.
54-
if (offset + length < buffer.length) {
55-
buffer.set(bytes, offset)
54+
if (this.offset + length < buffer.length) {
55+
buffer.set(bytes, this.offset)
5656
this.offset += length
5757
this.bytesWritten += BigInt(length)
5858
return this
5959
}
6060

6161
// Fill the buffer to complete a quad, then process whole quads from `bytes`.
62-
const bytesRequired = buffer.length - offset
63-
buffer.set(bytes.subarray(0, bytesRequired), offset)
62+
const bytesRequired = buffer.length - this.offset
63+
buffer.set(bytes.subarray(0, bytesRequired), this.offset)
6464
leaves.push(...split(fr32Expand(buffer)))
6565

6666
let readOffset = bytesRequired
@@ -88,14 +88,14 @@ export class Hasher {
8888
}
8989

9090
private digestInto(output: Uint8Array, byteOffset: number, asMultihash: boolean): number {
91-
const { buffer, layers, offset, bytesWritten } = this
91+
const { buffer, layers, bytesWritten } = this
9292

9393
// Snapshot the layers so we don't mutate hasher state.
9494
let [leaves, ...nodes] = layers
9595

9696
// If there's a partial quad in the buffer, zero-pad and absorb it.
97-
if (offset > 0 || bytesWritten === 0n) {
98-
leaves = [...leaves, ...split(fr32Expand(buffer.fill(0, offset)))]
97+
if (this.offset > 0 || bytesWritten === 0n) {
98+
leaves = [...leaves, ...split(fr32Expand(buffer.fill(0, this.offset)))]
9999
}
100100

101101
const tree = build([leaves, ...nodes])

packages/synapse-sdk/src/storage/context.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,7 @@ export class StorageContext {
938938

939939
return {
940940
txHash: addPiecesResult.txHash as Hex,
941-
...(confirmation.confirmedTxHash !== undefined
942-
? { confirmedTxHash: confirmation.confirmedTxHash }
943-
: {}),
941+
...(confirmation.confirmedTxHash === undefined ? {} : { confirmedTxHash: confirmation.confirmedTxHash }),
944942
pieceIds: confirmedPieceIds,
945943
dataSetId: this._dataSetId,
946944
isNewDataSet: false,
@@ -965,9 +963,7 @@ export class StorageContext {
965963

966964
return {
967965
txHash: result.txHash as Hex,
968-
...(confirmation.confirmedTxHash !== undefined
969-
? { confirmedTxHash: confirmation.confirmedTxHash as Hex }
970-
: {}),
966+
...(confirmation.confirmedTxHash === undefined ? {} : { confirmedTxHash: confirmation.confirmedTxHash as Hex }),
971967
pieceIds: confirmation.piecesIds,
972968
dataSetId: this._dataSetId,
973969
isNewDataSet: true,

packages/synapse-sdk/src/storage/terminate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export async function terminateServiceFlow(
9191
})
9292
return {
9393
txHash: status.terminationTxHash === '' ? undefined : status.terminationTxHash,
94-
...(status.confirmedTxHash !== undefined ? { confirmedTxHash: status.confirmedTxHash } : {}),
94+
...(status.confirmedTxHash === undefined ? {} : { confirmedTxHash: status.confirmedTxHash }),
9595
dataSetId,
9696
endEpoch: status.serviceTerminationEpoch,
9797
}
@@ -108,7 +108,7 @@ export async function terminateServiceFlow(
108108
const status = await waitForTerminateService({ statusUrl, onHash: onSubmitted })
109109
return {
110110
txHash: status.terminationTxHash === '' ? undefined : status.terminationTxHash,
111-
...(status.confirmedTxHash !== undefined ? { confirmedTxHash: status.confirmedTxHash } : {}),
111+
...(status.confirmedTxHash === undefined ? {} : { confirmedTxHash: status.confirmedTxHash }),
112112
dataSetId,
113113
endEpoch: status.serviceTerminationEpoch,
114114
}

0 commit comments

Comments
 (0)