获取星云节点数据

    技术2022-08-01  74

    public function get_xingyun(){ $data = ‘{“from”:“n1KSYoLoqen2bYmZvUC3JXT9TeXrAhkzrPy”,“to”:“n214bLrE3nREcpRewHXF7qRDWCcaxRSiUdw”,“value”:“0”,“gasPrice”:“20000000000”,“gasLimit”:“2000000”,“contract”:{“function”:“getNodeDetail”,“args”:"[“lk0001”]"}}’; $headerArray =array(“Content-type:application/json;charset=‘utf-8’”,“Accept:application/json”); c u r l = c u r l i n i t ( ) ; c u r l s e t o p t ( curl = curl_init(); curl_setopt( curl=curlinit();curlsetopt(curl, CURLOPT_URL,‘https://mainnet.nebulas.io/v1/user/call’); curl_setopt( c u r l , C U R L O P T S S L V E R I F Y P E E R , F A L S E ) ; c u r l s e t o p t ( curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt( curl,CURLOPTSSLVERIFYPEER,FALSE);curlsetopt(curl, CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt( c u r l , C U R L O P T P O S T , 1 ) ; c u r l s e t o p t ( curl, CURLOPT_POST, 1); curl_setopt( curl,CURLOPTPOST,1);curlsetopt(curl, CURLOPT_POSTFIELDS, d a t a ) ; c u r l s e t o p t ( data); curl_setopt( data);curlsetopt(curl,CURLOPT_HTTPHEADER, h e a d e r A r r a y ) ; c u r l s e t o p t ( headerArray); curl_setopt( headerArray);curlsetopt(curl, CURLOPT_RETURNTRANSFER, 1); o u t p u t = c u r l e x e c ( output = curl_exec( output=curlexec(curl); curl_close($curl); a = j s o n d e c o d e ( a= json_decode( a=jsondecode(output,true); r e s u l t = a r r a y c o l u m n ( result=array_column( result=arraycolumn(a,‘result’); b = j s o n d e c o d e ( b=json_decode( b=jsondecode(result[‘0’],true); d a t a = [ ′ v o t e V a l u e ′ = > data=[ 'voteValue'=> data=[voteValue=>b[‘voteValue’] / 1000000000, ‘blockCount’=> b [ ′ b l o c k C o u n t ′ ] , ′ b e c o m e C o n s e n s u s N o d e C o u n t ′ = > b['blockCount'], 'becomeConsensusNodeCount'=> b[blockCount],becomeConsensusNodeCount=>b[‘becomeConsensusNodeCount’], ‘rdate’=>date(“Y-m-d”), ‘rtime’=>time(), ]; $where[‘rdate’]=date(“Y-m-d”); r e e = M ( ′ x y n o d e d a y ′ ) − > w h e r e ( ree=M('xynodeday')->where( ree=M(xynodeday)>where(where)->find(); if ($ree) {

    }else{ $res=M('xynodeday')->add($data); if (!$res) { $data=[ //总票数 'voteValue'=>'失败', //逐步出块 'blockCount'=>'失败', //入选共识 'becomeConsensusNodeCount'=>'失败', 'rdate'=>date("Y-m-d"), 'rtime'=>time(), ]; $res=M('xynodeday')->add($data); } }

    }

    public function get_xingyunss(){ $data = '{"from":"n1KSYoLoqen2bYmZvUC3JXT9TeXrAhkzrPy","to":"n214bLrE3nREcpRewHXF7qRDWCcaxRSiUdw","value":"0","gasPrice":"20000000000","gasLimit":"2000000","contract":{"function":"getNodeVoteStatistic","args":"[\"lk0001\"]"}}'; $headerArray =array("Content-type:application/json;charset='utf-8'","Accept:application/json"); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,'https://mainnet.nebulas.io/v1/user/call'); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); //print_r($output);die; $a= json_decode($output,true); $result=array_column($a,'result'); $b=json_decode($result['0'],true); $where['rdate']=date('Y-m-d'); $jinday=M('xynodeday')->where($where)->find(); $wherezuo['rdate']=date("Y-m-d",strtotime("-1 day")); $zuoday=M('xynodeday')->where($wherezuo)->find(); //print_r($zuoday);die; if ($jinday&&$zuoday) { if ($value/1000000000 >500000&&$value/1000000000 < 1000000) { $b[$key]['is_chou']='4'; } if ($value/1000000000 >1000000) { $b[$key]['is_chou']='5'; } $b[$key]['uname']=date('Y-m-d').'用户'; } } } $whereadd['address']='n1ZciM6PYAkEjsXUfHCwYwW9gNWqU9AnXax'; $whereadd['rtime']=date('Y-m-d'); $ree=M('xyjd_copy')->where($whereadd)->find(); if ($ree) { echo date('Y-m-d H:i:s').'前已经执行';die; }else{ $res=M('xyjd_copy')->addAll($b); }

    }

    Processed: 0.010, SQL: 9