Documentation ¶
Index ¶
- Variables
- func AskForBlock(height int32, hash string)
- func Canonical(w http.ResponseWriter, r *http.Request)
- func CountVotes(value string) int
- func Create(w http.ResponseWriter, r *http.Request)
- func Download()
- func DownloadBallot()
- func ForwardHeartBeat(heartBeatData data.HeartBeatData)
- func GenerateVotingMpt() p1.MerklePatriciaTrie
- func HeartBeatReceive(w http.ResponseWriter, r *http.Request)
- func Logger(inner http.Handler, name string) http.Handler
- func NewRouter() *mux.Router
- func RandSeed()
- func ReadDataFromBallot() voting.Ballot
- func SendBlock(trie p1.MerklePatriciaTrie)
- func Show(w http.ResponseWriter, r *http.Request)
- func ShowBallot(w http.ResponseWriter, r *http.Request)
- func ShowMPT(w http.ResponseWriter, r *http.Request)
- func Start(w http.ResponseWriter, r *http.Request)
- func StartHeartBeat()
- func StartVotingProcess()
- func Upload(w http.ResponseWriter, r *http.Request)
- func UploadBlock(w http.ResponseWriter, r *http.Request)
- type CanonicalChain
- type CanonicalChainBlock
- type ECDSASignature
- type JsonString
- type Route
- type Routes
Constants ¶
This section is empty.
Variables ¶
var ALLOWED_IDS = map[int32]bool{ 6688: true, 6678: true, }
Only these IDs are allowed to write. This gives the semblance of a permissioned blockchain
var BALLOT voting.Ballot
var CREATED = false
var FIRST_NODE = "http://localhost:6688"
var FIRST_NODE_ADDRESS = "localhost:6688"
First node will have the canonical block chain on it. It will first create the blockchain, and the other nodes will listen for it.
var FIRST_NODE_BALLOT = FIRST_NODE + "/show-ballot"
var FIRST_NODE_PORT int32 = 6688
var FIRST_NODE_SERVER = FIRST_NODE + "/upload"
var FOUNDREMOTE = false
Need to introduce a private key so we can properly do signatures
var ID int32
var Peers data.PeerList
var SBC data.SyncBlockChain
This is the canonical blockchain
var SELF_ADDR string
Functions ¶
func AskForBlock ¶
Function recursively asks for all the missing predecessor blocks instead of only the parent block.
func Canonical ¶
func Canonical(w http.ResponseWriter, r *http.Request)
If there are multiple blocks at max height n, they are considered as forks, and each fork can form a chain.
The canonical chain would be decided once one of the forks grows and that chain becomes the longest chain.
func CountVotes ¶
func Create ¶
func Create(w http.ResponseWriter, r *http.Request)
Create the initial canonical Blockchain and add write it to the server
func Download ¶
func Download()
Download blockchain from First Node
So launch node on SELF_ADDR and then download from the TA_SERVER SELF_ADDR needs to make a request to FIRST_NODE
func DownloadBallot ¶
func DownloadBallot()
Download the uploaded ballot from other Nodes.
We should save this data to a Ballot Class, like we did with Blockchain.
func ForwardHeartBeat ¶
func ForwardHeartBeat(heartBeatData data.HeartBeatData)
Send to all the peers. Will probably want to send a post request to their ReceiveHeartBeat
func GenerateVotingMpt ¶
func GenerateVotingMpt() p1.MerklePatriciaTrie
Changed so there's User Input Required Now
This contains the data that we need to insert into the block, before we send it to the blockchain. Requires user input before the MPT is generated.
func HeartBeatReceive ¶
func HeartBeatReceive(w http.ResponseWriter, r *http.Request)
func ReadDataFromBallot ¶
func SendBlock ¶
func SendBlock(trie p1.MerklePatriciaTrie)
func ShowBallot ¶
func ShowBallot(w http.ResponseWriter, r *http.Request)
Show the contents of the ballot
func Start ¶
func Start(w http.ResponseWriter, r *http.Request)
Register ID, download BlockChain, start HeartBeat
func StartHeartBeat ¶
func StartHeartBeat()
func StartVotingProcess ¶
func StartVotingProcess()
This function starts a new thread that tries different nonces to generate new blocks. Nonce is a string of 16 hexes such as "1f7b169c846f218a". Initialize the rand when you start a new node with something unique about each node, such as the current time or the port number.
func Upload ¶
func Upload(w http.ResponseWriter, r *http.Request)
Called By Download (POST Request from local node's Download Function)
func UploadBlock ¶
func UploadBlock(w http.ResponseWriter, r *http.Request)
If you have the block, return the JSON string of the specific block; if you don't have the block, return HTTP 204: StatusNoContent; if there's an error, return HTTP 500: InternalServerError.
Types ¶
type CanonicalChain ¶
type CanonicalChain struct {
// contains filtered or unexported fields
}
type CanonicalChainBlock ¶
type CanonicalChainBlock struct {
// contains filtered or unexported fields
}
type ECDSASignature ¶
Need to make a ECDSASignature struct to verify
type JsonString ¶
type JsonString struct {
JsonBody string
}