csdc

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

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

Go to latest
Published: Aug 5, 2021 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	StandardScryptN = int(keystore.StandardScryptN)

	// StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on a modern processor.
	StandardScryptP = int(keystore.StandardScryptP)

	// LightScryptN is the N parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	LightScryptN = int(keystore.LightScryptN)

	// LightScryptP is the P parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	LightScryptP = int(keystore.LightScryptP)
)

Variables

This section is empty.

Functions

func Clean

func Clean(path string, arg int) error

func CreateKeyStore

func CreateKeyStore(path, passwd string, ScryptN, ScryptP int) (string, error)

func DefaultDataDir

func DefaultDataDir() string

func PathExists

func PathExists(path string) (bool, error)

Types

type Account

type Account struct {
	// contains filtered or unexported fields
}

Account represents a stored key.

func (*Account) GetAddress

func (a *Account) GetAddress() *Address

GetAddress retrieves the address associated with the account.

func (*Account) GetURL

func (a *Account) GetURL() string

GetURL retrieves the canonical URL of the account.

type Accounts

type Accounts struct {
	// contains filtered or unexported fields
}

Accounts represents a slice of accounts.

func (*Accounts) Get

func (a *Accounts) Get(index int) (account *Account, _ error)

Get returns the account at the given index from the slice.

func (*Accounts) Set

func (a *Accounts) Set(index int, account *Account) error

Set sets the account at the given index in the slice.

func (*Accounts) Size

func (a *Accounts) Size() int

Size returns the number of accounts in the slice.

type ActivatePost

type ActivatePost struct {
	Appid      string
	Credential string
	Account    string
	ClientId   string
}

type Address

type Address struct {
	// contains filtered or unexported fields
}

func (*Address) GetHex

func (a *Address) GetHex() string

type BigInt

type BigInt struct {
	// contains filtered or unexported fields
}

A BigInt represents a signed multi-precision integer.

func NewBigInt

func NewBigInt(x int64) *BigInt

NewBigInt allocates and returns a new BigInt set to x.

func (*BigInt) GetBytes

func (bi *BigInt) GetBytes() []byte

GetBytes returns the absolute value of x as a big-endian byte slice.

func (*BigInt) GetInt64

func (bi *BigInt) GetInt64() int64

GetInt64 returns the int64 representation of x. If x cannot be represented in an int64, the result is undefined.

func (*BigInt) GetString

func (bi *BigInt) GetString(base int) string

GetString returns the value of x as a formatted string in some number base.

func (*BigInt) SetBytes

func (bi *BigInt) SetBytes(buf []byte)

SetBytes interprets buf as the bytes of a big-endian unsigned integer and sets the big int to that value.

func (*BigInt) SetInt64

func (bi *BigInt) SetInt64(x int64)

SetInt64 sets the big int to x.

func (*BigInt) SetString

func (bi *BigInt) SetString(x string, base int)

SetString sets the big int to x.

The string prefix determines the actual conversion base. A prefix of "0x" or "0X" selects base 16; the "0" prefix selects base 8, and a "0b" or "0B" prefix selects base 2. Otherwise the selected base is 10.

func (*BigInt) Sign

func (bi *BigInt) Sign() int

Sign returns:

-1 if x <  0
 0 if x == 0
+1 if x >  0

func (*BigInt) String

func (bi *BigInt) String() string

String returns the value of x as a formatted decimal string.

type BigInts

type BigInts struct {
	// contains filtered or unexported fields
}

BigInts represents a slice of big ints.

func NewBigInts

func NewBigInts(size int) *BigInts

NewBigInts creates a slice of uninitialized big numbers.

func (*BigInts) Get

func (bi *BigInts) Get(index int) (bigint *BigInt, _ error)

Get returns the bigint at the given index from the slice.

func (*BigInts) Set

func (bi *BigInts) Set(index int, bigint *BigInt) error

Set sets the big int at the given index in the slice.

func (*BigInts) Size

func (bi *BigInts) Size() int

Size returns the number of big ints in the slice.

type Enodesv4

type Enodesv4 struct {
	// contains filtered or unexported fields
}

Enodes represents a slice of accounts.

func NewEnodesEmptyv4

func NewEnodesEmptyv4() *Enodesv4

NewEnodesEmpty creates an empty slice of Enode values.

func NewEnodesv4

func NewEnodesv4(size int) *Enodesv4

NewEnodes creates a slice of uninitialized enodes.

func (*Enodesv4) Append

func (e *Enodesv4) Append(enode *Enodev4)

Append adds a new enode element to the end of the slice.

func (*Enodesv4) Get

func (e *Enodesv4) Get(index int) (enodev4 *Enodev4, _ error)

Get returns the enode at the given index from the slice.

func (*Enodesv4) Set

func (e *Enodesv4) Set(index int, enode *Enodev4) error

Set sets the enode at the given index in the slice.

func (*Enodesv4) Size

func (e *Enodesv4) Size() int

Size returns the number of enodes in the slice.

type Enodev4

type Enodev4 struct {
	// contains filtered or unexported fields
}

Enode represents a host on the network.

func NewEnodev4

func NewEnodev4(rawurl string) (enodev4 *Enodev4, _ error)

type KeyStore

type KeyStore struct {
	// contains filtered or unexported fields
}

KeyStore manages a key storage directory on disk.

func NewKeyStore

func NewKeyStore(keydir string, scryptN, scryptP int) *KeyStore

NewKeyStore creates a keystore for the given directory.

func (*KeyStore) DeleteAccount

func (ks *KeyStore) DeleteAccount(account *Account, passphrase string) error

DeleteAccount deletes the key matched by account if the passphrase is correct. If a contains no filename, the address must match a unique key.

func (*KeyStore) ExportKey

func (ks *KeyStore) ExportKey(account *Account, passphrase, newPassphrase string) (key []byte, _ error)

ExportKey exports as a JSON key, encrypted with newPassphrase.

func (*KeyStore) GetAccounts

func (ks *KeyStore) GetAccounts() *Accounts

GetAccounts returns all key files present in the directory.

func (*KeyStore) HasAddress

func (ks *KeyStore) HasAddress(address *Address) bool

HasAddress reports whether a key with the given address is present.

func (*KeyStore) ImportKey

func (ks *KeyStore) ImportKey(keyJSON []byte, passphrase, newPassphrase string) (account *Account, _ error)

ImportKey stores the given encrypted JSON key into the key directory.

func (*KeyStore) Lock

func (ks *KeyStore) Lock(address *Address) error

Lock removes the private key with the given address from memory.

func (*KeyStore) NewAccount

func (ks *KeyStore) NewAccount(passphrase string) (*Account, error)

NewAccount generates a new key and stores it into the key directory, encrypting it with the passphrase.

func (*KeyStore) SignHash

func (ks *KeyStore) SignHash(address *Address, hash []byte) (signature []byte, _ error)

SignHash calculates a ECDSA signature for the given hash. The produced signature is in the [R || S || V] format where V is 0 or 1.

func (*KeyStore) SignHashPassphrase

func (ks *KeyStore) SignHashPassphrase(account *Account, passphrase string, hash []byte) (signature []byte, _ error)

SignHashPassphrase signs hash if the private key matching the given address can be decrypted with the given passphrase. The produced signature is in the [R || S || V] format where V is 0 or 1.

func (*KeyStore) TimedUnlock

func (ks *KeyStore) TimedUnlock(account *Account, passphrase string, timeout int64) error

TimedUnlock unlocks the given account with the passphrase. The account stays unlocked for the duration of timeout (nanoseconds). A timeout of 0 unlocks the account until the program exits. The account must match a unique key file.

If the account address is already unlocked for a duration, TimedUnlock extends or shortens the active unlock timeout. If the address was previously unlocked indefinitely the timeout is not altered.

func (*KeyStore) Unlock

func (ks *KeyStore) Unlock(account *Account, passphrase string) error

Unlock unlocks the given account indefinitely.

func (*KeyStore) UpdateAccount

func (ks *KeyStore) UpdateAccount(account *Account, passphrase, newPassphrase string) error

UpdateAccount changes the passphrase of an existing account.

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node represents a Geth Ethereum node instance.

func NewSwarmNode

func NewSwarmNode(datadir string, config *NodeConfig) (stack *Node, _ error)

func Start

func Start(path string, password string, bootnodeAddrs string, bootnode string) (stack *Node, _ error)

func StartL

func StartL(path string, password string, bootnodeAddrs string, bootnode string, logLevel int) (stack *Node, _ error)

func (*Node) AddBootnode

func (n *Node) AddBootnode(enodeStr string) error

func (*Node) AddPeer

func (n *Node) AddPeer(peer *Enodev4)

func (*Node) Close

func (n *Node) Close() error

Close terminates a running node along with all it's services, tearing internal state doen too. It's not possible to restart a closed node.

func (*Node) GetFileBaseUrl

func (n *Node) GetFileBaseUrl() string

getFile baseUrl

func (*Node) GetFileUrl

func (n *Node) GetFileUrl(cdnUrl string, hash string) string

getM3U8 url

func (*Node) GetHttpPort

func (n *Node) GetHttpPort() string

getBzzPort

func (*Node) GetM3U8BaseUrl

func (n *Node) GetM3U8BaseUrl() string

getM3U8baseUrl

func (*Node) GetM3U8Url

func (n *Node) GetM3U8Url(cdnUrl string, hash string) string

getM3U8 url

func (*Node) GetNodeInfo

func (n *Node) GetNodeInfo() *NodeInfo

GetNodeInfo gathers and returns a collection of metadata known about the host.

func (*Node) GetPeersInfo

func (n *Node) GetPeersInfo() *PeerInfos

GetPeersInfo returns an array of metadata objects describing connected peers.

func (*Node) SetHttpPort

func (n *Node) SetHttpPort(port string)

func (*Node) Start

func (n *Node) Start() error

Start creates a live P2P node and starts running it.

func (*Node) Stop

func (n *Node) Stop() error

Stop terminates a running node along with all it's services. If the node was not started, an error is returned.

type NodeConfig

type NodeConfig struct {

	// MaxPeers is the maximum number of peers that can be connected. If this is
	// set to zero, then only the configured static and trusted peers can connect.
	MaxPeers int

	// EthereumEnabled specifies whether the node should run the Ethereum protocol.
	EthereumEnabled bool

	// EthereumNetworkID is the network identifier used by the Ethereum protocol to
	// decide if remote peers should be accepted or not.
	EthereumNetworkID int64 // uint64 in truth, but Java can't handle that...

	// SwarmEnabled specifies whether the node should run the Swarm protocol.
	SwarmEnabled bool

	// SwarmAccount specifies account ID used for starting Swarm node.
	SwarmAccount string

	// SwarmAccountPassword specifies password for account retrieval from the keystore.
	SwarmAccountPassword string

	ServerAddrs []string
}

NodeConfig represents the collection of configuration values to fine tune the Geth node embedded into a mobile process. The available values are a subset of the entire API provided by go-ethereum to reduce the maintenance surface and dev complexity.

func NewNodeConfig

func NewNodeConfig() *NodeConfig

NewNodeConfig creates a new node option set, initialized to the default values.

type NodeInfo

type NodeInfo struct {
	// contains filtered or unexported fields
}

NodeInfo represents pi short summary of the information known about the host.

func (*NodeInfo) GetDiscoveryPort

func (ni *NodeInfo) GetDiscoveryPort() int

func (*NodeInfo) GetEnode

func (ni *NodeInfo) GetEnode() string

func (*NodeInfo) GetID

func (ni *NodeInfo) GetID() string

func (*NodeInfo) GetIP

func (ni *NodeInfo) GetIP() string

func (*NodeInfo) GetListenerAddress

func (ni *NodeInfo) GetListenerAddress() string

func (*NodeInfo) GetListenerPort

func (ni *NodeInfo) GetListenerPort() int

func (*NodeInfo) GetName

func (ni *NodeInfo) GetName() string

func (*NodeInfo) GetProtocols

func (ni *NodeInfo) GetProtocols() *Strings

type PeerInfo

type PeerInfo struct {
	// contains filtered or unexported fields
}

PeerInfo represents pi short summary of the information known about pi connected peer.

func (*PeerInfo) GetCaps

func (pi *PeerInfo) GetCaps() *Strings

func (*PeerInfo) GetID

func (pi *PeerInfo) GetID() string

func (*PeerInfo) GetLocalAddress

func (pi *PeerInfo) GetLocalAddress() string

func (*PeerInfo) GetName

func (pi *PeerInfo) GetName() string

func (*PeerInfo) GetRemoteAddress

func (pi *PeerInfo) GetRemoteAddress() string

type PeerInfos

type PeerInfos struct {
	// contains filtered or unexported fields
}

PeerInfos represents a slice of infos about remote peers.

func (*PeerInfos) Get

func (pi *PeerInfos) Get(index int) (info *PeerInfo, _ error)

Get returns the peer info at the given index from the slice.

func (*PeerInfos) Size

func (pi *PeerInfos) Size() int

Size returns the number of peer info entries in the slice.

type RespData

type RespData struct {
	ExpireTime int64  `json:"expireTime"`
	NodeUrl    string `json:"nodeUrl"`
	BootNode   string `json:"bootNode"`
	Error      string `json:"error"`
}

func Activate

func Activate(path string, appId string, credential string, addr string, newAccount bool, password string, arg int) (*RespData, error)

func ActivateR

func ActivateR(path string, appId string, clientId string, credential string, addr string, newAccount bool, password string, arg int) (*RespData, error)

func PostToServer

func PostToServer(urlStr string, timeout time.Duration, data *ActivatePost) (*RespData, error)

type Strings

type Strings struct {
	// contains filtered or unexported fields
}

Strings represents s slice of strs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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