vpkeydx

package
v0.0.0-...-bf055c7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package vpkeydx contains utilities to generate and analyze keys used in p2p messaging.

Index

Constants

View Source
const PackageCopyright = "Copyright (C)  2015, 2016  Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh

PackageCopyright contains a short copyright notice.

View Source
const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh

PackageEmail contains a contact email for the package.

View Source
const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh

PackageLicense contains a short license information.

View Source
const PackageName = "Vapor Toolkit" // PackageName set by version.sh

PackageName contains a readable name of the package, suitable for display.

View Source
const PackageTarname = "vapor" // PackageTarname set by version.sh

PackageTarname contains a short name of the package, suitable for a filename.

View Source
const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh

PackageURL contains the address of the project homepage.

View Source
const VersionMajor = 0 // VersionMajor set by version.sh

VersionMajor is the project major version.

View Source
const VersionMinor = 3 // VersionMinor set by version.sh

VersionMinor is the project minor version.

View Source
const VersionStamp = "c6a4298" // VersionStamp set by version.sh

VersionStamp is the project stamp, possibly changes for each build.

Variables

This section is empty.

Functions

func Dec31

func Dec31(i int32) int32

Dec31 decreases the value by 1, then performs a modulo 2<<32.

func Gen

func Gen(seed []byte, keyName string) ([]byte, error)

Gen generates a unique ID for a key, given a seed. A typical usage of seed is the vring (virtual ring) name, which can be used to differenciate key locations on various vrings.

func GenVec1

func GenVec1(seed []byte, keyName string, vec1 int32) ([]byte, error)

GenVec1 is a simple alias on GenX.

func GenVec2

func GenVec2(seed []byte, keyName string, vec2 *vpvec2.I32) ([]byte, error)

GenVec2 is a wrapper on GenXY, which takes a vector as an argument instead of individual coords.

func GenVec3

func GenVec3(seed []byte, keyName string, vec3 *vpvec3.I32) ([]byte, error)

GenVec3 is a wrapper on GenXYZ, which takes a vector as an argument instead of individual coords.

func GenX

func GenX(seed []byte, keyName string, x int32) ([]byte, error)

GenX generates a unique ID for a key, given a seed. A typical usage of seed is the vring (virtual ring) name, which can be used to differenciate key locations on various vrings. The x parameter has a special meaning, it is used on a 31-bit scale (from 0 to 0x7fffffff) as a prefix for the key. This is used to explicitely store some keys close to some node/host.

func GenXY

func GenXY(seed []byte, keyName string, x int32, y int32) ([]byte, error)

GenXY generates a unique ID for a key, given a seed. A typical usage of seed is the vring (virtual ring) name, which can be used to differenciate key locations on various vrings. The x and y parameter have a special meaning, they are used on a 31-bit scale (from 0 to 0x7fffffff) as a prefix for the key. This is used to explicitely store some keys close to some node/host. Technically they are interlaced so that globally, square-like shapes stick together, and avoid the all row 0 first, then all row 1, etc.

func GenXYZ

func GenXYZ(seed []byte, keyName string, x int32, y int32, z int32) ([]byte, error)

GenXYZ generates a unique ID for a key, given a seed. A typical usage of seed is the vring (virtual ring) name, which can be used to differenciate key locations on various vrings. The x, y and z parameter have a special meaning, they are used on a 31-bit scale (from 0 to 0x7fffffff) as a prefix for the key. This is used to explicitely store some keys close to some node/host. Technically they are interlaced so that globally, cube-like shapes stick together, and avoid the all row 0 first, then all row 1, etc.

func GetVec1

func GetVec1(keyID []byte) (int32, error)

GetVec1 gets the 1st (X) coord value for a given key. Note that it can be used for any key, even possibly those which have not be generated with Gen1d.

func GetVec2

func GetVec2(keyID []byte) (*vpvec2.I32, error)

GetVec2 gets the 1st and 2nd (X, Y) coord value for a given key. Note that it can be used for any key, even possibly those which have not be generated with Gen1d.

func GetVec3

func GetVec3(keyID []byte) (*vpvec3.I32, error)

GetVec3 gets the 1st, 2nd and 3rd (X,Y,Z) coord value for a given key. Note that it can be used for any key, even possibly those which have not be generated with Gen1d.

func GetX

func GetX(keyID []byte) (int32, error)

GetX gets the X (1st) coord value for a given key. Note that it can be used for any key, even possibly those which have not be generated with Gen1d.

func GetXY

func GetXY(keyID []byte) (int32, int32, error)

GetXY gets the X,Y (1st and 2nd) coord value for a given key. Note that it can be used for any key, even possibly those which have not be generated with Gen1d.

func GetXYZ

func GetXYZ(keyID []byte) (int32, int32, int32, error)

GetXYZ gets the X,Y,Z (1st, 2nd and 3rd) coord value for a given key. Note that it can be used for any key, even possibly those which have not be generated with Gen1d.

func Inc31

func Inc31(i int32) int32

Inc31 increases the value by 1, then performs a modulo 2<<32.

func Mod31

func Mod31(i int32) int32

Mod31 returns the value modulo 2<<32. Usefull to avoid out-of-range errors when manipulating coordinates.

func Scale31

func Scale31(i int32, n int32) int32

Scale31 returns a value expressed on 31 bit, between [0,n). The scale is linear, that is, if i == n / x, then returned value is about 2<<31 / x.

Types

This section is empty.

Jump to

Keyboard shortcuts

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