blockchainlib

package
v0.0.0-...-bfa7b29 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2018 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashBlock

func HashBlock(b Block) string

Types

type Block

type Block struct {
	Hash         string    `json:"hash"`
	Height       int64     `json:"height"`
	Date         time.Time `json:"date"`
	PreviousHash string    `json:"previoushash"`
	NextHash     string    `json:"nexthash"`
	Data         []string  `json:"data"`
	Emitter      string    `json:"emitter"` //the ID of the peer that has emmited the block
}

type Blockchain

type Blockchain struct {
	GenesisBlock string    `json:"genesisblock"`
	LastUpdate   time.Time `json:"lastupdate"`
	Blocks       []Block   `json:"blocks"`
}

func (*Blockchain) AddBlock

func (bc *Blockchain) AddBlock(block Block) error

func (*Blockchain) BlockExists

func (bc *Blockchain) BlockExists(block Block) bool

func (*Blockchain) CreateBlock

func (bc *Blockchain) CreateBlock(data string) Block

func (*Blockchain) CreateMsgHandlerCases

func (bc *Blockchain) CreateMsgHandlerCases() map[string]func(p2plib.Peer, p2plib.Msg)

func (*Blockchain) GetBlockByHash

func (bc *Blockchain) GetBlockByHash(hash string) (Block, error)

func (*Blockchain) InitializeBlockchain

func (bc *Blockchain) InitializeBlockchain(role, ip, port, restport, serverip, serverport string) p2plib.ThisPeer

func (*Blockchain) Print

func (bc *Blockchain) Print()

func (*Blockchain) ReadFromDisk

func (bc *Blockchain) ReadFromDisk() error

func (*Blockchain) ReconstructBlockchainFromBlock

func (bc *Blockchain) ReconstructBlockchainFromBlock(urlAPI string, h string)

func (*Blockchain) ReconstructBlockchainFromBlockRESTversion

func (bc *Blockchain) ReconstructBlockchainFromBlockRESTversion(urlAPI string, h string)

func (*Blockchain) SaveToDisk

func (bc *Blockchain) SaveToDisk() error

Jump to

Keyboard shortcuts

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