build

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 15 Imported by: 12

Documentation

Index

Constants

View Source
const DEBUG = false

DEBUG indicates wether it is a debug build, and if so panics will be thrown, where not strictly necessary for operational purposes.

View Source
const (
	// EncodedVersionLength is the static length of a sia-encoded ProtocolVersion.
	EncodedVersionLength = 16 // sizeof(uint32==64) + sizeof([8]uint8)
)
View Source
const Release = "standard"

Release indicates the kind of release that is built, defining timings, amount of (extra) runtime checks. Possibilities: standard, testing and dev.

Variables

View Source
var (
	// SiaTestingDir is the directory that contains all of the files and
	// folders created during testing.
	SiaTestingDir = filepath.Join(os.TempDir(), "SiaTesting")
)

Functions

func ComposeErrors added in v0.1.0

func ComposeErrors(errs ...error) error

ComposeErrors will take multiple errors and compose them into a single errors with a longer message. Any nil errors used as inputs will be stripped out, and if there are zero non-nil inputs then 'nil' will be returned.

The original types of the errors is not preserved at all.

func CopyDir

func CopyDir(source, dest string) error

CopyDir copies a directory and all of its contents to the destination directory.

func CopyFile

func CopyFile(source, dest string) error

CopyFile copies a file from a source to a destination.

func Critical

func Critical(v ...interface{})

Critical should be called if a sanity check has failed, indicating developer error. Critical is called with an extended message guiding the user to the issue tracker on Github. If the program does not panic, the call stack for the running goroutine is printed to help determine the error.

func ExtendErr added in v0.1.0

func ExtendErr(s string, err error) error

ExtendErr will return a new error which extends the input error with a string. If the input error is nil, then 'nil' will be returned, discarding the input string.

func ExtractTarGz added in v0.1.0

func ExtractTarGz(filename, dir string) error

ExtractTarGz extracts the specified .tar.gz file to dir, overwriting existing files in the event of a name conflict.

func JoinErrors

func JoinErrors(errs []error, sep string) error

JoinErrors concatenates the elements of errs to create a single error. The separator string sep is placed between elements in the resulting error. Nil errors are skipped. If errs is empty or only contains nil elements, JoinErrors returns nil.

func Retry added in v1.0.2

func Retry(tries int, durationBetweenAttempts time.Duration, fn func() error) (err error)

Retry will call 'fn' 'tries' times, waiting 'durationBetweenAttempts' between each attempt, returning 'nil' the first time that 'fn' returns nil. If 'nil' is never returned, then the final error returned by 'fn' is returned.

func Select added in v0.1.0

func Select(v Var) interface{}

Select returns the field of v that corresponds to the current Release.

Since the caller typically makes a type assertion on the result, it is important to point out that type assertions are stricter than conversions. Specifically, you cannot write:

type myint int
Select(Var{0, 0, 0}).(myint)

Because 0 will be interpreted as an int, which is not assignable to myint. Instead, you must explicitly cast each field in the Var, or cast the return value of Select after the type assertion. The former is preferred.

func Severe

func Severe(v ...interface{})

Severe will print a message to os.Stderr. If DEBUG has been set panic will be called as well. Severe should be called in situations which indicate significant problems for the user (such as disk failure or random number generation failure), but where crashing is not strictly required to preserve integrity.

func TempDir

func TempDir(dirs ...string) string

TempDir joins the provided directories and prefixes them with the Sia testing directory.

Types

type InvalidVersionError added in v0.1.0

type InvalidVersionError string

InvalidVersionError indicates a protocol version is invalid.

func (InvalidVersionError) Error added in v0.1.0

func (e InvalidVersionError) Error() string

Error implements the error interface for InvalidVersionError.

type ProtocolVersion added in v0.1.0

type ProtocolVersion struct {
	Version    uint32  // Semantic Versioning
	Prerelease [8]byte // Any pre-release tag (eg. 'alpha' or the git commit hash)
}

ProtocolVersion defines the protocol version that a node uses

var (

	// Version is the current version of rivined.
	Version ProtocolVersion
)

func MustParse added in v0.1.1

func MustParse(raw string) ProtocolVersion

MustParse creates a version based on a given string, panics in case the given string is invalid

func NewPrereleaseVersion added in v0.1.0

func NewPrereleaseVersion(major, minor, patch, build uint8, prerelease string) ProtocolVersion

NewPrereleaseVersion creates a new protocol prerelease version

func NewVersion added in v0.1.0

func NewVersion(major, minor, patch, build uint8) ProtocolVersion

NewVersion creates a new protocol version

func Parse added in v0.1.1

func Parse(raw string) (ver ProtocolVersion, err error)

Parse attempts to create a version based on a given string

func (ProtocolVersion) Compare added in v0.1.0

func (pv ProtocolVersion) Compare(other ProtocolVersion) int

Compare returns an integer comparing this version with another version.

func (ProtocolVersion) MarshalJSON added in v0.1.0

func (pv ProtocolVersion) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.MarshalJSON

func (ProtocolVersion) String added in v0.1.0

func (pv ProtocolVersion) String() string

String returns the string version of this ProtocolVersion

func (*ProtocolVersion) UnmarshalJSON added in v0.1.0

func (pv *ProtocolVersion) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON

type Var added in v0.1.0

type Var struct {
	Standard interface{}
	Dev      interface{}
	Testing  interface{}
	// contains filtered or unexported fields
}

A Var represents a variable whose value depends on which Release is being compiled. None of the fields may be nil, and all fields must have the same type.

Jump to

Keyboard shortcuts

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