+class _LedgerNode:
+ _next: Optional['_DatBlock'] = None
+
+ def _set_neighbor(
+ self,
+ new_this: Optional[Union['_DatBlock', '_StartNode']],
+ this: str,
+ that: str,
+ ) -> None:
+ if (old_this := getattr(self, f'_{this}')):
+ setattr(old_this, f'_{that}', None)
+ if new_this:
+ if (new_this_that := getattr(new_this, f'_{that}')):
+ setattr(new_this_that, f'_{this}', None)
+ setattr(new_this, f'_{that}', self)
+ setattr(self, f'_{this}', new_this)
+
+ @property
+ def next(self) -> Optional['_DatBlock']:
+ 'Successor in chain.'
+ return self._next
+
+ @next.setter
+ def next(self, new_next: Optional['_DatBlock']) -> None:
+ self._set_neighbor(new_next, 'next', 'prev')
+
+
+class _StartNode(_LedgerNode):
+ pass
+
+
+class _DatBlock(_LinesBlock, _LedgerNode):