0xs34n / blockchain Goto Github PK
View Code? Open in Web Editor NEW📖Code for Blockchain Demo
Home Page: https://blockchaindemo.io
📖Code for Blockchain Demo
Home Page: https://blockchaindemo.io
Hi, I've an error when I try to connect a peer to the network, the error is "Invalid magic value, peer not using PXP" What should I do? Thanks
Title says it all
I am a bit confused between peers and miners. I know that peers are the ones which have the entire blockchain with them and whenever a new block comes, it is broadcast to all peers, and the peers check the validity and finally add it to the blockchain.
Now I am confused as to who introduces the new block? I see the code which adds a new block which then gets broadcast to all peers but what I do not understand is, who calls the mineCommand()
?
function mineCommand(vorpal) {
vorpal
.command('mine <data>', 'Mine a new block. Eg: mine hello!')
.alias('m')
.action(function(args, callback) {
if (args.data) {
blockchain.mine(args.data);
p2p.broadcastLatest();
}
callback();
})
}
From the UI, I get an impression that a peer is the one adding a new block but from the code it doesn't seem so.
Hi, I run this project locally, but it is giving the functionality on CLI only, as you have shown on the website, the UI is a separate application? Can you give me a little guidance how did you developed the web interface to demonstrated all this on the web application very well. Thanks
@seanjameshan
When disconnecting a peer, adding some blocks and reconnecting, the blockchain replacement sometimes doesn't replace the block data. It keeps the previous value, but if you change it to what it should be, the hash remains valid (and you don't need to mine it).
Say for instance I have a peer Satoshi and Humberto, which are connected and both have the same blockchain with 4 blocks. If I disconnect Humberto, add a block 'Humberto 1' to it, and add two blocks to Satoshi (say, 'Satoshi 1' and 'Satoshi 2'), when reconnecting, Humberto has the same blockchain as Satoshi, but instead of having a block say 'Satoshi 1' it says 'Humberto 1'. If you change this block's data to 'Satoshi 1', the block will be valid without needing to mine it.
It probably is just a visualization issue, but it does lead to some confusion. Hope this helps
Getting an error while executing the third command npm install.
When a longer valid chain is created which differs from other smaller chains, the data of the longer chain is not replacing the data of shorter chains (though, the hashes are replaced).
Suppose 3 peers have 5 blocks, all in sync and then another peer joins and creates 7 blocks with blocks different from other peers. Here the longer valid blockchain should replace the smaller blockchains. But only the hashes are replaced, and the data remains the same. Only new blocks 6th and 7th get added to all other peers' blockchains. Their 1-5 blocks contain the same data (Hashes are replaced by those from the longer valid chains).
The code in nodejs or the web version (chrome), both use very high cpu.
Im using:
OS X High Sierra v10.13.1
NODEJS v6.12.0
CHROME v62.0.3202.94 (Official Build) (64-bit)
hi! I downloaded the project but is only CLI, you will upload UI source?
thanks!
const {
REQUEST_LATEST_BLOCK,
RECEIVE_LATEST_BLOCK,
REQUEST_BLOCKCHAIN,
RECEIVE_BLOCKCHAIN,
REQUEST_TRANSACTIONS,
RECEIVE_TRANSACTIONS
} = messageType;
This code block causes error with nodejs 6 and 5 on Ubuntu 16.04 system.
const {
^SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object. (/home/semih/mytone/blockchain/cli.js:2:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)npm ERR! Linux 4.10.0-40-generic
npm ERR! argv "/home/semih/.nvm/versions/node/v5.12.0/bin/node" "/home/semih/.nvm/versions/node/v5.12.0/bin/npm" "start"
npm ERR! node v5.12.0
npm ERR! npm v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start:node ./index.js
npm ERR! Exit status 1
.js file name(block.js) throws error in linux systems as it is case sensitive. Maybe it helps someone. Renaming file resolves the issue
I wanna use your great site for education in my language, how can I translate it?
Did you public the translation files so I can contribute?
Let's say Peer P1 added a block called B1 to its blockchain and another peer P2 added a block B2 to its blockchain. After this, if both the peers are connected, then will the blockchain be synced between them?
I was expecting both the peers would have both the blocks, i.e, B1 and B2. Am I right?
node ./index.js
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'wrtc'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\Users\astrea\blockchain\P2p.js:1:76)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\extra\AppData\Roaming\npm-cache_logs\2019-03-28T05_00_46_463Z-debug.log
please help me out of this error as soon as possibel
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.