Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Latest commit

 

History

History
88 lines (77 loc) · 2.05 KB

README.md

File metadata and controls

88 lines (77 loc) · 2.05 KB

Blockchain Visualization

P5JS Visualization for Golang Blockchain

Features

  1. Proof of Work
  2. Asynchronous Peer-to-Peer Communcation & Discovery
  3. P5JS Web Visualization of Blockchain Network

Dependencies

import (
	"bytes"
	"crypto/sha256"
	"encoding/binary"
	"encoding/gob"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"html/template"
	"io"
	"io/ioutil"
	"log"
	"math"
	"math/big"
	"net"
	"net/http"
	"os"
	"strconv"
	"strings"
	"sync"
	"time"

	"github.com/davecgh/go-spew/spew"
	"github.com/gorilla/mux"
	"github.com/spf13/pflag"
)

Usage:

Note: Though the program is scalable, to showcase the functions of the program, currently 2 docker peers are created for p2p.

  • -h, --host string binding host (default (Outbound Host IP))
  • -p, --port int binding port (default 4444)
  • -w, --webport int web server port (default 8000)

  1. Docker
make    # To build docker containers

      Using two terminals, exec "make run*" to access bash on built docker images

  • Terminal 1
admin$ make run1
# Access bash on blockchain-vis_run1_1 with exposed ports 4444 and 8000
run1$ ./blockchain-vis
  • Terminal 2
admin$ make run2
# Access bash on blockchain-vis_run2_1 with exposed ports 4444 and 8000
run2$ ./blockchain-vis (ip of run1):4444

  1. Build local binary
make local

P5JS Web Visualizations

Note: Limited to work only on localhost

Default port: 8000

Access web server through http://localhost:(port)/web/

Adding to Blockchain

  • cURL
curl -d '{"Data":"(transaction_data)"}' http://(ip):(port)/
  • Web Server
    • Hover on nodes to show node properties
    • Posts using textbox input (localhost only)
    • Reloads if POST response is invalid