Documentation ¶
Index ¶
- Constants
- Variables
- func HaltOnInterruptSignal(nodeManager *NodeManager)
- func HaltOnPanic()
- func MakeNode(config *params.NodeConfig) (*node.Node, error)
- func NotifyNode(jsonEvent *C.char)
- func ResetDefaultNodeNotificationHandler()
- func SendSignal(signal SignalEnvelope)
- func SetDefaultNodeNotificationHandler(fn NodeNotificationHandler)
- func TriggerDefaultNodeNotificationHandler(jsonEvent string)
- func TriggerTestSignal()
- type AccountManager
- func (m *AccountManager) AccountsListRequestHandler() func(entities []gethcommon.Address) []gethcommon.Address
- func (m *AccountManager) AddressToDecryptedAccount(address, password string) (accounts.Account, *keystore.Key, error)
- func (m *AccountManager) CreateAccount(password string) (address, pubKey, mnemonic string, err error)
- func (m *AccountManager) CreateChildAccount(parentAddress, password string) (address, pubKey string, err error)
- func (m *AccountManager) Logout() error
- func (m *AccountManager) ReSelectAccount() error
- func (m *AccountManager) RecoverAccount(password, mnemonic string) (address, pubKey string, err error)
- func (m *AccountManager) SelectAccount(address, password string) error
- func (m *AccountManager) SelectedAccount() (*common.SelectedExtKey, error)
- func (m *AccountManager) VerifyAccountPassword(keyStoreDir, address, password string) (*keystore.Key, error)
- type NodeCrashEvent
- type NodeManager
- func (m *NodeManager) AccountKeyStore() (*keystore.KeyStore, error)
- func (m *NodeManager) AccountManager() (*accounts.Manager, error)
- func (m *NodeManager) AddPeer(url string) error
- func (m *NodeManager) IsNodeRunning() bool
- func (m *NodeManager) LightEthereumService() (*les.LightEthereum, error)
- func (m *NodeManager) Node() (*node.Node, error)
- func (m *NodeManager) NodeConfig() (*params.NodeConfig, error)
- func (m *NodeManager) PopulateStaticPeers() error
- func (m *NodeManager) RPCClient() (*rpc.Client, error)
- func (m *NodeManager) RPCServer() (*rpc.Server, error)
- func (m *NodeManager) ResetChainData() (<-chan struct{}, error)
- func (m *NodeManager) RestartNode() (<-chan struct{}, error)
- func (m *NodeManager) StartNode(config *params.NodeConfig) (<-chan struct{}, error)
- func (m *NodeManager) StopNode() (<-chan struct{}, error)
- func (m *NodeManager) WhisperService() (*whisper.Whisper, error)
- type NodeNotificationHandler
- type RPCManager
- type ReturnSendTransactionEvent
- type SendTransactionEvent
- type SignalEnvelope
- type TxQueueManager
- func (m *TxQueueManager) CompleteTransaction(id, password string) (gethcommon.Hash, error)
- func (m *TxQueueManager) CompleteTransactions(ids, password string) map[string]common.RawCompleteTransactionResult
- func (m *TxQueueManager) DiscardTransaction(id string) error
- func (m *TxQueueManager) DiscardTransactions(ids string) map[string]common.RawDiscardTransactionResult
- func (m *TxQueueManager) TransactionQueueHandler() func(queuedTx status.QueuedTx)
- func (m *TxQueueManager) TransactionReturnHandler() func(queuedTx *status.QueuedTx, err error)
Constants ¶
const ( // EventNodeStarted is triggered when underlying node is started EventNodeStarted = "node.started" // EventNodeReady is triggered when underlying node is fully ready // (consider backend to be fully registered) EventNodeReady = "node.ready" // EventNodeStopped is triggered when underlying node is fully stopped EventNodeStopped = "node.stopped" // EventNodeCrashed is triggered when node crashes EventNodeCrashed = "node.crashed" // EventChainDataRemoved is triggered when node's chain data is removed EventChainDataRemoved = "chaindata.removed" )
const ( // EventTransactionQueued is triggered when send transaction request is queued EventTransactionQueued = "transaction.queued" // EventTransactionFailed is triggered when send transaction request fails EventTransactionFailed = "transaction.failed" // SendTxDefaultErrorCode is sent by default, when error is not nil, but type is unknown/unexpected. SendTxDefaultErrorCode = SendTransactionDefaultErrorCode )
const ( SendTransactionNoErrorCode = "0" SendTransactionDefaultErrorCode = "1" SendTransactionPasswordErrorCode = "2" SendTransactionTimeoutErrorCode = "3" SendTransactionDiscardedErrorCode = "4" )
Send transaction response codes
Variables ¶
var ( ErrAddressToAccountMappingFailure = errors.New("cannot retrieve a valid account for a given address") ErrAccountToKeyMappingFailure = errors.New("cannot retrieve a valid key for a given account") ErrWhisperIdentityInjectionFailure = errors.New("failed to inject identity into Whisper") ErrWhisperClearIdentitiesFailure = errors.New("failed to clear whisper identities") ErrNoAccountSelected = errors.New("no account has been selected, please login") ErrInvalidMasterKeyCreated = errors.New("can not create master extended key") )
errors
var ( ErrNodeExists = errors.New("node is already running") ErrNoRunningNode = errors.New("there is no running node") ErrInvalidNodeManager = errors.New("node manager is not properly initialized") ErrInvalidWhisperService = errors.New("whisper service is unavailable") ErrInvalidLightEthereumService = errors.New("LES service is unavailable") ErrInvalidAccountManager = errors.New("could not retrieve account manager") ErrAccountKeyStoreMissing = errors.New("account key store is not set") ErrInvalidRPCClient = errors.New("RPC client is unavailable") ErrInvalidRPCServer = errors.New("RPC server is unavailable") )
errors
var ( ErrEthServiceRegistrationFailure = errors.New("failed to register the Ethereum service") ErrWhisperServiceRegistrationFailure = errors.New("failed to register the Whisper service") ErrLightEthRegistrationFailure = errors.New("failed to register the LES service") ErrNodeMakeFailure = errors.New("error creating p2p node") ErrNodeRunFailure = errors.New("error running p2p node") ErrNodeStartFailure = errors.New("error starting p2p node") )
node-related errors
var ( ErrInvalidMethod = errors.New("method does not exist") ErrRPCServerTimeout = errors.New("RPC server cancelled call due to timeout") ErrRPCServerCallFailed = errors.New("RPC server cannot complete request") )
errors
Functions ¶
func HaltOnInterruptSignal ¶
func HaltOnInterruptSignal(nodeManager *NodeManager)
HaltOnInterruptSignal stops node and panics if you press Ctrl-C enough times
func HaltOnPanic ¶
func HaltOnPanic()
HaltOnPanic recovers from panic, logs issue, sends upward notification, and exits
func MakeNode ¶
func MakeNode(config *params.NodeConfig) (*node.Node, error)
MakeNode create a geth node entity
func NotifyNode ¶
func ResetDefaultNodeNotificationHandler ¶
func ResetDefaultNodeNotificationHandler()
ReetDefaultNodeNotificationHandler sets notification handler to default one
func SendSignal ¶
func SendSignal(signal SignalEnvelope)
SendSignal sends application signal (JSON, normally) upwards to application (via default notification handler)
func SetDefaultNodeNotificationHandler ¶
func SetDefaultNodeNotificationHandler(fn NodeNotificationHandler)
SetDefaultNodeNotificationHandler sets notification handler to invoke on SendSignal
func TriggerDefaultNodeNotificationHandler ¶
func TriggerDefaultNodeNotificationHandler(jsonEvent string)
TriggerDefaultNodeNotificationHandler triggers default notification handler (helpful in tests)
func TriggerTestSignal ¶
func TriggerTestSignal()
Types ¶
type AccountManager ¶
type AccountManager struct {
// contains filtered or unexported fields
}
AccountManager represents account manager interface
func NewAccountManager ¶
func NewAccountManager(nodeManager common.NodeManager) *AccountManager
NewAccountManager returns new node account manager
func (*AccountManager) AccountsListRequestHandler ¶
func (m *AccountManager) AccountsListRequestHandler() func(entities []gethcommon.Address) []gethcommon.Address
AccountsListRequestHandler returns handler to process account list request
func (*AccountManager) AddressToDecryptedAccount ¶
func (m *AccountManager) AddressToDecryptedAccount(address, password string) (accounts.Account, *keystore.Key, error)
AddressToDecryptedAccount tries to load decrypted key for a given account. The running node, has a keystore directory which is loaded on start. Key file for a given address is expected to be in that directory prior to node start.
func (*AccountManager) CreateAccount ¶
func (m *AccountManager) CreateAccount(password string) (address, pubKey, mnemonic string, err error)
CreateAccount creates an internal geth account BIP44-compatible keys are generated: CKD#1 is stored as account key, CKD#2 stored as sub-account root Public key of CKD#1 is returned, with CKD#2 securely encoded into account key file (to be used for sub-account derivations)
func (*AccountManager) CreateChildAccount ¶
func (m *AccountManager) CreateChildAccount(parentAddress, password string) (address, pubKey string, err error)
CreateChildAccount creates sub-account for an account identified by parent address. CKD#2 is used as root for master accounts (when parentAddress is ""). Otherwise (when parentAddress != ""), child is derived directly from parent.
func (*AccountManager) Logout ¶
func (m *AccountManager) Logout() error
Logout clears whisper identities
func (*AccountManager) ReSelectAccount ¶
func (m *AccountManager) ReSelectAccount() error
ReSelectAccount selects previously selected account, often, after node restart.
func (*AccountManager) RecoverAccount ¶
func (m *AccountManager) RecoverAccount(password, mnemonic string) (address, pubKey string, err error)
RecoverAccount re-creates master key using given details. Once master key is re-generated, it is inserted into keystore (if not already there).
func (*AccountManager) SelectAccount ¶
func (m *AccountManager) SelectAccount(address, password string) error
SelectAccount selects current account, by verifying that address has corresponding account which can be decrypted using provided password. Once verification is done, decrypted key is injected into Whisper (as a single identity, all previous identities are removed).
func (*AccountManager) SelectedAccount ¶
func (m *AccountManager) SelectedAccount() (*common.SelectedExtKey, error)
SelectedAccount returns currently selected account
func (*AccountManager) VerifyAccountPassword ¶
func (m *AccountManager) VerifyAccountPassword(keyStoreDir, address, password string) (*keystore.Key, error)
VerifyAccountPassword tries to decrypt a given account key file, with a provided password. If no error is returned, then account is considered verified.
type NodeCrashEvent ¶
type NodeCrashEvent struct {
Error string `json:"error"`
}
NodeCrashEvent is special kind of error, used to report node crashes
type NodeManager ¶
NodeManager manages Status node (which abstracts contained geth node)
func NewNodeManager ¶
func NewNodeManager() *NodeManager
NewNodeManager makes new instance of node manager
func (*NodeManager) AccountKeyStore ¶
func (m *NodeManager) AccountKeyStore() (*keystore.KeyStore, error)
AccountKeyStore exposes reference to accounts key store
func (*NodeManager) AccountManager ¶
func (m *NodeManager) AccountManager() (*accounts.Manager, error)
AccountManager exposes reference to node's accounts manager
func (*NodeManager) AddPeer ¶
func (m *NodeManager) AddPeer(url string) error
AddPeer adds new static peer node
func (*NodeManager) IsNodeRunning ¶
func (m *NodeManager) IsNodeRunning() bool
IsNodeRunning confirm that node is running
func (*NodeManager) LightEthereumService ¶
func (m *NodeManager) LightEthereumService() (*les.LightEthereum, error)
LightEthereumService exposes reference to LES service running on top of the node
func (*NodeManager) Node ¶
func (m *NodeManager) Node() (*node.Node, error)
Node returns underlying Status node
func (*NodeManager) NodeConfig ¶
func (m *NodeManager) NodeConfig() (*params.NodeConfig, error)
NodeConfig exposes reference to running node's configuration
func (*NodeManager) PopulateStaticPeers ¶
func (m *NodeManager) PopulateStaticPeers() error
PopulateStaticPeers connects current node with our publicly available LES/SHH/Swarm cluster
func (*NodeManager) RPCClient ¶
func (m *NodeManager) RPCClient() (*rpc.Client, error)
RPCClient exposes reference to RPC client connected to the running node
func (*NodeManager) RPCServer ¶
func (m *NodeManager) RPCServer() (*rpc.Server, error)
RPCServer exposes reference to running node's in-proc RPC server/handler
func (*NodeManager) ResetChainData ¶
func (m *NodeManager) ResetChainData() (<-chan struct{}, error)
ResetChainData remove chain data from data directory. Node is stopped, and new node is started, with clean data directory.
func (*NodeManager) RestartNode ¶
func (m *NodeManager) RestartNode() (<-chan struct{}, error)
RestartNode restart running Status node, fails if node is not running
func (*NodeManager) StartNode ¶
func (m *NodeManager) StartNode(config *params.NodeConfig) (<-chan struct{}, error)
StartNode start Status node, fails if node is already started
func (*NodeManager) StopNode ¶
func (m *NodeManager) StopNode() (<-chan struct{}, error)
StopNode stop Status node. Stopped node cannot be resumed.
func (*NodeManager) WhisperService ¶
func (m *NodeManager) WhisperService() (*whisper.Whisper, error)
WhisperService exposes reference to Whisper service running on top of the node
type NodeNotificationHandler ¶
type NodeNotificationHandler func(jsonEvent string)
NodeNotificationHandler defines a handler able to process incoming node events. Events are encoded as JSON strings.
type RPCManager ¶
RPCManager abstract RPC management API (for both client and server)
func NewRPCManager ¶
func NewRPCManager(nodeManager common.NodeManager) *RPCManager
NewRPCManager returns new instance of RPC client
func (*RPCManager) Call ¶
func (c *RPCManager) Call(inputJSON string) string
Call executes RPC request on node's in-proc RPC server
type ReturnSendTransactionEvent ¶
type ReturnSendTransactionEvent struct { ID string `json:"id"` Args status.SendTxArgs `json:"args"` MessageID string `json:"message_id"` ErrorMessage string `json:"error_message"` ErrorCode string `json:"error_code"` }
ReturnSendTransactionEvent is a JSON returned whenever transaction send is returned
type SendTransactionEvent ¶
type SendTransactionEvent struct { ID string `json:"id"` Args status.SendTxArgs `json:"args"` MessageID string `json:"message_id"` }
SendTransactionEvent is a signal sent on a send transaction request
type SignalEnvelope ¶
type SignalEnvelope struct { Type string `json:"type"` Event interface{} `json:"event"` }
SignalEnvelope is a general signal sent upward from node to RN app
type TxQueueManager ¶
type TxQueueManager struct {
// contains filtered or unexported fields
}
TxQueueManager provides means to manage internal Status Backend (injected into LES)
func NewTxQueueManager ¶
func NewTxQueueManager(nodeManager common.NodeManager, accountManager common.AccountManager) *TxQueueManager
func (*TxQueueManager) CompleteTransaction ¶
func (m *TxQueueManager) CompleteTransaction(id, password string) (gethcommon.Hash, error)
CompleteTransaction instructs backend to complete sending of a given transaction
func (*TxQueueManager) CompleteTransactions ¶
func (m *TxQueueManager) CompleteTransactions(ids, password string) map[string]common.RawCompleteTransactionResult
CompleteTransactions instructs backend to complete sending of multiple transactions
func (*TxQueueManager) DiscardTransaction ¶
func (m *TxQueueManager) DiscardTransaction(id string) error
DiscardTransaction discards a given transaction from transaction queue
func (*TxQueueManager) DiscardTransactions ¶
func (m *TxQueueManager) DiscardTransactions(ids string) map[string]common.RawDiscardTransactionResult
DiscardTransactions discards given multiple transactions from transaction queue
func (*TxQueueManager) TransactionQueueHandler ¶
func (m *TxQueueManager) TransactionQueueHandler() func(queuedTx status.QueuedTx)
TransactionQueueHandler returns handler that processes incoming tx queue requests
func (*TxQueueManager) TransactionReturnHandler ¶
func (m *TxQueueManager) TransactionReturnHandler() func(queuedTx *status.QueuedTx, err error)
TransactionReturnHandler returns handler that processes responses from internal tx manager