| 662 | } |
| 663 | |
| 664 | fn get_operation_heads(&self, scope: OperationScope) -> PristineResult<OperationHeads> { |
| 665 | let table = match self.txn.open_table(OP_HEADS) { |
| 666 | Ok(table) => table, |
| 667 | Err(redb::TableError::TableDoesNotExist(_)) => { |
| 668 | return Err(PristineError::OperationSchemaUnavailable); |
| 669 | } |
| 670 | Err(error) => return Err(error.into()), |
| 671 | }; |
| 672 | let key = crate::operation::encode_operation_scope(scope); |
| 673 | let heads = match table.get(&key)? { |
| 674 | Some(value) => { |
| 675 | decode_operation_heads(value.value()).map_err(operation_serialization_error)? |
| 676 | } |
| 677 | None => OperationHeads::new(Vec::new()), |
| 678 | }; |
| 679 | for head in heads.as_slice() { |
| 680 | if OperationTxnT::get_operation(self, *head)?.is_none() { |
| 681 | return Err(PristineError::OperationNotFound { |
| 682 | id: head.to_string(), |
| 683 | }); |
| 684 | } |
| 685 | } |
| 686 | Ok(heads) |
| 687 | } |
| 688 | |
| 689 | fn list_operation_heads(&self) -> PristineResult<Vec<(OperationScope, OperationHeads)>> { |
| 690 | let table = match self.txn.open_table(OP_HEADS) { |