Skip to content

Commit 1b5fc89

Browse files
committed
fix(node): make session message decoding backwards-compatible
1 parent 9c3008e commit 1b5fc89

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

node/src/actors/session/handlers.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ use witnet_data_structures::{
1414
Block, CheckpointBeacon, Epoch, Hashable, InventoryEntry, InventoryItem, SuperBlock,
1515
SuperBlockVote,
1616
},
17-
proto::ProtobufConvert,
17+
proto::versioning::Versioned,
1818
transaction::Transaction,
1919
types::{
2020
Address, Command, InventoryAnnouncement, InventoryRequest, LastBeacon,
2121
Message as WitnetMessage, Peers, Version,
2222
},
2323
};
2424
use witnet_p2p::sessions::{SessionStatus, SessionType};
25+
use witnet_util::timestamp::get_timestamp;
2526

26-
use super::Session;
2727
use crate::actors::{
2828
chain_manager::ChainManager,
2929
inventory_manager::InventoryManager,
@@ -39,7 +39,7 @@ use crate::actors::{
3939
sessions_manager::SessionsManager,
4040
};
4141

42-
use witnet_util::timestamp::get_timestamp;
42+
use super::Session;
4343

4444
#[derive(Debug, Eq, Fail, PartialEq)]
4545
enum HandshakeError {
@@ -133,7 +133,7 @@ impl StreamHandler<Result<BytesMut, Error>> for Session {
133133
}
134134

135135
let bytes = res.unwrap();
136-
let result = WitnetMessage::from_pb_bytes(&bytes);
136+
let result = WitnetMessage::from_versioned_pb_bytes(&bytes);
137137

138138
match result {
139139
Err(err) => {
@@ -1105,9 +1105,10 @@ fn process_superblock_vote(_session: &mut Session, superblock_vote: SuperBlockVo
11051105

11061106
#[cfg(test)]
11071107
mod tests {
1108-
use super::*;
11091108
use witnet_data_structures::chain::Hash;
11101109

1110+
use super::*;
1111+
11111112
#[test]
11121113
fn handshake_bootstrap_before_epoch_zero() {
11131114
// Check that when the last beacon has epoch 0 and the current epoch is not 0,

0 commit comments

Comments
 (0)