Testrpc
錯誤:處理事務時出現 VM 異常:TEST RPC 上的氣體不足
function allowServiceProvider(bytes32 _name,uint _votes) ifDivOptExecuted { // CSD can allow a service provider to submit its customers votes if(_votes > divOpt.votingRightsMax - divOpt.votingRightsUsed){ // throw in case you give more votes to the service provider than allowed throw; } // used to dynamically map index to structure in array of structs // to be refactored.. address _sp =msg.sender; providerOf[_sp].name = _name; providerOf[_sp].votingRightsMax =_votes; providerOf[_sp].votingRightsUsed = 0; providerOf[_sp].active = true; SpStatus('Service Provider allowed by CSD (name,votes)',_name,_votes); }
交易是這樣呼叫的:
DividendOptionContract.deployed().then(function(instance) { return instance.allowServiceProvider(name,votes,{from:web3.eth.accounts[5] }); }).then(function(result) { save_th(result.tx,type) console.log("done"); }).catch(function(e){ console.log(e); });
我調試了錯誤。由於任務和操作的數量,使用了太多的氣體。當我註釋掉事件捕捉器時,程式碼執行良好!