def apply(self, transaction, state): txn_header = TransactionHeader() txn_header.ParseFromString(transaction.header) pubkey = txn_header.signer_pubkey auth_type = _get_auth_type(state) auth_keys = _get_auth_keys(state) if len(auth_keys) > 0 and pubkey not in auth_keys: raise InvalidTransaction( '{} is not authorized to change settings'.format(pubkey)) config_payload = ConfigPayload() config_payload.ParseFromString(transaction.payload) if auth_type == 'Ballot': return self._apply_ballot_config(pubkey, config_payload, auth_keys, state) elif auth_type == 'None': return self._apply_noauth_config(pubkey, config_payload, state) else: LOGGER.error('auth_type %s should not have been allowed', auth_type) raise InternalError( 'auth_type {} should not have been allowed'.format(auth_type))
def apply(self, transaction, state): txn_header = TransactionHeader() txn_header.ParseFromString(transaction.header) pubkey = txn_header.signer_pubkey auth_keys = _get_auth_keys(state) if len(auth_keys) > 0 and pubkey not in auth_keys: raise InvalidTransaction( '{} is not authorized to change settings'.format(pubkey)) config_payload = ConfigPayload() config_payload.ParseFromString(transaction.payload) if config_payload.action == ConfigPayload.PROPOSE: return self._apply_proposal( auth_keys, pubkey, config_payload.data, state) elif config_payload.action == ConfigPayload.VOTE: return self._apply_vote(pubkey, config_payload.data, auth_keys, state) else: raise InvalidTransaction( "'action' must be one of {PROPOSE, VOTE} in 'Ballot' mode")