P5JS Visualization for Golang Blockchain
- Proof of Work
- Asynchronous Peer-to-Peer Communcation & Discovery
- P5JS Web Visualization of Blockchain Network
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"
)
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)
- 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
- Build local binary
make local
Note: Limited to work only on localhost
Default port: 8000
Access web server through http://localhost:(port)/web/
- 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