p3

package
v0.0.0-...-c2f1f9c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const Difficulty = 5

Variables

can use here --> var Peers data.PeerList

View Source
var BC_DOWNLOAD_SERVER = INIT_SERVER + "/upload"

SELF_ADDR var BC_DOWNLOAD_SERVER = TA_SERVER + "/upload"

View Source
var BalanceBook p5.BalanceBook
View Source
var GetNewParent bool
View Source
var INIT_SERVER = "http://localhost:6686"

var TA_SERVER = "http://localhost:6688"

View Source
var PID_DOWNLOAD_SERVER = INIT_SERVER + "/uploadpids"

Peers is the Peer List which is for each node

SBC is safe for distributed use

View Source
var SELF_ADDR = "http://localhost:6686"

changes in init for arg of port provided

View Source
var SELF_ADDR_PREFIX = "http://localhost:"
View Source
var Wallet p5.Wallet

Functions

func AskForBlock

func AskForBlock(height int32, hash string, blockHolder []b.Block) bool

AskForBlock - Ask another server to return a block of certain height and hash

func BcHolders

func BcHolders(w http.ResponseWriter, r *http.Request)

func BuildTransactionsList

func BuildTransactionsList(chain p2.Blockchain) map[string]bool

func CIDPage

func CIDPage(w http.ResponseWriter, r *http.Request)

func Canonical

func Canonical(w http.ResponseWriter, r *http.Request)

Canonical func - Display canonical chain

func ClientLogin

func ClientLogin(w http.ResponseWriter, r *http.Request)

func ClientSignUp

func ClientSignUp(w http.ResponseWriter, r *http.Request)

func Download

func Download()

Download blockchain from TA server

func DownloadPeerMapPid

func DownloadPeerMapPid()

func GenerateTransactionsMPT

func GenerateTransactionsMPT() p1.MerklePatriciaTrie

func to generate transactionMPT

func GetMyId

func GetMyId(w http.ResponseWriter, r *http.Request)

func GetTransactionPool

func GetTransactionPool()

func GiveDefaultTokens

func GiveDefaultTokens(cid p5.ClientId)

func GiveMinerTokens

func GiveMinerTokens(cid p5.Identity)

func HeartBeatReceive

func HeartBeatReceive(w http.ResponseWriter, r *http.Request)

HeartBeatReceive func - Received a heartbeat in request body

func InitBalanceBook

func InitBalanceBook()

func Logger

func Logger(inner http.Handler, name string) http.Handler

func Login

func Login(w http.ResponseWriter, r *http.Request)

func NewClient

func NewClient(w http.ResponseWriter, r *http.Request)

func NewRouter

func NewRouter() *mux.Router

func Register

func Register() int32

Register to TA's server, get an ID

func SendBlockBeat

func SendBlockBeat(height int32, parentHash string, nonce string, mpt p1.MerklePatriciaTrie)

SendBlockBeat func prepares heartbeat data and sends across to peers

func ServeClient

func ServeClient(w http.ResponseWriter, r *http.Request)

func SetCID

func SetCID(w http.ResponseWriter, r *http.Request)

func Show

func Show(w http.ResponseWriter, r *http.Request)

Show func - Display peerList and sbc

func ShowBalanceBook

func ShowBalanceBook(w http.ResponseWriter, r *http.Request)

func ShowBcHolders

func ShowBcHolders(w http.ResponseWriter, r *http.Request)

func ShowBlockMpt

func ShowBlockMpt(w http.ResponseWriter, r *http.Request)

called when /showBlockMpt/{height}/{hash} is called

func ShowTransactionPool

func ShowTransactionPool(w http.ResponseWriter, r *http.Request)

func ShowWallet

func ShowWallet(w http.ResponseWriter, r *http.Request)

func SignUp

func SignUp(w http.ResponseWriter, r *http.Request)

func Start

func Start(w http.ResponseWriter, r *http.Request)

Start handler - does Register ID, download BlockChain, start HeartBeat

func StartHeartBeat

func StartHeartBeat()

StartHeartBeat func periodically sends heartbeatdata to peers

func StartTryingNonces

func StartTryingNonces()

StartTryingNonces func sends heartbeatdata with new block information to peers

func TransactionBeatRecv

func TransactionBeatRecv(w http.ResponseWriter, r *http.Request)

TransactionBeatRecv func takes http request POST /txbeat/receive - verify txSig - verify tx valid - add to TxPool - forward to Peers

func TransactionForm

func TransactionForm(w http.ResponseWriter, r *http.Request)

func TransactionPoolRecv

func TransactionPoolRecv(w http.ResponseWriter, r *http.Request)

func Upload

func Upload(w http.ResponseWriter, r *http.Request)

Upload blockchain to whoever called this method, return jsonStr

func UploadBlock

func UploadBlock(w http.ResponseWriter, r *http.Request)

UploadBlock func - Upload a block to whoever called this method, return jsonStr

func UploadGenesis

func UploadGenesis(w http.ResponseWriter, r *http.Request)

Upload genesis blockchain to whoever called this method, return jsonStr

func UploadPids

func UploadPids(w http.ResponseWriter, r *http.Request)

Upload blockchain to whoever called this method, return jsonStr

Types

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

type Routes

type Routes []Route

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL