-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [resource-viewer] Add metering to resource viewer * bump node version
- Loading branch information
1 parent
9caaaa3
commit a1cda42
Showing
7 changed files
with
183 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) The Move Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use move_binary_format::errors::{PartialVMError, PartialVMResult}; | ||
use move_core_types::vm_status::StatusCode; | ||
|
||
// Default limit set to 100mb per query. | ||
const DEFAULT_LIMIT: usize = 100_000_000; | ||
|
||
pub struct Limiter(usize); | ||
|
||
impl Limiter { | ||
pub fn charge(&mut self, cost: usize) -> PartialVMResult<()> { | ||
if self.0 < cost { | ||
return Err(PartialVMError::new(StatusCode::ABORTED) | ||
.with_message("Query exceeds size limit".to_string())); | ||
} | ||
self.0 -= cost; | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl Default for Limiter { | ||
fn default() -> Self { | ||
Limiter(DEFAULT_LIMIT) | ||
} | ||
} |
Oops, something went wrong.