# IOTAProxy 筆記 Introduction --- 在 IOTA Tangle 上發起一筆交易,必須歷經以下四個步驟: * 簽名 (signature) * 驗證 2 個之前的交易 (Tips selection) * POW (Attach To Tangle) * 廣播 (Broadcast) 其中只有 **簽名 (signature)** 會在 local (錢包端) 執行,其餘 3 個步驟皆以 Restful API 的方式對 IOTA node 進行 request/response. 而 [IOTAProxy](https://github.com/yillkid/iotaproxy)(此為 fork 後修改過的版本) 專案利用這個特性,將:**驗證 2 個之前的交易 (Tips selection)** 或 **POW (Attach To Tangle)** 等loading 較大的 API 進行轉發.  [Edit Me...](https://drive.google.com/file/d/0B_L2XkGkLXbVLU8xeXpzR1ZEbDQ/view?usp=sharing) PS. 官方版的 [iotaproxy](https://github.com/TimSamshuijzen/iotaproxy) 專案目的正好與修改過的版本相反,官方版其目的在於將 POW (Attach To Tangle) 以外的所有 API 轉發,POW 則留在 local 端的 node 運作,此為因應 [LightWallet](iotasupport.com/lightwallet.shtml) 上的 light node 皆不支援 POW (Attach To Tangle) 的關係。 Installation --- * Clone this repository: ```$ git clone https://github.com/TimSamshuijzen/iotaproxy``` * Enter the "iotaproxy" directory: ```$ cd iotaproxy``` * Install dependencies: ```$ npm install``` Configuration --- Edit index.js to set preferred connection settings. For example: * host: proxy target host * port: proxy target port * localPort: local IRI API port ``` var iotaProxy = require('./lib/iotaproxy.js'); iotaProxy.start( { host: 'http://iota.bitfinex.com', port: 80, localPort: 14266, overrideAttachToTangle: true } ); ``` Run --- Run the proxy server: ```$ node index.js``` ``` IOTA proxy server started Listing on port 14266 Relaying requests to iota.bitfinex.com:80 ``` Test with console Wallet --- 您可以透過修改一個錢包來確認您的交易是否有真的被 Relay. #### Install Wallet * Clone Wallet repo. ```$ git clone https://github.com/bahamapascal/CL-Wallet.git``` * Modify to measure POW duration ```$ vi Wallet.py``` Search with **api.send_transfer**: ``` current_milli_time_0 = datetime.now().microsecond api.send_transfer( depth=7, transfers=prepared_transferes, change_address=change_addy, min_weight_magnitude=15 ) current_milli_time_1 = datetime.now().microsecond total_ms = current_milli_time_1 - current_milli_time_0 print("POW cost " + str(total_ms) + " milliseconds.") ``` * Run ```$ cd CL-Wallet``` ```$ python Wallet.py``` * Resule * [ASUS Tinker Board](https://www.asus.com/us/Single-Board-Computer/Tinker-Board/) ```iota.adapter.BadApiResponse: 400 response from node: This operations cannot be executed: The subtangle has not been updated yet.``` * Relay to node.deviceproof.org ```Relay: Transaction compleated! Cost: 35116 milliseconds.``` Test with Restful API --- You can clone all the test script as below from [iotaproxy_test_script](https://github.com/yillkid/iotaproxy_test_script) | Local hardware | Relay hardware | | -------------- | -------------- | | [ASUS Tinker Board](https://www.asus.com/us/Single-Board-Computer/Tinker-Board/) | [IBM X3550 M4 (7914-IA4) ](https://www.ibm.com/support/home/docdisplay?lndocid=migr-5092816)| | API Command | Local duration(ms) | Relay duration(ms) | | ----------- | ---------- | ----- | | [getNodeInfo](https://iota.readme.io/reference#getnodeinfo)|1|0| | [getNeighbors](https://iota.readme.io/reference#getneighborsactivity)|5|3| | [getTips](https://iota.readme.io/reference#gettips)|107|28| | [findTransactions](https://iota.readme.io/reference#findtransactions)|3|2| | [getBalances](https://iota.readme.io/reference#getbalances)|2|1| | [getTransactionsToApprove](https://iota.readme.io/reference#gettransactionstoapprove)|38574|1| | [attachToTangle](https://iota.readme.io/reference#attachtotangle)|8326|190| | [broadcastTransactions](https://iota.readme.io/reference#interruptattachingtotangle)|1057|32| IOTAProxy in i-Certificate Architecture ---  [Edit Me ...](https://drive.google.com/file/d/0B_L2XkGkLXbVT2VZUl9TaTd3MkE/view?usp=sharing)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up