blockchain

package
v0.0.0-...-2847b59 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

github is a Go library for accessing the Github API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBlockHash

func GetBlockHash(b Block) ([]byte, error)

func GetTransactionHash

func GetTransactionHash(tx Transaction) ([]byte, error)

Get the transaction hashcode that is calculated from the payload

Types

type Block

type Block struct {
	Index        uint64
	Timestamp    string
	Transaction  *Transaction
	Hash         []byte
	PreviousHash []byte
}

Type Block represents a transactions

func NewGenesisBlock

func NewGenesisBlock() *Block

type Blockchain

type Blockchain struct {
	// contains filtered or unexported fields
}

Type Blockchain represents a Blockchain

func NewBlockchain

func NewBlockchain(initialBlock *Block) *Blockchain

func (*Blockchain) AddBlock

func (bc *Blockchain) AddBlock(t Transaction) error

AddBlock adds a new Block to the back of the Blockchain with a specific transaction

func (*Blockchain) GetCurrentBlock

func (bc *Blockchain) GetCurrentBlock() *Block

GetCurrentBlock returns the tip Block

type Hashable

type Hashable interface {
	Hash() ([]byte, error)
}

type Transaction

type Transaction struct {
	Hash    []byte
	Payload []byte
}

func NewTransaction

func NewTransaction(payload []byte) *Transaction

func (*Transaction) MarshalBinary

func (tx *Transaction) MarshalBinary() ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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