common

package
v0.0.0-...-2fc7d26 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PUBLISH_TORRENT = "PUBLISH_TORRENT"
	TORRENT_REP     = "TORRENT_REP"
	SHARED_LAYER    = "SHARED_LAYER"
	LAYER_REP       = "LAYER_REP"
	SET_ALIAS       = "SET_ALIAS"
)
View Source
const BlockchainHostDefault = "http://localhost"
View Source
const BlockchainPortDefault = "5000"
View Source
const TorrentPortDefault = "8000"

Variables

View Source
var AUTHENTICATION_CURVE = elliptic.P256()

Functions

func Int64ToByteArr

func Int64ToByteArr(i int64) []byte

Types

type Base64Address

type Base64Address string

func HashPublicToB64Address

func HashPublicToB64Address(pub ecdsa.PublicKey) Base64Address

type EnvVars

type EnvVars struct {
	BlockchainHost string
	BlockchainPort string
	TorrentPort    string
}

func LoadEnvFromFile

func LoadEnvFromFile(topDir string) EnvVars

type JSONRepSummary

type JSONRepSummary struct {
	ValidTorrFraction    float64
	QualityTorrFraction  float64
	AccurateTorrFraction float64

	NotReceivedLayerFraction float64
	ValidLayerFraction       float64
}

type JSONSignableTransaction

type JSONSignableTransaction struct {
	Origin          OriginInfo // needed to say who I am (WITHIN the transaction)
	Transaction     json.RawMessage
	TransactionType string
	R, S            *big.Int // signature of the transaction, should be separate from the actual "message" components
	TxID            string
}

func (JSONSignableTransaction) ConvertToSignable

func (js JSONSignableTransaction) ConvertToSignable() SignableTransaction

type LayerFileMetadata

type LayerFileMetadata struct {
	Begin int64
	Size  int64
	// contains filtered or unexported fields
}

func AppendLayerDataToFile

func AppendLayerDataToFile(layerId string, data []byte) LayerFileMetadata

func (LayerFileMetadata) GetUrl

func (lm LayerFileMetadata) GetUrl() string

type LayerRep

type LayerRep struct {
	//How many times this layer has been shared w/ someone else on the blockchain
	SharedQuantity uint64

	NotReceived uint64

	//How many times this layer has been reported as valid upon receipt
	ValidReports uint64
}

type LayerRepTrans

type LayerRepTrans struct {
	TxID             string //the original transaction when the layer was shared with "me"
	LayerHash        string
	WasLayerReceived bool
	WasLayerValid    bool
}

LayerRepTrans represents an address leaving feedback on a layer that was shared with it. This can be used to determine if a particular node/address is reputable when sharing layers that are valid and hash correctly, or even if they shared the layer at all

func (LayerRepTrans) GetRawBytes

func (rt LayerRepTrans) GetRawBytes() []byte

func (LayerRepTrans) ToString

func (rt LayerRepTrans) ToString() string

type OriginInfo

type OriginInfo struct {
	PubKeyX *big.Int
	PubKeyY *big.Int
	Address Base64Address
}

func (OriginInfo) GetRawBytes

func (oi OriginInfo) GetRawBytes() []byte

func (OriginInfo) ToString

func (oi OriginInfo) ToString() string

type PersonalAddress

type PersonalAddress struct {
	PrivateKey ecdsa.PrivateKey //TODO Encrypt and save locally
	PublicKey  ecdsa.PublicKey
	Address    Base64Address
}

func GenerateNewPersonalAddress

func GenerateNewPersonalAddress() PersonalAddress

func (PersonalAddress) ConvertToOriginInfo

func (address PersonalAddress) ConvertToOriginInfo() OriginInfo

type PublishTorrentTrans

type PublishTorrentTrans struct {
	Torrent TorrentFile
}

PublishTorrentTrans represents a transaction that shows a node/user posting a new torrent onto the blockchain This allows other users and nodes to discover what layers comprise what type of file or content, so that the individual layers can be directly/"privately" requested from nodes (users don't request layers on the blockchain)

func (PublishTorrentTrans) GetRawBytes

func (tt PublishTorrentTrans) GetRawBytes() []byte

func (PublishTorrentTrans) ToString

func (tt PublishTorrentTrans) ToString() string

type RepMessage

type RepMessage struct {
	WasValid     bool
	HighQuality  bool
	AccurateName bool
}

RepMessage represents a message that conveys the quality of a Torrent, in terms of the accuracy of the name, the validity of the file itself (does it form a cohesive file that runs/opens as expected?), and if the content itself is high quality

type ReputationSummary

type ReputationSummary struct {
	//Reputation of all torrents, indexed by their hashes
	TorrentRep map[string]TorrentRep

	//Reputation of all layers, indexed by hash
	LayerRep map[string]LayerRep
}

func (ReputationSummary) ToJSONSummary

func (summary ReputationSummary) ToJSONSummary() JSONRepSummary

type SetAliasTrans

type SetAliasTrans struct {
	Alias string
}

func (SetAliasTrans) GetRawBytes

func (sat SetAliasTrans) GetRawBytes() []byte

func (SetAliasTrans) ToString

func (sat SetAliasTrans) ToString() string

type SharedLayerTrans

type SharedLayerTrans struct {
	SharedLayerHash string
	Recipient       Base64Address
}

SharedLayerTrans represents a transaction that shows a node sharing a torrent layer with a particular address This can be used by other nodes to see if a node has indicated sharing with an address, and whether or not that address left feedback on the share, if that address actually received the layer, etc.

func (SharedLayerTrans) GetRawBytes

func (lt SharedLayerTrans) GetRawBytes() []byte

func (SharedLayerTrans) ToString

func (lt SharedLayerTrans) ToString() string

type SignableTransaction

type SignableTransaction struct {
	Origin          OriginInfo // needed to say who I am (WITHIN the transaction)
	Transaction     TorrentTransaction
	TransactionType string
	R, S            *big.Int // signature of the transaction, should be separate from the actual "message" components
	TxID            string
}

func NewSignable

func NewSignable(info OriginInfo, transaction TorrentTransaction, ttype string) SignableTransaction

func (SignableTransaction) GetHash

func (st SignableTransaction) GetHash() []byte

func (SignableTransaction) GetOrigin

func (st SignableTransaction) GetOrigin() OriginInfo

func (SignableTransaction) GetRS

func (st SignableTransaction) GetRS() (*big.Int, *big.Int)

func (SignableTransaction) SignAndSetTxID

func (st SignableTransaction) SignAndSetTxID(priv *ecdsa.PrivateKey) SignableTransaction

func (SignableTransaction) ToString

func (st SignableTransaction) ToString() string

func (SignableTransaction) Verify

func (st SignableTransaction) Verify() bool

func (SignableTransaction) VerifyWithKey

func (st SignableTransaction) VerifyWithKey(key ecdsa.PublicKey) bool

type TorrentFile

type TorrentFile struct {
	Name          string
	LayerByteSize int64
	TotalByteSize int64
	TotalHash     string

	LayerHashKeys []string //fine to expose publicly to say what layers the torrent has
	// contains filtered or unexported fields
}

func MakeTorrentFileFromFile

func MakeTorrentFileFromFile(layerByteSize int64, url string, name string) (TorrentFile, error)

func MakeTorrentFromBytes

func MakeTorrentFromBytes(layerByteSize int64, data []byte, name string) (TorrentFile, error)

func (TorrentFile) Equals

func (torr1 TorrentFile) Equals(torr2 TorrentFile) bool

func (TorrentFile) GetLayerHashMap

func (torr TorrentFile) GetLayerHashMap() map[string]LayerFileMetadata

GetLayerHashMap exposes the hashes and file metadata associated with a torrent file's layers, but without exposing the fields to manipulation, or exposure by mux when listing the TorrentFile as a web response

func (TorrentFile) GetRawBytes

func (torr TorrentFile) GetRawBytes() []byte

func (TorrentFile) GetUrl

func (torr TorrentFile) GetUrl() string

func (TorrentFile) ToString

func (torr TorrentFile) ToString() string

func (TorrentFile) Validate

func (torr TorrentFile) Validate() (bool, error)

type TorrentRep

type TorrentRep struct {
	TotalReports    uint64
	ValidReports    uint64
	QualityReports  uint64
	AccurateReports uint64
}

type TorrentRepTrans

type TorrentRepTrans struct {
	TxID        string //the original transaction when the layer was shared with "me"
	TorrentHash string
	RepMessage  RepMessage
}

TorrentRepTrans represents a transaction for feedback on a Torrent. See RepMessage for more details

func (TorrentRepTrans) GetRawBytes

func (rt TorrentRepTrans) GetRawBytes() []byte

func (TorrentRepTrans) ToString

func (rt TorrentRepTrans) ToString() string

type TorrentTransaction

type TorrentTransaction interface {
	GetRawBytes() []byte
	ToString() string
}

Jump to

Keyboard shortcuts

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