Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtl: remove stringify from db logic + more overflow protection #1010

Merged
merged 4 commits into from
Jun 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions packages/data-transport-layer/src/db/transport-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,38 +379,14 @@ export class TransportDB {
if (index === null) {
return null
}
let entry = await this.db.get<TEntry>(`${key}:index`, index)
entry = stringify(entry)
return entry
return this.db.get<TEntry>(`${key}:index`, index)
}

private async _getEntries<TEntry extends Indexed>(
key: string,
startIndex: number,
endIndex: number
): Promise<TEntry[] | []> {
const entries = await this.db.range<TEntry>(
`${key}:index`,
startIndex,
endIndex
)
const results = []
for (const entry of entries) {
results.push(stringify(entry))
}
return results
}
}

function stringify(entry) {
if (entry === null || entry === undefined) {
return entry
}
if (entry.gasLimit) {
entry.gasLimit = BigNumber.from(entry.gasLimit).toString()
}
if (entry.decoded) {
entry.decoded.gasLimit = BigNumber.from(entry.decoded.gasLimit).toString()
return this.db.range<TEntry>(`${key}:index`, startIndex, endIndex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got confused here but realized that this was meant to target regenesis/0.4.0. Which is perfectly fine. LGTM!

}
return entry
}