Skip to content

Commit

Permalink
Use serde_bytes for binary data in EventRecord and OracleResponse. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
afck authored Nov 14, 2024
1 parent 143a051 commit a93d4ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
12 changes: 10 additions & 2 deletions linera-base/src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,17 @@ impl ApplicationPermissions {
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
pub enum OracleResponse {
/// The response from a service query.
Service(#[debug(with = "hex_debug")] Vec<u8>),
Service(
#[debug(with = "hex_debug")]
#[serde(with = "serde_bytes")]
Vec<u8>,
),
/// The response from an HTTP POST request.
Post(#[debug(with = "hex_debug")] Vec<u8>),
Post(
#[debug(with = "hex_debug")]
#[serde(with = "serde_bytes")]
Vec<u8>,
),
/// A successful read or write of a blob.
Blob(BlobId),
/// An assertion oracle that passed.
Expand Down
2 changes: 2 additions & 0 deletions linera-chain/src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,11 @@ pub struct EventRecord {
pub stream_id: StreamId,
/// The event key.
#[debug(with = "hex_debug")]
#[serde(with = "serde_bytes")]
pub key: Vec<u8>,
/// The payload data.
#[debug(with = "hex_debug")]
#[serde(with = "serde_bytes")]
pub value: Vec<u8>,
}

Expand Down
12 changes: 4 additions & 8 deletions linera-rpc/tests/snapshots/format__format.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,8 @@ EventRecord:
STRUCT:
- stream_id:
TYPENAME: StreamId
- key:
SEQ: U8
- value:
SEQ: U8
- key: BYTES
- value: BYTES
ExecutedBlock:
STRUCT:
- block:
Expand Down Expand Up @@ -635,12 +633,10 @@ OracleResponse:
ENUM:
0:
Service:
NEWTYPE:
SEQ: U8
NEWTYPE: BYTES
1:
Post:
NEWTYPE:
SEQ: U8
NEWTYPE: BYTES
2:
Blob:
NEWTYPE:
Expand Down

0 comments on commit a93d4ea

Please sign in to comment.