Documentation ¶
Index ¶
- Variables
- func BytesToCmd(bytes []byte) string
- func CloseDB(chain *blockchain.BlockChain)
- func CmdToBytes(cmd string) []byte
- func DeserializePayload(request []byte, payload interface{}) error
- func ExtractCmd(request []byte) []byte
- func GobEncode(data interface{}) []byte
- func HandeBlock(request []byte, chain *blockchain.BlockChain)
- func HandleAddr(request []byte)
- func HandleConnection(conn net.Conn, chain *blockchain.BlockChain)
- func HandleGetBlocks(request []byte, chain *blockchain.BlockChain)
- func HandleGetData(request []byte, chain *blockchain.BlockChain)
- func HandleInv(request []byte, chain *blockchain.BlockChain)
- func HandleTx(request []byte, chain *blockchain.BlockChain)
- func HandleVersion(request []byte, chain *blockchain.BlockChain)
- func MineTx(chain *blockchain.BlockChain)
- func NodeIsKnown(addr string) bool
- func RequestBlocks()
- func SendAddr(address string)
- func SendBlock(addr string, b *blockchain.Block)
- func SendGetBlock(addr string)
- func SendGetData(addr, kind string, id []byte)
- func SendInv(addr, kind string, items [][]byte)
- func SendTx(addr string, txn *blockchain.Transaction)
- func SendVersion(addr string, chain *blockchain.BlockChain)
- func StartServer(nodeID, mineAddress string)
- type Addr
- type Block
- type GetBlocks
- type GetData
- type Inv
- type Tx
- type Version
Constants ¶
This section is empty.
Variables ¶
var (
KnownNodes = []string{"localhost:3000"}
)
Functions ¶
func BytesToCmd ¶
BytesToCmd will work like a deserialize function transforming the given bytes to a string
func CloseDB ¶
func CloseDB(chain *blockchain.BlockChain)
CloseDB will grafully shutdown the system if the process is interrupt or recive a syscall
func CmdToBytes ¶
CmdToBytes will work like a serialize function for the commands recibed by the command line package
func DeserializePayload ¶
Deserialze payload will deserialize the request into a struuct
func ExtractCmd ¶
func GobEncode ¶
func GobEncode(data interface{}) []byte
GobEncode will allow us to serialize data in a generic way
func HandeBlock ¶
func HandeBlock(request []byte, chain *blockchain.BlockChain)
handle block will handle the address get block request
func HandleAddr ¶
func HandleAddr(request []byte)
handle address will handle the address get address request
func HandleConnection ¶
func HandleConnection(conn net.Conn, chain *blockchain.BlockChain)
HandleConnection will handle connections of the current node
func HandleGetBlocks ¶
func HandleGetBlocks(request []byte, chain *blockchain.BlockChain)
handle get block will handle the get blocks request
func HandleGetData ¶
func HandleGetData(request []byte, chain *blockchain.BlockChain)
Handle GetData will handle the get data request
func HandleInv ¶
func HandleInv(request []byte, chain *blockchain.BlockChain)
handle inventory will handle the get Inv request
func HandleTx ¶
func HandleTx(request []byte, chain *blockchain.BlockChain)
Handle transaction will handle the get transaction request
func HandleVersion ¶
func HandleVersion(request []byte, chain *blockchain.BlockChain)
handle version will handle the get version request
func NodeIsKnown ¶
Node is known will check if the given node is in the list of known nodes
func RequestBlocks ¶
func RequestBlocks()
Request block will call send get block for each node in the list
func SendAddr ¶
func SendAddr(address string)
send address will create the request of the address to be send
func SendBlock ¶
func SendBlock(addr string, b *blockchain.Block)
Send block will create the request of the block to be send
func SendGetBlock ¶
func SendGetBlock(addr string)
SendGetBLock will the create request of the Getblock to be send
func SendGetData ¶
SendGetData will the create request of the GetData to be send
func SendTx ¶
func SendTx(addr string, txn *blockchain.Transaction)
SendTx will the create request of the transaction to be send
func SendVersion ¶
func SendVersion(addr string, chain *blockchain.BlockChain)
SendVersion will the create request of the Version to be send
func StartServer ¶
func StartServer(nodeID, mineAddress string)
StartServer will start the server with the given node id
Types ¶
type Addr ¶
type Addr struct {
AddrList []string // represents the list of addresses of each of the nodes
}
type GetBlocks ¶
type GetBlocks struct {
AddrFrom string // represents the address where the block are being fetching
}