Skip to content

arunp0/blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

blockchain

Simple Block Chain implemenation in Go with Proof of Work

Go to app folder

    $cd server/src/app/server

Now we need to set our GOPATH, so run the following command:

    $export GOPATH={path to app directory}/server

Great, now that we’ve set that, we can setup our app for dependencies.

Run the following:

    $cd src/app
    $dep init
    $dep ensure

To Run the server

    $go run server.go

To Mine:

GET http://localhost:3000/mine_block
{"index":2,"timeStamp":"2019-03-29T02:51:53.697289+05:30","pHash":"4b1c33439ca926762d25438b9a62c1b1898de7bbf5fa9af5abbc0b778aa15c02","proof":61840}

To Get the chain:

GET http://localhost:3000/get_chain
    [{"index":1,"timeStamp":"2019-03-29T02:51:39.540236+05:30","pHash":"0","proof":1},{"index":2,"timeStamp":"2019-03-29T02:51:53.697289+05:30","pHash":"4b1c33439ca926762d25438b9a62c1b1898de7bbf5fa9af5abbc0b778aa15c02","proof":61840}]

To check if chain is valid:

GET http://localhost:3000/is_valid
"Block chain is valid"

Run Test cases

    $cd blockchain
    $go test

Releases

No releases published

Packages

No packages published

Languages