contracts

package
v0.0.0-...-27a570a Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2017 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SMART_CONTRACT    = 1
	FUNCTION_CONTRACT = 2
	CDN_CONTRACT      = 3
	CDN_BUNDLE        = 4
)

Variables

This section is empty.

Functions

func FindCDNFilePath

func FindCDNFilePath(filename, ownerWallet string) string

Returns a filepath for a wallet and a filename. Very fragile because bad escaping could lead to file traversal vulnerabilties.

func ProcessCDNBundle

func ProcessCDNBundle(data []byte) error

Takes a bson encoded Contract with a CDNFileBundle as Definition and stores it

func StartCDNServer

func StartCDNServer()

func VerifyContract

func VerifyContract(c *Contract) (bool, error)

Types

type CDNContract

type CDNContract struct {
	Hashes        map[string][32]byte `bson:"h"`
	MaxCacheNodes uint16              `bson:"n"`
}

type CDNFileBundle

type CDNFileBundle struct {
	File     []byte `bson:"fb"`
	Filename string `bson:"fn"`
}

type Contract

type Contract struct {
	PubKey     []byte    `bson:"p"`
	Type       uint8     `bson:"t"`
	Definition []byte    `bson:"d"`
	SenderSig  [2][]byte `bson:"rs"`
}

func CreateCDNContract

func CreateCDNContract(files []string, maxCacheNodes uint16, w *wallet.Wallet) (Contract, error)

Creates a contract for all files passed to files.

func (*Contract) AppendKeyAndSign

func (c *Contract) AppendKeyAndSign(w *wallet.Wallet)

func (Contract) SelectCDNNodes

func (c Contract) SelectCDNNodes(w *wallet.Wallet) error
type Header struct {
	Index     int    `json:"index"`
	BlockSize int    `json:"blocksize"`
	File      string `json:"filename"`
	Owner     string `json:"owner"`

	Proof string `json:"proof,omitempty"`
}

type SmartContract

type SmartContract struct {
	Id     int
	IsWasm bool
	Code   []byte
}

func NewSmartContract

func NewSmartContract(code []byte, isWasm bool) (SmartContract, error)

Jump to

Keyboard shortcuts

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