예제 #1
0
 def __getitem__(self, hash_and_pc):
     res = self.txos.get_by_hash(_hash(hash_and_pc))
     if not res:
         raise KeyError(hash_and_pc)
     utxo = IOput()
     utxo.deserialize(res)
     return utxo
예제 #2
0
 def remove(self, n):
     self.commitments.remove(n)
     ser_removed_outputs = self.txos.remove(n)
     removed_outputs = []
     for _ser in ser_removed_outputs:
         utxo = IOput()
         utxo.deserialize(_ser)
         removed_outputs.append(utxo)
     return removed_outputs
예제 #3
0
 def find(self, hash_and_pc):
     '''
     In contrast with __getitem__ find will try to find even spent
     outputs for other (syncing) nodes.
   '''
     res = self.txos.find_by_hash(_hash(hash_and_pc))
     if not res:
         raise KeyError(hash_and_pc)
     utxo = IOput()
     utxo.deserialize(res)
     return utxo
예제 #4
0
 def rollback(self, pruned_inputs, num_of_added_outputs, prev_state):
     for r_i in pruned_inputs:
         if self.storage_space.utxo_index:
             #r_i[0][2] is serialized txo (0 is txo, 2 is serialized object)
             utxo = IOput()
             utxo.deserialize(r_i[0][2])
             self.storage_space.utxo_index.add_utxo(utxo)
         self.confirmed.unspend(r_i)
     outputs_for_mempool = self.confirmed.remove(num_of_added_outputs)
     for _o in outputs_for_mempool:
         self.mempool[_o.serialized_index] = _o
         self.storage_space.utxo_index.remove_utxo(_o)
     self.confirmed.set_state(prev_state)