ab_farmer/lib.rs
1#![feature(const_block_items, future_join, iter_collect_into, try_blocks)]
2#![cfg_attr(
3 test,
4 expect(
5 clippy::rest_pattern_accessible_field,
6 reason = "Too verbose for tests"
7 )
8)]
9#![warn(rust_2018_idioms, missing_debug_implementations, missing_docs)]
10
11//! `ab-farmer` is both a library and an app for everything related to farming.
12//!
13//! # Library
14//!
15//! Library exposes all the necessary utilities for plotting, maintaining and farming plots.
16//! Conceptually [`farm::Farm`] is an abstraction that contains a plot, a small piece cache and
17//! corresponding metadata. [`single_disk_farm::SingleDiskFarm`] is the primary abstraction that
18//! implements [`farm::Farm`] and encapsulates those components stored on local disk with high-level
19//! API with events that allow to orchestrate farms from the outside (for example in CLI).
20//!
21//! While local farming is one option, there is also a way to have cluster setup, implemented in
22//! [`cluster`] module. Cluster contains a special implementation of [`farm::Farm`] and other
23//! components that are not stored on local disk, but rather are somewhere on the network (typically
24//! LAN). This allows to better manage resources, which is primarily useful for large farmers.
25//! Cluster setup usually consists from heterogeneous machines where different machines are
26//! specialized with different tasks (some machines do farming, some plotting, some both, etc.).
27//! Cluster setup also allows for even greater composition and allows for combining various pieces
28//! of the software from different vendors (like unofficial plotters for example).
29//!
30//! Since various key components are implementations of traits, it is possible to use some part of
31//! the library as is (like farming), while swapping others (like plotting). The library is meant to
32//! be somewhat generic and allowing different composition scenarios.
33//!
34//! # CLI
35//!
36//! CLI provides reference implementation of the farmer software, it wraps library components and
37//! orchestrates them as a final user-facing application.
38//!
39//! CLI exposes many key options to fine tune various aspects, but primarily for experimentation and
40//! improving defaults, the goal is for default behavior to be already as optimal as efficient as
41//! possible.
42//!
43//! # Memory allocation
44//!
45//! CLI uses mimalloc as the global allocator. Allocations are mostly of fixed sizes determined by
46//! the data being processed, and it is up to the allocator to handle them efficiently. Don't add
47//! application-level buffer pools or thread-locals to compensate for the allocator (allocating an
48//! element once and reusing it in a loop is fine).
49
50mod cache_element;
51#[cfg(feature = "cluster")]
52pub mod cluster;
53pub mod disk_piece_cache;
54pub mod farm;
55pub mod farmer_cache;
56pub mod farmer_piece_getter;
57pub mod node_client;
58pub mod plotter;
59pub mod single_disk_farm;
60pub mod thread_pool_manager;
61pub mod utils;
62
63/// Size of the LRU cache for peers.
64pub const KNOWN_PEERS_CACHE_SIZE: u32 = 100;