@@ -103,46 +103,45 @@ async fn process_vote(vote: VoteToProcess) {
103103 }
104104 }
105105 VoteToProcess :: PendingWtnVote ( pair_id, wtn_vote) => {
106- let Some ( ( canister_id, neuron_id) ) = state:: read ( |s| {
106+ if let Some ( ( canister_id, neuron_id) ) = state:: read ( |s| {
107107 s. neuron_pairs ( )
108108 . get ( & pair_id)
109109 . map ( |p| ( s. wtn_governance_canister_id ( ) , p. wtn_neuron_id ( ) ) )
110- } ) else {
111- return ;
112- } ;
113- let args = ManageNeuronArgs {
114- subaccount : neuron_id. to_vec ( ) ,
115- command : Some ( Command :: RegisterVote ( RegisterVote {
116- proposal : Some ( ProposalId {
117- id : wtn_vote. wtn_proposal_id ,
118- } ) ,
119- vote : if wtn_vote. adopt { 1 } else { 2 } ,
120- } ) ) ,
121- } ;
122- let response: CallResult < ( ManageNeuronResponse , ) > =
123- ic_cdk:: call ( canister_id, "manage_neuron" , ( & args, ) ) . await ;
124- state:: mutate ( |s| match response. map ( |r| r. 0 . command ) {
125- Ok ( Some ( CommandResponse :: RegisterVote ( _) ) ) => {
126- s. record_wtn_vote_registered ( pair_id, wtn_vote) ;
127- }
128- Ok ( Some ( CommandResponse :: Error ( error) ) ) => {
129- log ( format ! (
130- "Governance canister returned an error: {error:?}. Args: {args:?}"
131- ) ) ;
132- s. push_vote_to_process ( VoteToProcess :: PendingWtnVote ( pair_id, wtn_vote) ) ;
133- }
134- Ok ( None ) => {
135- log ( format ! (
136- "Governance canister returned an empty response. Args: {args:?}"
137- ) ) ;
138- }
139- Err ( error) => {
140- log ( format ! (
141- "Error calling `manage_neuron`: {error:?}. Args: {args:?}"
142- ) ) ;
143- s. push_vote_to_process ( VoteToProcess :: PendingWtnVote ( pair_id, wtn_vote) ) ;
144- }
145- } ) ;
110+ } ) {
111+ let args = ManageNeuronArgs {
112+ subaccount : neuron_id. to_vec ( ) ,
113+ command : Some ( Command :: RegisterVote ( RegisterVote {
114+ proposal : Some ( ProposalId {
115+ id : wtn_vote. wtn_proposal_id ,
116+ } ) ,
117+ vote : if wtn_vote. adopt { 1 } else { 2 } ,
118+ } ) ) ,
119+ } ;
120+ let response: CallResult < ( ManageNeuronResponse , ) > =
121+ ic_cdk:: call ( canister_id, "manage_neuron" , ( & args, ) ) . await ;
122+ state:: mutate ( |s| match response. map ( |r| r. 0 . command ) {
123+ Ok ( Some ( CommandResponse :: RegisterVote ( _) ) ) => {
124+ s. record_wtn_vote_registered ( pair_id, wtn_vote) ;
125+ }
126+ Ok ( Some ( CommandResponse :: Error ( error) ) ) => {
127+ log ( format ! (
128+ "Governance canister returned an error: {error:?}. Args: {args:?}"
129+ ) ) ;
130+ s. push_vote_to_process ( VoteToProcess :: PendingWtnVote ( pair_id, wtn_vote) ) ;
131+ }
132+ Ok ( None ) => {
133+ log ( format ! (
134+ "Governance canister returned an empty response. Args: {args:?}"
135+ ) ) ;
136+ }
137+ Err ( error) => {
138+ log ( format ! (
139+ "Error calling `manage_neuron`: {error:?}. Args: {args:?}"
140+ ) ) ;
141+ s. push_vote_to_process ( VoteToProcess :: PendingWtnVote ( pair_id, wtn_vote) ) ;
142+ }
143+ } ) ;
144+ }
146145 }
147146 }
148147
0 commit comments