[Tarantool-patches] [RAFT 04/10] [tosquash] raft: introduce IPROTO_RAFT_VCLOCK

Serge Petrenko sergepetrenko at tarantool.org
Wed Aug 26 10:52:36 MSK 2020


From: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>

IPROTO_RAFT keys are stored in their own isolated dictionary, so
no need to reuse other keys. Better implement the raft's own
keyset with IPROTO_RAFT_* keys.
---
 src/box/iproto_constants.h | 1 +
 src/box/xrow.c             | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h
index 4217ce2e0..3ec397d3c 100644
--- a/src/box/iproto_constants.h
+++ b/src/box/iproto_constants.h
@@ -264,6 +264,7 @@ enum iproto_raft_keys {
 	IPROTO_RAFT_TERM = 0,
 	IPROTO_RAFT_VOTE = 1,
 	IPROTO_RAFT_STATE = 2,
+	IPROTO_RAFT_VCLOCK = 3,
 };
 
 /**
diff --git a/src/box/xrow.c b/src/box/xrow.c
index ed3f77a15..836de3575 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -972,7 +972,7 @@ xrow_encode_raft(struct xrow_header *row, struct region *region,
 	size += (r->state != 0) * (mp_sizeof_uint(IPROTO_RAFT_STATE) +
 				   mp_sizeof_uint(r->state));
 	if (r->vclock != NULL) {
-		size += mp_sizeof_uint(IPROTO_VCLOCK) +
+		size += mp_sizeof_uint(IPROTO_RAFT_VCLOCK) +
 		mp_sizeof_vclock_ignore0(r->vclock);
 	}
 
@@ -999,7 +999,7 @@ xrow_encode_raft(struct xrow_header *row, struct region *region,
 		buf = mp_encode_uint(buf, r->state);
 	}
 	if (r->vclock != NULL) {
-		buf = mp_encode_uint(buf, IPROTO_VCLOCK);
+		buf = mp_encode_uint(buf, IPROTO_RAFT_VCLOCK);
 		buf = mp_encode_vclock_ignore0(buf, r->vclock);
 	}
 
@@ -1029,7 +1029,7 @@ xrow_decode_raft(const struct xrow_header *row, struct raft_request *r)
 		case IPROTO_RAFT_STATE:
 			r->state = mp_decode_uint(&pos);
 			break;
-		case IPROTO_VCLOCK:
+		case IPROTO_RAFT_VCLOCK:
 			if (r->vclock != NULL)
 				mp_decode_vclock_ignore0(&pos, r->vclock);
 			else
-- 
2.20.1 (Apple Git-117)



More information about the Tarantool-patches mailing list