ProHoster > ΠΠ»ΠΎΠ³ > Kev tswj hwm > Yuav ua li cas ib tug decentralized tub txib ntawm lub blockchain ua hauj lwm?
Yuav ua li cas ib tug decentralized tub txib ntawm lub blockchain ua hauj lwm?
Thaum pib ntawm 2017, peb pib tsim ib tug neeg xa xov liaison ntawm blockchain [lub npe thiab txuas nyob rau hauv profile] los ntawm kev sib tham txog qhov zoo dua classic P2P tub txib.
Dhau 2.5 xyoo, thiab peb tuaj yeem lees paub peb lub tswv yim: cov ntawv thov xa xov tam sim no muaj rau iOS, Web PWA, Windows, GNU / Linux, Mac OS thiab Android.
Niaj hnub no peb yuav qhia koj seb tus neeg xa xov liaison blockchain ua haujlwm li cas thiab cov neeg siv khoom tuaj yeem ua haujlwm nrog nws API li cas.
Peb xav kom blockchain los daws qhov teeb meem kev nyab xeeb thiab kev ceev ntiag tug ntawm classic P2P tub txib:
Ib nias los tsim ib tus account - tsis muaj xov tooj lossis emails, tsis muaj kev nkag mus rau cov phau ntawv chaw nyob lossis chaw nyob.
Lub peev xwm kom tau txais tag nrho koj cov kev sib tham los ntawm ib lub cuab yeej txhua lub sijhawm txhais tau tias koj tsis tas yuav khaws cov kev sib tham hauv zos txhua lub sijhawm.
Kev lees paub ntawm kev xa xov. Tsis yog rau tus neeg siv lub cuab yeej, tab sis rau lub network. Qhov tseem ceeb, qhov no yog kev lees paub ntawm tus neeg tau txais kev muaj peev xwm nyeem koj cov lus. Qhov no yog qhov muaj txiaj ntsig zoo rau kev xa cov ntawv ceeb toom tseem ceeb.
Blockchain cov txiaj ntsig tseem suav nrog kev sib raug zoo nrog cov cryptocurrencies Ethereum, Dogecoin, Lisk, Dash, Bitcoin (qhov no tseem tab tom ua tiav) thiab muaj peev xwm xa cov tokens hauv kev sib tham. Peb txawm ua ib tug built-in crypto exchanger.
Thiab ces - yuav ua li cas nws tag nrho ua hauj lwm.
Ib qho lus yog kev lag luam
Txhua leej txhua tus twb tau siv rau qhov tseeb tias kev lag luam hauv blockchain hloov pauv tokens (npib) los ntawm ib tus neeg siv mus rau lwm tus. Zoo li Bitcoin. Peb tsim ib hom kev lag luam tshwj xeeb rau kev xa xov.
Txhawm rau xa cov lus hauv tus tub txib ntawm blockchain, koj yuav tsum mus dhau ob peb kauj ruam:
Encrypt cov ntawv nyeem
Muab ciphertext rau hauv kev sib pauv
Kos npe rau kev ua lag luam
Xa ib qho kev sib pauv mus rau txhua lub network node
Cov lus kuj tau muab faib ua hom. Qhov tseem ceeb, qhov parameter type qhia koj kom nkag siab message. Koj tuaj yeem xa cov ntawv xwb, lossis koj tuaj yeem xa cov khoom nrog cov khoom nthuav hauv - piv txwv li, qhov no yog li cas tus tub txib ua rau kev hloov pauv cryptocurrency hauv kev sib tham.
Txhawm rau kom ntseeg tau tias txhua tus neeg muaj kev ntseeg siab rau qhov tseeb ntawm tus neeg xa khoom thiab tus neeg tau txais txiaj ntsig, lub sijhawm xa thiab cov ntsiab lus ntawm cov lus, kev hloov pauv tau kos npe. Kev kos npe digital tso cai rau koj los txheeb xyuas qhov tseeb ntawm kev lag luam siv tus yuam sij pej xeem - tus yuam sij ntiag tug tsis xav tau rau qhov no.
Tab sis kos npe nws tus kheej yog ua los ntawm tus kheej tus yuam sij:
Daim duab qhia tau hais tias peb thawj zaug hash kev pauv nrog SHA-256 thiab tom qab ntawd kos npe rau nws 25519 EDDSA thiab tau kos npe signature, thiab tus lej ID yog ib feem ntawm SHA-256 hash.
Kev ua piv txwv:
1 - Tsim cov ntaub ntawv thaiv, suav nrog cov lus
/**
* Calls `getBytes` based on transaction type
* @see privateTypes
* @implements {ByteBuffer}
* @param {transaction} trs
* @param {boolean} skipSignature
* @param {boolean} skipSecondSignature
* @return {!Array} Contents as an ArrayBuffer.
* @throws {error} If buffer fails.
*/
adamant.getBytes = function (transaction) {
...
switch (transaction.type) {
case constants.Transactions.SEND:
break
case constants.Transactions.CHAT_MESSAGE:
assetBytes = this.chatGetBytes(transaction)
assetSize = assetBytes.length
break
β¦
default:
alert('Not supported yet')
}
var bb = new ByteBuffer(1 + 4 + 32 + 8 + 8 + 64 + 64 + assetSize, true)
bb.writeByte(transaction.type)
bb.writeInt(transaction.timestamp)
...
bb.flip()
var arrayBuffer = new Uint8Array(bb.toArrayBuffer())
var buffer = []
for (var i = 0; i < arrayBuffer.length; i++) {
buffer[i] = arrayBuffer[i]
}
return Buffer.from(buffer)
}
Txij li thaum cov lus raug xa mus rau hauv txoj kev no li ntawm 5 vib nas this - qhov no yog lub sijhawm tshiab network thaiv tshwm - peb tuaj nrog cov neeg siv khoom-rau-node thiab node-rau-node socket kev sib txuas. Thaum ib lub node tau txais kev hloov pauv tshiab, nws tshawb xyuas nws qhov siv tau thiab xa mus rau lwm cov nodes. Kev hloov pauv yog muaj rau cov neeg xa xov xwm txawm tias ua ntej kev pom zoo tshwm sim thiab suav nrog hauv qhov thaiv. Txoj kev no peb yuav xa cov lus tam sim, ib yam li cov neeg xa xov xwm niaj hnub.
Txhawm rau khaws phau ntawv chaw nyob, peb tau ua KVS - Qhov Tseem Ceeb-Value Storage - qhov no yog lwm hom kev lag luam uas asset nws tsis yog NaCl-box uas yog encrypted, tab sis NaCl-secretbox. Qhov no yog li cas tus tub txib khaws lwm cov ntaub ntawv.
Kev hloov ntaub ntawv / duab thiab kev sib tham hauv pab pawg tseem xav tau ntau yam haujlwm. Tau kawg, nyob rau hauv blunder-and-blunder hom ntawv no tuaj yeem "screwed" sai, tab sis peb xav kom muaj tib theem ntawm kev ceev ntiag tug.
Yog lawm, tseem muaj txoj haujlwm yuav tsum tau ua - qhov zoo tshaj plaws, kev ceev ntiag tug tiag tiag xav tias cov neeg siv yuav tsis txuas rau pej xeem network nodes, tab sis yuav tsa lawv tus kheej. Qhov feem pua ββββntawm cov neeg siv koj xav tias ua li no? Yog lawm, 0. Peb tuaj yeem daws qhov teeb meem no ib nrab nrog Tor version ntawm tus tub txib.
Peb tau ua pov thawj tias tus tub txib ntawm blockchain tuaj yeem muaj nyob. Yav dhau los, tsuas muaj ib qho kev sim hauv xyoo 2012 - bitmessage, uas ua tsis tiav vim lub sijhawm xa xov ntev, CPU thauj khoom, thiab tsis muaj daim ntawv thov mobile.
Thiab kev tsis ntseeg yog vim qhov tseeb tias cov neeg xa xov ntawm blockchain ua ntej lawv lub sijhawm - tib neeg tsis tau npaj txhij los ua lub luag haujlwm rau lawv tus account, muaj tus kheej cov ntaub ntawv tseem tsis tau muaj qhov sib txawv, thiab thev naus laus zis tsis tso cai rau kev kub ceev ntawm blockchain. Ntau thev naus laus zis analogues ntawm peb qhov project yuav tshwm sim tom ntej. Koj yuav pom.