data

package
v0.0.0-...-97f3c37 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadStakeDist

func LoadStakeDist(file string, stakeDist *map[string]float64)

loads json file containing stake distribution into in memory map to access stakes of users useful when validating transactions (check for enough credit) and validating leaders (computing threshold for leader)

Types

type Block

type Block struct {
	PreviousHash      string // aka state
	Slot              int    // index of slot block produced in
	VrfOutput         string
	VrfProof          string
	SlotLeader        string // public key of block creator
	Timestamp         string
	Transactions      []Transaction
	Nonce             string        //seeds slot leaders for selection process, no need to include in all blocks (just epoch transitions)
	StakeDistribution []Stakeholder //only in epoch transitions
	Signature         string        // signing all previous fields (proof that slot leader is who he claims to be)
}

func GenesisBlock

func GenesisBlock(stakeDist map[string]float64) *Block

func (*Block) Add

func (b *Block) Add(t Transaction)

func (*Block) Sign

func (b *Block) Sign(privateKey ed25519.PrivateKey)

type Distribution

type Distribution struct {
	Stakeholders []Stakeholder
}

type Stakeholder

type Stakeholder struct {
	PublicKey string
	Stake     float64 //percentage
}

type Transaction

type Transaction struct {
	// maybe introduce a transaction header type later
	Nonce           uint64 // in case same amount sent to same receiver later
	From            string
	To              string
	Amount          uint64
	Timestamp       string
	ContractCode    []byte
	GasPrice        uint64
	GasLimit        uint64
	ContractAddress string // provides consent for smart contracts involving other users (otherwise empty)
	Signature       string
}

func (*Transaction) Sign

func (t *Transaction) Sign(privateKey ed25519.PrivateKey)

func (*Transaction) Validate

func (t *Transaction) Validate() bool

Jump to

Keyboard shortcuts

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