1
   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);
  }

THE TRANSACTION IS CALLED LIKE THIS:

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);

         });
Rohan Khanna
  • 123
  • 7
  • What are divopt and ifDivOptExecuted? It's very likely this is throwing by design. – Rob Hitchens Jul 05 '17 at 05:33
  • IfdivOptexecuted is a modifier which checks if a value is true (which i have set to true) and the if condition will evaluate to false i am sure of that ! – Rohan Khanna Jul 05 '17 at 05:36
  • I debugged the error. Too much gas was being used because of the number of assignments and operations. when i commented out the event catcher the code worked perfectly ! – Rohan Khanna Jul 05 '17 at 06:19

1 Answers1

0

I debugged the error. Too much gas was being used because of the number of assignments and operations. when i commented out the event catcher the code worked perfectly !

Rohan Khanna
  • 123
  • 7