blockchain on go
TRANSCRIPT
•
• Github: timakin / Twitter: @__timakin__ • Gunosy Inc.
• Go / Swift • community
• golang.tokyo • roppongi-golunch • blockchain.tokyo
Example of block
{ difficulty: '137447', extraData: '0x476574682f76312e302e312f6c696e75782f676f312e342e32', gasLimit: 3141592, gasUsed: 0, hash: '0x4d3063b91cbaa12bf2de81014c1319febc9f197c93f81b0746afaffaa9496620', nonce: '0x28fda83cb19ed497', number: 100, parentHash: '0x5885cdec1d1410580eaaf1fb7ef9db245a735822d48e816c73d926b7c9872f15', size: 536, timestamp: 1439451765, totalDifficulty: '13551548', transactions: [ ], transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',}
Consensus Algorithm• Proof of Work
• Node 0 Node
• target nonce(hash value)
• Node
• Proof of Stake
•
• ex) SHA256(prevhash + address + timestamp) <= 2^256 * balance (volume of stake) / diff
• Proof of Stake Velocity
geth(go-ethereum)• Go
• Ethereum protocol Go
• Ethereum
• Windows OS
• geth( 7832) cpp-ethereum( 1710),
pythereum( 1487), ethereumj(760)
HyperLedger Projects
Fabric PBFT
*
* http://www.jpx.co.jp/corporate/research-study/working-paper/tvdivq0000008q5y-att/
JPX_working_paper_No15.pdf
HyperLedger Fabric Network
ref: https://www.ibm.com/developerworks/jp/cloud/library/j_cl-blockchain-basics-bluemix/
PBFT (Practical Byzantine Fault Tolelance)
ref: https://www.ibm.com/developerworks/jp/cloud/library/j_cl-blockchain-basics-bluemix/
shim.ChaincodeStubInterface• chaincode WorldState Ledger
API
• Init, Invoke
• Get/Put/Delete State World State
• shim.Success, shim.Error res payload writer
200, 400,
500
HyperLedger Composer
Web UI (Fabric)
4
Model:
Access Control: Read/Write
Script: JS
Query:
Model REST API
Upload assets# $ ipfs add test.jpgadded QmaC9pUA3grWJ948u1VWRLG1wPLP8YZe7b3HopBGk4zZyA test.jpg
$ ipfs cat /ipfs/QmaC9pUA3grWJ948u1VWRLG1wPLP8YZe7b3HopBGk4zZyA > butaman.jpg$ open https://ipfs.io/ipfs/QmaC9pUA3grWJ948u1VWRLG1wPLP8YZe7b3HopBGk4zZyA
# $ ipfs add -r ~/myproject
# Fuse$ ipfs mount$ ls /ipfs/$hash/
# $ ipfs add -q test.mp4
API Client
var ipfs = require('ipfs-client'); var stream = ipfs.cat('QmTE9Xp76E67vkYeygbKJrsVj8W2LLcyUifuMHMEkyRfUL');stream.pipe(process.stdout);
ipfs.add(process.stdin, function(err, hash) { console.log(hash);});
https://www.npmjs.com/package/ipfs-client
API
Scala Go JavaScript