models

package
v0.0.0-...-99f7857 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBlock

func AddBlock(cfg *config.Config, pubKey string, txn float64) error

AddBlock adds a new block to the coin chain

Types

type CoinBlock

type CoinBlock struct {
	gorm.Model

	// PubKey is the public key of the peer
	PubKey string `gorm:"index"`

	// TotalCoins is the number of coins the peer has after the txn
	TotalCoins float64

	// TXN is the amount added/reduced from the old `TotalCoins`
	TXN float64

	// Hash is the blake2 hash of the last node's msgpack in base64
	LastHash string
}

CoinBlock the the coin blockchain stored onto a psql DB for now

type CoinPack

type CoinPack struct {
	PubKey     string  `msgpack:"public_key"`
	TotalCoins float64 `msgpack:"total_coins"`
	TXN        float64 `msgpack:"txn"`
	LastHash   string  `msgpack:"hash"`
}

CoinPack is used to pack a record into msgpack

type DHT

type DHT struct {
	gorm.Model

	// PubKey is the base64 Curve25519 public key of the peer
	PubKey string `gorm:"uniqueIndex"`

	// NickName is the peer's short name used to make reaching it easier
	NickName string `gorm:"uniqueIndex"`
}

DHT is the DB model for the hash table

type RegisterBody

type RegisterBody struct {
	PubKey   string `json:"pub_key"`
	NickName string `json:"nickname"`
}

RegisterBody is used to deserialize the HTTP register endpoint's body

type ResolveReponse

type ResolveReponse struct {
	PubKey string `json:"pub_key"`
}

ResolveReponse is the model for the response of a resolve request

type Signal

type Signal struct {
	Type string `json:"type"`
	To   string `json:"to"`
	From string `json:"from"`
	SDP  string `json:"sdp"`
}

Signal is used to define the signal msg transmitted over the network

Jump to

Keyboard shortcuts

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