From a33502c108148a06efd410b7c113b21c5ab07864 Mon Sep 17 00:00:00 2001 From: Yoni <svechinskyy@gmail.com> Date: Wed, 30 Jan 2019 10:19:41 +0200 Subject: [PATCH 1/4] Add a slate version field --- core/src/libtx/slate.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/libtx/slate.rs b/core/src/libtx/slate.rs index c1ab36c60..ca10f40db 100644 --- a/core/src/libtx/slate.rs +++ b/core/src/libtx/slate.rs @@ -92,6 +92,8 @@ pub struct Slate { /// insert their public data here. For now, 0 is sender and 1 /// is receiver, though this will change for multi-party pub participant_data: Vec<ParticipantData>, + /// Slate format version + pub version: Option<u64>, } impl Slate { @@ -106,6 +108,7 @@ impl Slate { height: 0, lock_height: 0, participant_data: vec![], + version:Some(1) } } From 99dda19f5e0c61bca314b036b259dd53f6d8d3d7 Mon Sep 17 00:00:00 2001 From: Yoni <svechinskyy@gmail.com> Date: Wed, 30 Jan 2019 10:19:52 +0200 Subject: [PATCH 2/4] rustfmt --- core/src/libtx/slate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/libtx/slate.rs b/core/src/libtx/slate.rs index ca10f40db..f03225e06 100644 --- a/core/src/libtx/slate.rs +++ b/core/src/libtx/slate.rs @@ -108,7 +108,7 @@ impl Slate { height: 0, lock_height: 0, participant_data: vec![], - version:Some(1) + version: Some(1), } } From 569d7a322051bd1ad0e5666d165f44e12e0f7006 Mon Sep 17 00:00:00 2001 From: Yoni <svechinskyy@gmail.com> Date: Wed, 30 Jan 2019 10:26:23 +0200 Subject: [PATCH 3/4] Move current slate version to constant --- core/src/libtx/slate.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/libtx/slate.rs b/core/src/libtx/slate.rs index f03225e06..32ee3cf28 100644 --- a/core/src/libtx/slate.rs +++ b/core/src/libtx/slate.rs @@ -31,6 +31,8 @@ use rand::thread_rng; use std::sync::Arc; use uuid::Uuid; +const CURRENT_SLATE_VERSION: u64 = 1; + /// Public data for each participant in the slate #[derive(Serialize, Deserialize, Debug, Clone)] @@ -108,7 +110,7 @@ impl Slate { height: 0, lock_height: 0, participant_data: vec![], - version: Some(1), + version: Some(CURRENT_SLATE_VERSION), } } From 1f7d3c6dc755c94b95e755ea91bf5a8930fce39c Mon Sep 17 00:00:00 2001 From: Yoni <svechinskyy@gmail.com> Date: Thu, 31 Jan 2019 16:25:57 +0200 Subject: [PATCH 4/4] - Change slate version to uint - Add default 0 incase it's missing (pre-versioning) --- core/src/libtx/slate.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/libtx/slate.rs b/core/src/libtx/slate.rs index e6bb7090b..85d91bef5 100644 --- a/core/src/libtx/slate.rs +++ b/core/src/libtx/slate.rs @@ -122,7 +122,12 @@ pub struct Slate { /// is receiver, though this will change for multi-party pub participant_data: Vec<ParticipantData>, /// Slate format version - pub version: Option<u64>, + #[serde(default = "no_version")] + pub version: u64, +} + +fn no_version() -> u64 { + 0 } /// Helper just to facilitate serialization @@ -144,7 +149,7 @@ impl Slate { height: 0, lock_height: 0, participant_data: vec![], - version: Some(CURRENT_SLATE_VERSION), + version: CURRENT_SLATE_VERSION, } }