“钱包”与“内核”守护进程通信

主要通过 RPC 接口,与“内核”守护进程进行联动。

联动,如:

  • 同步区块数据,保存与账户有关的交易信息

  • 发起转账请求等

理论上,部分操作客户端可以直接与链交互通信,这里是封装一下,调用更加友好。

/* this file handles communication with the daemon
 * this includes receiving output information
 */

IsDaemonOnlineCached

// returns whether wallet was online some time ago

IsDaemonOnline

rpcClient get_info

// this is as simple as it gets
// single threaded communication to get the daemon status and height
// this will tell whether the wallet can connection successfully to  daemon or not

DetectSyncPoint

rpcClient getblockheaderbytopoheight

// do the entire sync
// lagging behind is the NOT the major problem
// the problem is the frequent soft-forks
// once an input has been detected, we must check whether the block is not orphan
// we must do this without leaking ourselves to the daemon itself
// this means, we will have to keep track of the chain in the wallet also, ofcouse for syncing purposes only
// we have a bucket where we store  topo height to block hash links , of course in encrypted form
// during syncing we do a a binary search style matching and then sync up from that point

Sync_Wallet_With_Daemon

向“区块链服务器”不断的发送 http Get 请求,获得响应数据,对数据进行解析,然后根据需要进行处理。

打通身份信息与链上数据的桥梁,钱包数据的主要来源!

Get getoutputs.bin

// get the outputs from the daemon, requesting specfic outputs
// the range can be anything
// if stop is zero,
// the daemon will flush out everything it has ASAP
// the stream can be saved and used later on

sync_loop

死循环,保证定时同步。

// triggers syncing with wallet every Y seconds ( configurable)
// less time means, higher resources consumption(network/compute) basically inversely proportional

封装了 Sync_Wallet_With_Daemon

Rescan_From_Height

Scan_Offline_File

// offline file is scanned from start till finish

SendTransaction

在钱包客户端操作,进行普通的转账交易,构建好交易数据后,由钱包软件向内核发起请求,之后的任务交给内核处理。

这里就是“钱包”向“内核”发起转账诉求。

Post sendrawtransaction

// this is as simple as it gets
// single threaded communication to relay TX to daemon
// if this is successful, then daemon is in control

本质是:
向“内核”的 sendrawtransaction 接口 Post 数据。

IsKeyImageSpent

Post is_key_image_spent

// this is as simple as it gets
// single threaded communication  gets whether the the key image is spent in pool or in blockchain
// this can leak informtion which keyimage belongs to us
// TODO in order to stop privacy leaks we must guess this information somehow on client side itself
// maybe the server can broadcast a bloomfilter or something else from the mempool keyimages

results matching ""

    No results matching ""