def _create_config_txn(pubkey, signing_key, setting_key_value): """Creates an individual sawtooth_config transaction for the given key and value. """ setting_key = setting_key_value[0] setting_value = setting_key_value[1] nonce = str(datetime.datetime.utcnow().timestamp()) proposal = ConfigProposal(setting=setting_key, value=setting_value, nonce=nonce) payload = ConfigPayload(data=proposal.SerializeToString(), action=ConfigPayload.PROPOSE).SerializeToString() header = TransactionHeader( signer_pubkey=pubkey, family_name='sawtooth_config', family_version='1.0', inputs=_config_inputs(setting_key), outputs=_config_outputs(setting_key), dependencies=[], payload_encoding='application/protobuf', payload_sha512=hashlib.sha512(payload).hexdigest(), batcher_pubkey=pubkey).SerializeToString() signature = signing.sign(header, signing_key) return Transaction(header=header, header_signature=signature, payload=payload)
def _create_propose_txn(pubkey, signing_key, setting_key_value): """Creates an individual sawtooth_config transaction for the given key and value. """ setting_key, setting_value = setting_key_value nonce = str(datetime.datetime.utcnow().timestamp()) proposal = ConfigProposal(setting=setting_key, value=setting_value, nonce=nonce) payload = ConfigPayload(data=proposal.SerializeToString(), action=ConfigPayload.PROPOSE) return _make_txn(pubkey, signing_key, setting_key, payload)
def _create_vote_txn(pubkey, signing_key, proposal_id, setting_key, vote_value): """Creates an individual sawtooth_config transaction for voting on a proposal for a particular setting key. """ if vote_value == 'accept': vote_id = ConfigVote.ACCEPT else: vote_id = ConfigVote.REJECT vote = ConfigVote(proposal_id=proposal_id, vote=vote_id) payload = ConfigPayload(data=vote.SerializeToString(), action=ConfigPayload.VOTE) return _make_txn(pubkey, signing_key, setting_key, payload)