@@ -264,7 +264,7 @@ func ProposeCommit(_commitMessage string) (string, int, error) {
264264 }
265265
266266 // Proposing the commit
267- transaction , err := ditCoordinatorInstance .ProposeCommit (auth , repoHash , big .NewInt (int64 (answerKnowledgeLabel - 1 )), big .NewInt (int64 (120 )), big .NewInt (int64 (120 )))
267+ transaction , err := ditCoordinatorInstance .ProposeCommit (auth , repoHash , big .NewInt (int64 (answerKnowledgeLabel - 1 )), big .NewInt (int64 (180 )), big .NewInt (int64 (180 )))
268268 if err != nil {
269269 if strings .Contains (err .Error (), "insufficient funds" ) {
270270 return "" , 0 , errors .New ("Your account doesn't have enough ETH to pay for the transaction" )
@@ -667,21 +667,21 @@ func Open(_proposalID string) error {
667667// including the ETH and KNW reward in case of a voting for the winning decision
668668// or the losing of ETH and KNW in case of a voting for the losing decision
669669// The first caller who executes this will also trigger the calculation whether the vote passed or not
670- func Finalize (_proposalID string ) (bool , error ) {
670+ func Finalize (_proposalID string ) (bool , bool , error ) {
671671 // Converting the stdin string input of the user into an int
672672 proposalID , _ := strconv .Atoi (_proposalID )
673673
674674 // Searching for this repositories object in the config
675675 repoIndex , err := searchForRepoInConfig ()
676676 if err != nil {
677- return false , err
677+ return false , false , err
678678 }
679679
680680 repoHash := GetHashOfString (config .DitConfig .Repositories [repoIndex ].Name )
681681
682682 connection , err := getConnection ()
683683 if err != nil {
684- return false , err
684+ return false , false , err
685685 }
686686
687687 // Convertig the hex-string-formatted address into an address object
@@ -690,19 +690,19 @@ func Finalize(_proposalID string) (bool, error) {
690690 // Create a new instance of the ditContract to access it
691691 ditCooordinatorInstance , err := getDitCoordinatorInstance (connection )
692692 if err != nil {
693- return false , err
693+ return false , false , err
694694 }
695695
696696 // Create a new instance of the KNWToken contract to access it
697697 KNWTokenInstance , err := getKNWTokenInstance (connection )
698698 if err != nil {
699- return false , err
699+ return false , false , err
700700 }
701701
702702 // Create a new instance of the KNWVoting contract to access it
703703 KNWVotingInstance , err := getKNWVotingInstance (connection )
704704 if err != nil {
705- return false , err
705+ return false , false , err
706706 }
707707
708708 // Searching for the corresponding vote in the votes stored in the config
@@ -716,62 +716,65 @@ func Finalize(_proposalID string) (bool, error) {
716716
717717 // If this user already called the Resolve function for this vote it's not possible anymore
718718 if config .DitConfig .Repositories [repoIndex ].ActiveVotes [voteIndex ].Resolved {
719- return false , errors .New ("You already finalized this vote" )
719+ return false , false , errors .New ("You already finalized this vote" )
720720 }
721721
722722 // Verifying whether the vote has already ended
723723 pollEnded , err := KNWVotingInstance .PollEnded (nil , big .NewInt (int64 (config .DitConfig .Repositories [repoIndex ].ActiveVotes [voteIndex ].KNWVoteID )))
724724 if err != nil {
725- return false , errors .New ("Failed to retrieve vote status" )
725+ return false , false , errors .New ("Failed to retrieve vote status" )
726726 }
727727
728728 // If not, we can't resolve it
729729 if ! pollEnded {
730- return false , errors .New ("The vote hasn't ended yet" )
730+ return false , false , errors .New ("The vote hasn't ended yet" )
731731 }
732732
733733 // Verifying whether the user is a participant of this vote
734734 didCommit , err := KNWVotingInstance .DidCommit (nil , myAddress , big .NewInt (int64 (config .DitConfig .Repositories [repoIndex ].ActiveVotes [voteIndex ].KNWVoteID )))
735735 if err != nil {
736- return false , errors .New ("Failed to retrieve commit status" )
736+ return false , false , errors .New ("Failed to retrieve commit status" )
737737 }
738738
739739 // Retrieve the selected proposal obkect
740740 proposal , err := ditCooordinatorInstance .ProposalsOfRepository (nil , repoHash , big .NewInt (int64 (proposalID )))
741741 if err != nil {
742- return false , errors .New ("Failed to retrieve the new proposal" )
742+ return false , false , errors .New ("Failed to retrieve the new proposal" )
743743 }
744744
745+ // Indicates whether the called was the proposer or not
746+ isProposer := (proposal .Proposer == myAddress )
747+
745748 // If not, we are not allowed to call this function (it would fail)
746749 if ! didCommit && myAddress != proposal .Proposer {
747- return false , errors .New ("You didn't participate in this vote" )
750+ return false , false , errors .New ("You didn't participate in this vote" )
748751 }
749752
750753 // Saving the old ETH balance
751754 oldEthBalance , err := connection .BalanceAt (context .Background (), myAddress , nil )
752755 if err != nil {
753- return false , errors .New ("Failed to retrieve ETH balance" )
756+ return false , false , errors .New ("Failed to retrieve ETH balance" )
754757 }
755758
756759 // Saving the old KNW balance
757760 oldKNWBalance , err := KNWTokenInstance .BalanceOfLabel (nil , myAddress , config .DitConfig .Repositories [repoIndex ].ActiveVotes [voteIndex ].KnowledgeLabel )
758761 if err != nil {
759- return false , errors .New ("Failed to retrieve KNW balance" )
762+ return false , false , errors .New ("Failed to retrieve KNW balance" )
760763 }
761764
762765 // Crerating the transaction (basic values)
763766 auth , err := populateTx (connection )
764767 if err != nil {
765- return false , err
768+ return false , false , err
766769 }
767770
768771 // Resolving the vote
769772 transaction , err := ditCooordinatorInstance .FinalizeVote (auth , repoHash , big .NewInt (int64 (proposalID )))
770773 if err != nil {
771774 if strings .Contains (err .Error (), "insufficient funds" ) {
772- return false , errors .New ("Your account doesn't have enough ETH to pay for the transaction" )
775+ return false , false , errors .New ("Your account doesn't have enough ETH to pay for the transaction" )
773776 }
774- return false , errors .New ("Failed to finalize the vote: " + err .Error ())
777+ return false , false , errors .New ("Failed to finalize the vote: " + err .Error ())
775778 }
776779
777780 // Waiting for the resolve transaction to be mined
@@ -785,7 +788,7 @@ func Finalize(_proposalID string) (bool, error) {
785788 // Checking the balance of the user every 5 seconds, if it changed, a transaction was executed
786789 newEthBalance , err = connection .BalanceAt (context .Background (), myAddress , nil )
787790 if err != nil {
788- return false , errors .New ("Failed to retrieve opening status" )
791+ return false , false , errors .New ("Failed to retrieve opening status" )
789792 }
790793 // If we are waiting for more than 2 minutes, the transaction might have failed
791794 if waitingFor > 180 {
@@ -800,13 +803,13 @@ func Finalize(_proposalID string) (bool, error) {
800803 // Saving the new KNW balance after resolving the vote
801804 newKNWBalance , err := KNWTokenInstance .BalanceOfLabel (nil , myAddress , config .DitConfig .Repositories [repoIndex ].ActiveVotes [voteIndex ].KnowledgeLabel )
802805 if err != nil {
803- return false , errors .New ("Failed to retrieve KNW balance" )
806+ return false , false , errors .New ("Failed to retrieve KNW balance" )
804807 }
805808
806809 // Retrieving the outcome of the vote
807810 pollPassed , err := KNWVotingInstance .IsPassed (nil , big .NewInt (int64 (config .DitConfig .Repositories [repoIndex ].ActiveVotes [voteIndex ].KNWVoteID )))
808811 if err != nil {
809- return false , errors .New ("Failed to retrieve vote outcome" )
812+ return false , false , errors .New ("Failed to retrieve vote outcome" )
810813 }
811814
812815 fmt .Printf ("\n " )
@@ -847,7 +850,7 @@ func Finalize(_proposalID string) (bool, error) {
847850 // Saving the config back to the file
848851 err = config .Save ()
849852 if err != nil {
850- return false , nil
853+ return false , false , err
851854 }
852855
853856 if config .DitConfig .DemoModeActive && len (config .DitConfig .Repositories [repoIndex ].ActiveVotes [voteIndex ].DemoChoices ) == 3 {
@@ -858,7 +861,7 @@ func Finalize(_proposalID string) (bool, error) {
858861 }
859862 }
860863 }
861- return pollPassed , nil
864+ return pollPassed , isProposer , nil
862865}
863866
864867// GetVoteInfo will print information about a vote
@@ -1125,16 +1128,16 @@ func initDitRepository(_ditCoordinatorInstance *ditCoordinator.DitCoordinator, _
11251128 voteSettings [2 ] = big .NewInt (0 )
11261129
11271130 // TODO
1128- voteSettings [3 ] = big .NewInt (120 )
1131+ voteSettings [3 ] = big .NewInt (150 )
11291132
11301133 // TODO
1131- voteSettings [4 ] = big .NewInt (121 )
1134+ voteSettings [4 ] = big .NewInt (86400 )
11321135
11331136 // TODO
1134- voteSettings [5 ] = big .NewInt (120 )
1137+ voteSettings [5 ] = big .NewInt (150 )
11351138
11361139 // TODO
1137- voteSettings [6 ] = big .NewInt (121 )
1140+ voteSettings [6 ] = big .NewInt (86400 )
11381141
11391142 // Prompting the user to provide 1 to 3 knowledge-labels for this repository
11401143 helpers .PrintLine ("Please provide knowledge labels that will be used for this repository:" , 0 )
0 commit comments