Blockchain has a very good coupling with the vertical field of content.Using the characteristics and technology of blockchain,there are more and more platforms for content.The competition in this track is extremely fierce.As far as I know,there are many,such as foreign steelit,domestic coin,coin,Primas,iveryone,pressone,etc.
DApp运行原理
DApp底层区块链开发平台就好比手机的iOS和Android系统,是各种DApp的底层生态环境,DApp就是底层区块链平台生态上衍生的各种分布式应用,本文由V_StPv888整理发布.也是区块链世界中的基础服务提供方,DApp于区块链,就好比APP之于iOS和Android。
int calPagerank()
{
cout<<nowTime()<<“:Begin calculate pagerank.”<<endl;
int oldIdx=0;
int newIdx=1;
int urlNum=urls.size();
for(int i=0;i<urlNum;i++)urls.score[oldIdx]=sum/urlNum;
for(int iteration=0;iteration<=10000;iteration++)
{
cout<<nowTime()<<“:iteration”<<iteration<<endl;
for(int i=0;i<urlNum;i++)
{
urls.score[newIdx]=0;
}
double perSum=0;
for(int i=0;i<urlNum;i++)
{
urls.score[newIdx]=sum*rem/urlNum;
if(urls.inDegree>0)
{
for(vector::iterator iter=urls.refList.begin();iter!=urls.refList.end();iter++)
{
int id=*iter;
urls.score[newIdx]+=(1-rem)*urls[id].score[oldIdx]/urls[id].outDegree;
}
}
perSum+=urls.score[newIdx];
}
for(int i=0;i<urlNum;i++)
{
urls.score[newIdx]=urls.score[newIdx]/perSum;
}
double dif=0;
for(int i=0;i<urlNum;i++)
{
dif+=abs(urls.score[newIdx]-urls.score[oldIdx]);
}
if(dif<bound)
{
break;
}
oldIdx=newIdx;
newIdx=1-oldIdx;
}
cout<<nowTime()<<“:Complete calculate pagerank.”<<endl;
return newIdx;
}
什么是智能合约?
如果把区块链看做是一个数据库,数据源,
智能合约基本上就是一段数据库操作脚本,
它决定了你如何在区块链上存储数据,修改数据。
void initUrl()
{
cout<<nowTime()<<“Begin init user.”<<endl;
ifstream in(mapPath.c_str());
string urlStr;
int id=0;
while(in>>urlStr)
{
if(urlStr.substr(urlStr.size()-4)“.css”||urlStr.substr(urlStr.size()-3)“.js”)
continue;
if(urlId.find(urlStr)==urlId.end())
{
urlId[urlStr]=id;
url newUrl;
newUrl.id=id;
newUrl.inDegree=0;
newUrl.outDegree=0;
newUrl.urlTxt=urlStr;
urls.push_back(newUrl);
id++;
}
}
in.close();
}
简介
智能合约是代码(它的功能)和数据(它的状态)的集合,存在于以太坊区块链的特定地址。智能合约账户能够在彼此之间传递信息,进行图灵完备的运算。智能合约依靠被称作以太坊虚拟机(EVM)字节代码(以太坊特有的二进制格式)上的区块链运行。
智能合约使用诸如Solidity等高级语言写成,然后编译成字节代码上传到区块链上。
void initNet()
{
cout<<nowTime()<<“:Begin init net.”<<endl;
ifstream in(mapPath.c_str());
string fromStr,toStr,rootStr;
in>>rootStr;
while(in>>fromStr>>toStr)
{
if(links.find(fromStr+“#”+toStr)!=links.end())continue;
else links.insert(fromStr+“#”+toStr);
if(fromStr.substr(fromStr.size()-4)“.css”||toStr.substr(toStr.size()-3)“.js”)
{
continue;
}
int from=urlId[fromStr];
int to=urlId[toStr];
urls[to].refList.push_back(from);
urls[to].inDegree++;
urls[from].outDegree++;
}
in.close();
cout<<nowTime()<<“:Complete init net.”<<endl;
}
智能合约开发流程大概有以下步骤:
编写智能合约(如基于solidity)
测试智能合约,在测试网络或者私有链进行合约的功能测试
编译和发布合约,将合约部署到链上
操作合约,利用诸如web3.js等接口,通过访问智能合约的地址,来调用和操作智能合约。
May you have enough happiness to make you sweet,enough trials to make you strong,enough sorrow to keep you human,enough hope to make you happy?Always put yourself in others’shoes.If you feel that it hurts you,it probably hurts the other person,too.
The happiest of people don’t necessarily have the best of everything;they just make the most of everything that comes along their way.Happiness lies for those who cry,those who hurt,those who have searched,and those who have tried,for only they can appreciate the importance of people
who have touched their lives.Love begins with a smile,grows with a kiss and ends with a tear.The brightest future will always be based on a forgotten past,you can’t go on well in lifeuntil you let go of your past failures and heartaches.
When you were born,you were crying and everyone around you was smiling.Live your life so that when you die,you’re the one who is smiling and everyone around you is crying.