Documentation
¶
Index ¶
- Constants
- Variables
- func Connected() (connected bool)
- func CreateDirIfDoesNotExist(dir string) error
- func Decode(b []byte) ([]byte, error)
- func DecodeString(s string) ([]byte, error)
- func Encode(b []byte) ([]byte, error)
- func EncodeString(b []byte) (string, error)
- func Forever()
- func GenerateTLSCertificates(namePrefix string) error
- func GetExtIPAddrWithoutUPnP() (string, error)
- func Log(a ...interface{}) (int, error)
- func Logf(format string, a ...interface{}) (int, error)
- func ParseStringMethodCall(input string) (string, string, []string, error)
- func ParseStringMethodCallNoReceiver(input string) (string, []string, error)
- func ParseStringParams(input string) ([]string, error)
- func ReadConnectionWaitAsyncNoTLS(conn net.Conn) ([]byte, error)
- func ReadGob(filePath string, object interface{}) error
- func SendBytes(b []byte, address string) error
- func SendBytesResult(b []byte, address string) ([]byte, error)
- func StringFetchCallReceiver(input string) string
- func StringStripParentheses(input string) string
- func StringStripReceiverCall(input string) string
- func WriteGob(filePath string, object interface{}) error
- type Address
- type AddressSpace
- type Hash
Constants ¶
const ( // AddressLength - max addr length AddressLength = 20 // HashLength - max hash length HashLength = 32 )
Variables ¶
var ( // ErrNilInput - error definition describing input of 0 char length ErrNilInput = errors.New("nil input") // ErrVerboseNotAllowed - error definition describing config preventing print call ErrVerboseNotAllowed = errors.New("verbose output not allowed") // DataDir - global data directory definition DataDir = getDataDir() // ConfigDir - global config directory definition ConfigDir = filepath.FromSlash(fmt.Sprintf("%s/config", DataDir)) // PeerToPeerDir - global p2p directory definition. PeerToPeerDir = filepath.FromSlash(fmt.Sprintf("%s/p2p", DataDir)) // DbDir - global db directory definition. DbDir = filepath.FromSlash(fmt.Sprintf("%s/db", DataDir)) // DagDir - global dag directory definition. DagDir = filepath.FromSlash(fmt.Sprintf("%s/dag", DbDir)) // DisableTimestamps - global declaration for timestamp format config DisableTimestamps = false // GeneralTLSConfig - general global GoP2P TLS Config GeneralTLSConfig = &tls.Config{ Certificates: []tls.Certificate{getTLSCerts("general")}, InsecureSkipVerify: true, ServerName: "localhost", } // BootstrapNodes - global definition for set of bootstrap nodes BootstrapNodes = []string{ "108.41.124.60:3000", } // Silent - silent config Silent = false // NodePort - global port definition NodePort = 3000 // VMConfig - global virtual machine config VMConfig = vm.Environment{ EnableJIT: false, DefaultMemoryPages: 128, DefaultTableSize: 65536, } // GasPolicy - global gas policy GasPolicy = &compiler.SimpleGasPolicy{ GasPerInstruction: 1, } )
var ( // MemPrefix - "0x" memory address prefixbyte array representation MemPrefix = []byte{48, 120} // ErrNoMem - error definition describing input < 2 chars long (< len(0x)) ErrNoMem = errors.New("insufficient length for memory address char") )
var ErrDuplicateAddress = errors.New("duplicate address")
ErrDuplicateAddress - error definition describing two addresses of equal value
var ExtIPProviders = []string{
"http://checkip.amazonaws.com/",
"http://icanhazip.com/",
"http://www.trackip.net/ip",
"http://bot.whatismyipaddress.com/",
"https://ipecho.net/plain",
"http://myexternalip.com/raw",
}
ExtIPProviders - preset macro defining list of available external IP checking services
Functions ¶
func CreateDirIfDoesNotExist ¶ added in v0.6.1
CreateDirIfDoesNotExist - create given directory if does not exist
func Decode ¶
Decode - decode given hex-formatted, MemPrefix-compliant byte array to standard byte array
func DecodeString ¶
DecodeString - decode given hex-formatted, MemPrefix-compliant string to standard byte array
func EncodeString ¶
EncodeString - encode given byte array to hex-formatted, MemPrefix-compliant string
func GenerateTLSCertificates ¶
GenerateTLSCertificates - generate necessary TLS certificates, keys
func GetExtIPAddrWithoutUPnP ¶
GetExtIPAddrWithoutUPnP - retrieve the external IP address of the current machine w/o upnp
func ParseStringMethodCall ¶
ParseStringMethodCall - attempt to parse string as method call, returning receiver, method name and params
func ParseStringMethodCallNoReceiver ¶ added in v0.5.1
ParseStringMethodCallNoReceiver - attempt to parse string as method call, returning method name and params
func ParseStringParams ¶
ParseStringParams - attempt to fetch string parameters from (..., ..., ...) style call
func ReadConnectionWaitAsyncNoTLS ¶
ReadConnectionWaitAsyncNoTLS - attempt to read from connection in an asynchronous fashion, after waiting for peer to write
func SendBytesResult ¶ added in v0.5.0
SendBytesResult - gop2pCommon.SendBytesResult performance-optimized wrapper
func StringFetchCallReceiver ¶
StringFetchCallReceiver - attempt to fetch receiver from string, as if it were an x.y(..., ..., ...) style method call
func StringStripParentheses ¶
StringStripParentheses - strip parantheses from string
func StringStripReceiverCall ¶
StringStripReceiverCall - strip receiver from string method call
Types ¶
type Address ¶
type Address [AddressLength]byte
Address - []byte wrapper for addresses
func NewAddress ¶
func NewAddress(privateKey *ecdsa.PrivateKey) (Address, error)
NewAddress - initialize new address
func PublicKeyToAddress ¶
PublicKeyToAddress - initialize new address with given public key
func StringToAddress ¶
StringToAddress - convert string to address
type AddressSpace ¶
type AddressSpace struct { Addresses []Address `json:"addresses"` // Addresses in address space ID Hash `json:"ID"` // AddressSpace identifier }
AddressSpace - given address-space (e.g. 0x000-0x123)
func NewAddressSpace ¶
func NewAddressSpace(originAddresses []Address) (*AddressSpace, error)
NewAddressSpace - initialize address space
func (*AddressSpace) Bytes ¶
func (addressSpace *AddressSpace) Bytes() []byte
Bytes - convert given address-space to bytes
func (*AddressSpace) String ¶
func (addressSpace *AddressSpace) String() string
String - convert given address-space to string