区块链数据层包括底层数据区块、基础数据、算法等内容,数据层的创新改变数据结构,提升存储效率,降低存储空间。
数字货币交易所开发技术是一种去中心化的共识机制,来维护一个完整的、分布式的、不可篡改的账本数据库的技术。It can enable participants in the blockchain to achieve a unified ledger system without establishing trust relationships.
如果区块链是数据库,则智能合约是使区块链技术能够应用于现实世界的应用层。智能合约是在区块链数据库上运行的计算机程序,在满足其源代码中写入的条件时可以自己执行。
uint8 v2=uint8(body);
uint224 takerOrderKey=uint224(body>>8);
Order memory takerOrder;
if(v2==0){//order already in storage
takerOrder=orders[takerOrderKey];
i+=1;
}else{
if(orders[takerOrderKey].pairId!=0)revert();//order must not be already in storage
if(i+3>=body.length)revert();//at least 3 body elements left
takerOrder=parseNewOrder(takerOrderKey,v2,body,i);
i+=4;
}
matchOrder(uint224(bits)/makerOrderKey/,makerOrder,takerOrderKey,takerOrder);
continue;
}
//HardCancelOrder:<nonce>(64)<traderAddr>(160)
if(opcode==0xDE04){
hardCancelOrder(uint224(bits)/orderKey/);
i+=1;
continue;
}
//SetFeeRates:<withdrawFeeRateE4>(16)<takerFeeRateE4>(16)<makerFeeRateE4>(16)
if(opcode==0xDE05){
setFeeRates(uint16(bits),uint16(bits>>16),uint16(bits>>32));
i+=1;
continue;
}
//SetFeeRebatePercent:<rebatePercent>(8)<traderAddr>(160)
if(opcode==0xDE06){
setFeeRebatePercent(address(bits)/traderAddr/,uint8(bits>>160)/rebatePercent/);
i+=1;
continue;
}
}//for loop
setExeStatus(newLogicTimeSec,nextOperationIndex-1);
}//function exeSequence
//------------------------------Public Functions:-----------------------------------------------
//Set information of a token.
function setTokenInfo(uint16 tokenCode,string symbol,address tokenAddr,uint64 scaleFactor,
uint minDeposit)public{
if(msg.sender!=admin)revert();
if(marketStatus!=ACTIVE)revert();
if(scaleFactor==0)revert();
TokenInfo memory info=tokens[tokenCode];
if(info.scaleFactor!=0){//this token already exists
//For an existing token only the minDeposit field can be updated.
tokens[tokenCode].minDeposit=minDeposit;
emit SetTokenInfoEvent(tokenCode,info.symbol,info.tokenAddr,info.scaleFactor,minDeposit);
return;
}