/****************************************************************************** * Copyright © 2014-2016 The SuperNET Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright * * holder information and the developer policies on copyright and licensing. * * * * Unless otherwise agreed in a custom licensing agreement, no part of the * * SuperNET software, including this file may be copied, modified, propagated * * or distributed except according to the terms contained in the LICENSE file * * * * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ // included from gecko.c int32_t basilisk_respond_geckogetheaders(struct supernet_info *myinfo,struct iguana_info *virt,uint8_t *serialized,int32_t maxsize,cJSON *valsobj,bits256 hash2) { int32_t i,n,num,height,len=0; struct iguana_block *block; if ( (block= iguana_blockfind("geckohdr",virt,hash2)) != 0 ) { if ( (height= block->height) >= 0 ) { if ( (num= juint(valsobj,"num")) == 0 || num > virt->chain->bundlesize ) num = virt->chain->bundlesize; for (i=0; i 0 ) len += n; } hash2 = iguana_blockhash(virt,height+i+1); block = iguana_blockfind("geckohdri",virt,hash2); } return(len); } } return(-1); } void gecko_headerupdate(struct iguana_info *virt,bits256 hash2,int32_t height) { int32_t bundlei; struct iguana_bundle *bp; bits256 zero; memset(zero.bytes,0,sizeof(zero)); if ( (height % virt->chain->bundlesize) == 0 ) bp = iguana_bundlecreate(virt,&bundlei,height,hash2,zero,0); else if ( (bp= virt->bundles[height / virt->chain->bundlesize]) != 0 ) iguana_bundlehash2add(virt,0,bp,height % virt->chain->bundlesize,hash2); } char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 firsthash2) { bits256 hash2; struct iguana_block *block; int32_t firstheight,i,len=0,n; n = (int32_t)(datalen / sizeof(bits256)); char str[65]; printf("headers arrived.%d from %s\n",n,bits256_str(str,firsthash2)); if ( (block= iguana_blockfind("geckohdrs",virt,firsthash2)) != 0 && (firstheight= block->height) >= 0 ) { gecko_headerupdate(virt,firsthash2,firstheight); for (i=0; ibundles[hdrsi]) != 0 ) { vals = cJSON_CreateObject(); memset(zero.bytes,0,sizeof(zero)); jaddstr(vals,"symbol",virt->symbol); jaddstr(vals,"type","HDR"); if ( (retstr= basilisk_standardservice("GET",myinfo,bp->hashes[0],vals,0,0)) != 0 ) free(retstr); free_json(vals); } else printf("dont have bundle needed\n"); }