forked from casper-network/casper-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'casper-network:feat-2.0' into feat-2.0
- Loading branch information
Showing
12 changed files
with
119 additions
and
136 deletions.
There are no files selected for viewing
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
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,4 @@ | ||
//! Contains implementation of the gas reservation system | ||
mod reservation_kind; | ||
|
||
pub use reservation_kind::ReservationKind; |
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,42 @@ | ||
use crate::{ | ||
bytesrepr, | ||
bytesrepr::{Bytes, ToBytes, U8_SERIALIZED_LENGTH}, | ||
Digest, | ||
}; | ||
use alloc::vec::Vec; | ||
#[cfg(feature = "datasize")] | ||
use datasize::DataSize; | ||
#[cfg(feature = "json-schema")] | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Container for bytes recording location, type and data for a gas reservation | ||
#[derive(Eq, PartialEq, Debug, Clone, Serialize, Deserialize)] | ||
#[cfg_attr(feature = "datasize", derive(DataSize))] | ||
#[cfg_attr(feature = "json-schema", derive(JsonSchema))] | ||
pub struct ReservationKind { | ||
receipt: Digest, | ||
reservation_kind: u8, | ||
reservation_data: Bytes, | ||
} | ||
|
||
impl ToBytes for ReservationKind { | ||
fn to_bytes(&self) -> Result<Vec<u8>, bytesrepr::Error> { | ||
let mut buffer = bytesrepr::allocate_buffer(self)?; | ||
self.write_bytes(&mut buffer)?; | ||
Ok(buffer) | ||
} | ||
|
||
fn serialized_length(&self) -> usize { | ||
self.receipt.serialized_length() | ||
+ U8_SERIALIZED_LENGTH | ||
+ self.reservation_data.serialized_length() | ||
} | ||
|
||
fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), bytesrepr::Error> { | ||
self.receipt.write_bytes(writer)?; | ||
self.reservation_kind.write_bytes(writer)?; | ||
self.reservation_data.write_bytes(writer)?; | ||
Ok(()) | ||
} | ||
} |
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
Oops, something went wrong.