blockchain

package
v0.0.0-...-74edb40 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleBCmessage

func HandleBCmessage(s core.Server, conn net.Conn)

HandleBCmessage : recive bc messages and answer them

func HashSha256

func HashSha256(tohash []byte) string

HashSha256 : returns the hash of a slice of bytes

func IsBlockValid

func IsBlockValid(newBlock, oldBlock Block) (bool, error)

IsBlockValid : chech if block is valid

func StdAddListeners

func StdAddListeners(s core.Server)

StdAddListeners : add the standard listeners to the server NEW CONNECTION NEW DOSCONNECTION

func StdBCServer

func StdBCServer(sc core.ServerConfig) core.Server

StdBCServer : create a standard server

func StdReciveMessage

func StdReciveMessage(s core.Server, conn net.Conn) error

StdReciveMessage : Standard function to recive messages

Types

type Block

type Block struct {
	Index        int
	Timestamp    string
	Transactions []Transaction
	Hash         string
	PrevHash     string
}

Block : struct of a blockchan block

func GenerateBlock

func GenerateBlock(oldBlock Block, txs []Transaction) (Block, error)

GenerateBlock : generate a new block from an old block and some txs

func GenerateGenesisBlock

func GenerateGenesisBlock() (Block, error)

GenerateGenesisBlock : generate a genesis block

func (*Block) CalculateHash

func (b *Block) CalculateHash() (string, error)

CalculateHash : calcumate has of the block

type Transaction

type Transaction struct {
	Hash    string
	NTxsIn  int
	TxsIn   []TxIn
	NTxsOut int
	TxsOut  []TxOut
}

Transaction : struct of a blockchain transaction

type TxIn

type TxIn struct {
	PrevTx    string
	Index     int
	ScriptSig string
}

TxIn : struct for bc transaction input

type TxOut

type TxOut struct {
	Value        int
	ScriptPubKey string
}

TxOut : struct for bc transaction output

Jump to

Keyboard shortcuts

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