From 0c8f9b372921e1aa37a94b40ac35181b5583a831 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 25 Jul 2019 04:29:07 -1100 Subject: [PATCH 1/9] Add version field --- src/komodo_nSPV.h | 1 + src/komodo_nSPV_defs.h | 2 ++ src/komodo_nSPV_fullnode.h | 1 + src/komodo_nSPV_superlite.h | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 9b23cb018..f88afd6c1 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -286,6 +286,7 @@ int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight); len += NSPV_rwequihdr(rwflag,&serialized[len],&ptr->H); + len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->version),&ptr->version); //fprintf(stderr,"hdr rwlen.%d\n",len); return(len); } diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index 8eeed8292..a27af170b 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -17,6 +17,7 @@ #ifndef KOMODO_NSPV_DEFSH #define KOMODO_NSPV_DEFSH +#define NSPV_PROTOCOL_VERSION 0x0001 #define NSPV_POLLITERS 100 #define NSPV_POLLMICROS 30000 #define NSPV_MAXVINS 64 @@ -124,6 +125,7 @@ struct NSPV_inforesp uint256 blockhash; int32_t height,hdrheight; struct NSPV_equihdr H; + uint32_t version; }; struct NSPV_txproof diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 5e4ec0b25..897762c3a 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -133,6 +133,7 @@ int32_t NSPV_getinfo(struct NSPV_inforesp *ptr,int32_t reqheight) if ( reqheight == 0 ) reqheight = ptr->height; ptr->hdrheight = reqheight; + ptr->version = NSPV_PROTOCOL_VERSION; if ( NSPV_setequihdr(&ptr->H,reqheight) < 0 ) return(-1); return(sizeof(*ptr)); diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index d7f11c41b..316a51e45 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -139,7 +139,7 @@ void komodo_nSPVresp(CNode *pfrom,std::vector response) // received a r switch ( response[0] ) { case NSPV_INFORESP: - //fprintf(stderr,"got info response %u size.%d height.%d\n",timestamp,(int32_t)response.size(),NSPV_inforesult.height); // update current height and ntrz status + fprintf(stderr,"got version.%d info response %u size.%d height.%d\n",NSPV_inforesult.version,timestamp,(int32_t)response.size(),NSPV_inforesult.height); // update current height and ntrz status I = NSPV_inforesult; NSPV_inforesp_purge(&NSPV_inforesult); NSPV_rwinforesp(0,&response[1],&NSPV_inforesult); From fdf6f610f9201cef20cff2734b4e14977ed8c868 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 25 Jul 2019 04:34:57 -1100 Subject: [PATCH 2/9] Add version to netinfo --- src/komodo_nSPV_superlite.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index 316a51e45..2babc69a7 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -370,6 +370,7 @@ UniValue NSPV_getinfo_json(struct NSPV_inforesp *ptr) result.push_back(Pair("chaintip",ptr->blockhash.GetHex())); result.push_back(Pair("notarization",NSPV_ntz_json(&ptr->notarization))); result.push_back(Pair("header",NSPV_header_json(&ptr->H,ptr->hdrheight))); + result.push_back(Pair("protocolversion",ptr->version)); result.push_back(Pair("lastpeer",NSPV_lastpeer)); return(result); } From 71610bb2661b74cab2c4fa022cb9e3db9a23a42a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 25 Jul 2019 04:47:23 -1100 Subject: [PATCH 3/9] Version --- src/komodo_nSPV_fullnode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 897762c3a..424a7ce89 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -538,7 +538,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req { response.resize(1 + slen); response[0] = NSPV_INFORESP; - //fprintf(stderr,"slen.%d\n",slen); + fprintf(stderr,"version.%d\n",I.version); if ( NSPV_rwinforesp(1,&response[1],&I) == slen ) { //fprintf(stderr,"send info resp to id %d\n",(int32_t)pfrom->id); From fe89e15065de2dc70d8e2be4e76979ed4816f022 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 25 Jul 2019 04:47:51 -1100 Subject: [PATCH 4/9] Test --- src/komodo_nSPV_superlite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index 2babc69a7..24ceeb6b8 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -370,7 +370,7 @@ UniValue NSPV_getinfo_json(struct NSPV_inforesp *ptr) result.push_back(Pair("chaintip",ptr->blockhash.GetHex())); result.push_back(Pair("notarization",NSPV_ntz_json(&ptr->notarization))); result.push_back(Pair("header",NSPV_header_json(&ptr->H,ptr->hdrheight))); - result.push_back(Pair("protocolversion",ptr->version)); + result.push_back(Pair("protocolversion",(int64_t)ptr->version)); result.push_back(Pair("lastpeer",NSPV_lastpeer)); return(result); } From 8d37c1e4d19f3b41dca04024a9e6ad9963208f37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 25 Jul 2019 04:48:49 -1100 Subject: [PATCH 5/9] -print --- src/komodo_nSPV_fullnode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 424a7ce89..8dbf40d68 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -538,7 +538,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req { response.resize(1 + slen); response[0] = NSPV_INFORESP; - fprintf(stderr,"version.%d\n",I.version); + //fprintf(stderr,"version.%d\n",I.version); if ( NSPV_rwinforesp(1,&response[1],&I) == slen ) { //fprintf(stderr,"send info resp to id %d\n",(int32_t)pfrom->id); From 40cb65a9370426cac28ee4d34c54a2483ca55063 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 25 Jul 2019 04:52:45 -1100 Subject: [PATCH 6/9] Getoinfo --- src/komodo_nSPV.h | 2 +- src/komodo_nSPV_fullnode.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index f88afd6c1..8c65dc772 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -287,7 +287,7 @@ int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight); len += NSPV_rwequihdr(rwflag,&serialized[len],&ptr->H); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->version),&ptr->version); -//fprintf(stderr,"hdr rwlen.%d\n",len); +fprintf(stderr,"getinfo rwlen.%d\n",len); return(len); } diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 8dbf40d68..d5e741ebf 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -538,10 +538,10 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req { response.resize(1 + slen); response[0] = NSPV_INFORESP; - //fprintf(stderr,"version.%d\n",I.version); + fprintf(stderr,"slen.%d version.%d\n",slen,I.version); if ( NSPV_rwinforesp(1,&response[1],&I) == slen ) { - //fprintf(stderr,"send info resp to id %d\n",(int32_t)pfrom->id); + fprintf(stderr,"send info resp to id %d\n",(int32_t)pfrom->id); pfrom->PushMessage("nSPV",response); pfrom->prevtimes[ind] = timestamp; } From a62de7f72b4e57b1903938c679af58ed4e86222e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 25 Jul 2019 04:56:21 -1100 Subject: [PATCH 7/9] -print --- src/komodo_nSPV.h | 2 +- src/komodo_nSPV_fullnode.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 8c65dc772..4695133c7 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -287,7 +287,7 @@ int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight); len += NSPV_rwequihdr(rwflag,&serialized[len],&ptr->H); len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->version),&ptr->version); -fprintf(stderr,"getinfo rwlen.%d\n",len); +//fprintf(stderr,"getinfo rwlen.%d\n",len); return(len); } diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index d5e741ebf..ff3156f37 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -538,10 +538,10 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req { response.resize(1 + slen); response[0] = NSPV_INFORESP; - fprintf(stderr,"slen.%d version.%d\n",slen,I.version); + //fprintf(stderr,"slen.%d version.%d\n",slen,I.version); if ( NSPV_rwinforesp(1,&response[1],&I) == slen ) { - fprintf(stderr,"send info resp to id %d\n",(int32_t)pfrom->id); + //fprintf(stderr,"send info resp to id %d\n",(int32_t)pfrom->id); pfrom->PushMessage("nSPV",response); pfrom->prevtimes[ind] = timestamp; } From 4642c0809447e01b969ccce0dce0b9d7c6161634 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 28 Jul 2019 06:10:57 -1100 Subject: [PATCH 8/9] Update nspv version --- src/komodo_nSPV_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_defs.h b/src/komodo_nSPV_defs.h index bcefcbc95..282e58cab 100644 --- a/src/komodo_nSPV_defs.h +++ b/src/komodo_nSPV_defs.h @@ -17,7 +17,7 @@ #ifndef KOMODO_NSPV_DEFSH #define KOMODO_NSPV_DEFSH -#define NSPV_PROTOCOL_VERSION 0x0001 +#define NSPV_PROTOCOL_VERSION 0x00000002 #define NSPV_POLLITERS 100 #define NSPV_POLLMICROS 30000 #define NSPV_MAXVINS 64 From 21c8e021475eff8eb3a5bc8478b0c5ffac75c645 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 28 Jul 2019 06:31:53 -1100 Subject: [PATCH 9/9] -print --- src/komodo_nSPV_fullnode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 50f0f8c56..30b11ecb5 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -132,7 +132,7 @@ int32_t NSPV_getinfo(struct NSPV_inforesp *ptr,int32_t reqheight) ptr->notarization = pair.prevntz; if ( (pindex2= komodo_chainactive(ptr->notarization.txidheight)) != 0 ) ptr->notarization.timestamp = pindex->nTime; - fprintf(stderr, "timestamp.%i\n", ptr->notarization.timestamp ); + //fprintf(stderr, "timestamp.%i\n", ptr->notarization.timestamp ); if ( reqheight == 0 ) reqheight = ptr->height; ptr->hdrheight = reqheight;