meadow
meadow copied to clipboard
Consolidate Host-side code for both direct and message-based operations
In the Host struct, there's a lot of duplicated functionality between methods like process_tcp and process_udp and Host::get code. Ideally, we should really have different packets result in the Host running those operations on itself. The big issue here is that we're currently doing this in separate threads. That's currently okay because we're directly passing in the thread-safe sled::Db object, but we'll probably need to experiment with different design patterns since there's a lot of self references hanging around. That might just mean writing functions that take self.db that we using the Host-direct methods and then can re-use in process_xyz functions, or look into having something like an inner that we can pass around as a thread-safe object by itself.
Additionally, there's still some .expect methods hanging around that that should be given canonical error paths on the Host-side.
This should also make it easier to add new messages like GetNth in the future.
This has been partially addressed in #75, which now uses host::GenericStore trait-based methods for each transport mechanism. There is still some degree of duplicated code, but the fiddlier parts of this (interacting with the Db and managing Msg <=> GenericMsg <=> Vec<u8> type conversions`) are now using core methods.