forked from massalabs/massa
-
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.
Modify the network into new interface
Old: ReceiveOperations New: Operations: receive/send asked operation OperationBatch: receive/send operations ids (batch) AskOperation: receive/send require operations by ids
- Loading branch information
1 parent
f127d6d
commit 038cb5f
Showing
14 changed files
with
663 additions
and
339 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
// Copyright (c) 2022 MASSA LABS <[email protected]> | ||
|
||
use crate::constants::{ADDRESS_SIZE_BYTES, OPERATION_ID_SIZE_BYTES}; | ||
use crate::prehash::{PreHashed, Set}; | ||
use crate::signed::{Id, Signable, Signed}; | ||
use crate::{ | ||
constants::{ADDRESS_SIZE_BYTES, OPERATION_ID_SIZE_BYTES}, | ||
node::NodeId, | ||
}; | ||
use crate::{ | ||
serialization::{ | ||
array_from_slice, DeserializeCompact, DeserializeVarInt, SerializeCompact, SerializeVarInt, | ||
|
@@ -478,6 +481,14 @@ impl Operation { | |
} | ||
} | ||
|
||
/// Data structure forwarded in the network after asking [Operation]. | ||
/// Option is None if the asked node hasn't the operation. | ||
pub type AskedOperations = std::collections::HashMap<OperationId, Option<SignedOperation>>; | ||
/// Internal data structure describing the [Operation] we do want from which `NodeId`. | ||
pub type WantOperations = std::collections::HashMap<NodeId, Vec<OperationId>>; | ||
/// Same as wanted operation but used to propagate `OperationId` through `NodeId` | ||
pub type OperationBatches = std::collections::HashMap<NodeId, Vec<OperationId>>; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
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
Oops, something went wrong.