From d1288b4e6ef9accc6fec412aa78373b3775b67d9 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 15 Sep 2012 04:20:34 +0000 Subject: [PATCH] Check block version for compatibility, honouring version/force and version/reduce mutations if allowed --- blkmaker_jansson.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/blkmaker_jansson.c b/blkmaker_jansson.c index 85c543d..faa4bc7 100644 --- a/blkmaker_jansson.c +++ b/blkmaker_jansson.c @@ -245,6 +245,15 @@ const char *blktmpl_add_jansson(blktemplate_t *tmpl, const json_t *json, time_t } } + if (tmpl->version > 2 || (tmpl->version == 2 && !tmpl->height)) + { + if (tmpl->mutations & BMM_VERDROP) + tmpl->version = tmpl->height ? 2 : 1; + else + if (!(tmpl->mutations & BMM_VERFORCE)) + return "Unrecognized block version, and not allowed to reduce or force it"; + } + tmpl->_time_rcvd = time_rcvd; return NULL;