文/溫國兵
這是「區塊鏈技術指北」的第 40 篇文章。
如果對我感興趣,想和我交流,我的微訊號:Wentasy,加我時簡單介紹下自己,並註明來自「區塊鏈技術指北」,同時我會把你拉入微信群。
![EOSIO MySQL 外掛 issue 1](https://i.iter01.com/images/34e937eb0aa25cc30e7bab7394b9c933685753ef2252bfec523eae28be3ba154.png)
題圖來自: © ChainONE / Original / chainon.io
文/溫國兵
0x00 背景
鏈上資料如何轉化為 API 友好的資料,這是一個很重要的話題。因為能夠轉化為 API 友好的資料,對於開發者而言,可以極大地提高效率。目前 EOS 生態有很多外掛,比如 MySQL 外掛、ES 外掛、Kafka 外掛等等。
筆者在測試環境部署了基於 kesar 寫的 MySQL 外掛,結果同步資料時發現有如下的異常。
![EOSIO MySQL 外掛 issue 1](https://i.iter01.com/images/07fe0ec6a8b280649eb44e2424d173942c528fc4b36fcf94aa020bd9c3901175.jpg)
0x01 解決
檢視 nodeos 日誌,可以發現如下異常。
When sync to zhengjinhua1, and nodoes exit. The log as follows:
terminate called after throwing an instance of 'soci::mysql_soci_error'
what(): Out of range value for column 'amount' at row 1 while executing "INSERT INTO tokens(account, amount, symbol) VALUES (:ac, :am, :as) " with :ac="zhengjinhua1", :am=1e+10, :as="UXB".
複製程式碼
我們從日誌中分析得出如下結論:
The amount filed of tokens table defines double(14,4), but 1e+10 means 10 billion, it exceed the maximum. It should change to double(64,4), the command as follows:
ALTER TABLE tokens CHANGE amount amount double(64,4) DEFAULT NULL;
複製程式碼
In addition, I sync the data of maninnet using this sql_db_plugin.
Submit a pr, see at: github.com/NebulaProto…
0x02 小結
MySQL 外掛目前不太成熟,還有很多坑,謹慎入坑。
–EOF–
版權宣告:自由轉載-非商用-非衍生-保持署名(創意共享4.0許可證)
「區塊鏈技術指北」同名 知識星球,二維碼如下,歡迎加入。
![區塊鏈技術指北](https://i.iter01.com/images/3e3cc2ce230b383951577f3271dcbbea8f0f4d0d487009717531917dd0b8ef4f.png)
「區塊鏈技術指北」相關資訊渠道:
- 「區塊鏈技術指北」同名知識星球,t.xiaomiquan.com/ZRbmaU3
- 官網,chainon.io
- 官方部落格,blog.chainon.io
- 官方社群,bbs.chainon.io
- Telegram Channel,t.me/BlockchainA…
- Telegram Group,t.me/bcage
- Twitter,twitter.com/bcageone
- Facebook,www.facebook.com/chainone.or…
- 新浪微博,weibo.com/BlockchainA…
同時,本系列文章會在以下渠道同步更新,歡迎關注:
- 「區塊鏈技術指北」同名微信公眾號(微訊號:BlockchainAge)
- 個人部落格,dbarobin.com
- 知乎,zhuanlan.zhihu.com/robinwen
- 簡書,www.jianshu.com/c/a37698a12…
- Steemit,steemit.com/@robinwen
- Medium,medium.com/@robinwan
- 掘金,robinwen@juejin.im
- EOS LIVE,eos.live/user/robin
- 幣乎,bihu.com/people/2220…
原創不易,讀者可以通過如下途徑打賞,虛擬貨幣、美元、法幣均支援。
- BTC: 3QboL2k5HfKjKDrEYtQAKubWCjx9CX7i8f
- ERC20 Token: 0x8907B2ed72A1E2D283c04613536Fac4270C9F0b3
- PayPal: www.paypal.me/robinwen
- 微信打賞二維碼
![Wechat](https://i.iter01.com/images/f0db480211122bf0e9da324b5e696ec1ea996cc64fee32fb9bf66b764439b0c9.jpg)
–EOF–