Пример #1
0
 def make_post(self, group_id, owner_id, data, post_key, proof_of_work_args):
 
     timestamp = ut.current_time()
 
     data_hash = ut.hash_function(data)
 
     request_string = ut.serialize_request(
             ['MAKE_POST', timestamp, self.node_name, group_id, owner_id, data_hash])
 
     post_id = ut.hash_function(request_string)
 
     post_signature = None
     if post_key != None:
         post_signature = post_key.sign(post_id)
 
     proof_of_work = None
     if proof_of_work_args != None:
         proof_of_work = ut.make_proof_of_work(proof_of_work_args, post_id)
 
     resp = self.client_raw.make_post(
             timestamp, self.node_name, group_id, owner_id,
             data_hash, post_id, data,
             post_signature, proof_of_work)[0]
 
     gen = (post_id, timestamp, data_hash, post_signature, proof_of_work)
 
     return resp, gen
Пример #2
0
 def read_last_post_time(self, group_id, owner_id, group_read_key, proof_of_work_args):
     timestamp = ut.current_time()
 
     request_string = ut.serialize_request(
             ['READ_LAST_POST_TIME', timestamp, self.node_name, group_id, owner_id])
 
     read_signature = None
     if group_read_key != None:
         read_signature = group_read_key.sign(request_string)
 
     proof_of_work = None
     if proof_of_work_args != None:
         proof_of_work = ut.make_proof_of_work(proof_of_work_args, request_string)
 
     return self.client_raw.read_last_post_time(
             timestamp, self.node_name, group_id, owner_id, read_signature, proof_of_work)[0]
Пример #3
0
 def delete_post(self, group_id, owner_id, post_id, delete_key, proof_of_work_args):
 
     timestamp = ut.current_time()
 
     request_string = ut.serialize_request(
             ['DELETE_POST', timestamp, self.node_name, group_id, owner_id, post_id])
 
     delete_signature = None
     if delete_key != None:
         delete_signature = delete_key.sign(request_string)
 
     proof_of_work = None
     if proof_of_work_args != None:
         proof_of_work = ut.make_proof_of_work(proof_of_work_args, request_string)
 
     return self.client_raw.delete_post(
             timestamp, self.node_name, group_id, owner_id, post_id,
             delete_signature, proof_of_work)[0]
Пример #4
0
 def send_message(
         self, to_user, to_user_key_hash,
         from_user, from_key,
         message, proof_of_work_args):
 
     timestamp = ut.current_time()
 
     message_hash = ut.hash_function(message)
 
     from_user_key_hash = None
     if from_key != None:
         from_user_key_hash = from_key.public_key_hash
 
     request_string = ut.serialize_request(
             ['SEND_MESSAGE', timestamp, self.node_name,
              to_user, to_user_key_hash,
              from_user, from_user_key_hash,
              message_hash])
 
     message_id = ut.hash_function(request_string)
 
     from_signature = None
     if from_key != None:
         from_signature = from_key.sign(message_id)
 
     proof_of_work = None
     if proof_of_work_args != None:
         proof_of_work = ut.make_proof_of_work(proof_of_work_args, message_id)
 
     resp = self.client_raw.send_message(
             timestamp, self.node_name,
             to_user, to_user_key_hash,
             from_user, from_user_key_hash,
             message_hash,
             message_id, message,
             from_signature, proof_of_work)[0]
 
     return resp, (message_id, timestamp, message_hash, from_signature, proof_of_work)
Пример #5
0
 def read_post_list(self,
                    group_id, owner_id,
                    start_time, end_time, max_records, order,
                    group_read_key, proof_of_work_args):
 
     timestamp = ut.current_time()
 
     request_string = ut.serialize_request(
             ['READ_POST_LIST', timestamp, self.node_name,
              group_id, owner_id,
              start_time, end_time, max_records, order])
 
     read_signature = None
     if group_read_key != None:
         read_signature = group_read_key.sign(request_string)
 
     proof_of_work = None
     if proof_of_work_args != None:
         proof_of_work = ut.make_proof_of_work(proof_of_work_args, request_string)
  
     return self.client_raw.read_post_list(
             timestamp, self.node_name, group_id, owner_id,
             start_time, end_time, max_records, order,
             read_signature, proof_of_work)[0]