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