Function holochain::conductor::p2p_agent_store::p2p_put_all_batch
source · pub async fn p2p_put_all_batch(
env: DbWrite<DbKindP2pAgents>,
rx: Receiver<P2pBatch>
)
Expand description
Inject multiple agent info entries into the peer store in batches.
Examples found in repository?
src/conductor/space.rs (lines 684-687)
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
fn new(
dna_hash: Arc<DnaHash>,
root_db_dir: &DatabaseRootPath,
db_sync_strategy: DbSyncStrategy,
) -> ConductorResult<Self> {
use holochain_p2p::DnaHashExt;
let space = dna_hash.to_kitsune();
let db_sync_level = match db_sync_strategy {
DbSyncStrategy::Fast => DbSyncLevel::Off,
DbSyncStrategy::Resilient => DbSyncLevel::Normal,
};
let cache = DbWrite::open_with_sync_level(
root_db_dir.as_ref(),
DbKindCache(dna_hash.clone()),
db_sync_level,
)?;
let authored_db = DbWrite::open_with_sync_level(
root_db_dir.as_ref(),
DbKindAuthored(dna_hash.clone()),
DbSyncLevel::Normal,
)?;
let dht_db = DbWrite::open_with_sync_level(
root_db_dir.as_ref(),
DbKindDht(dna_hash.clone()),
db_sync_level,
)?;
let p2p_agents_db = DbWrite::open_with_sync_level(
root_db_dir.as_ref(),
DbKindP2pAgents(space.clone()),
db_sync_level,
)?;
let p2p_metrics_db = DbWrite::open_with_sync_level(
root_db_dir.as_ref(),
DbKindP2pMetrics(space),
db_sync_level,
)?;
let conductor_db: DbWrite<DbKindConductor> =
DbWrite::open_with_sync_level(root_db_dir.as_ref(), DbKindConductor, db_sync_level)?;
let (tx, rx) = tokio::sync::mpsc::channel(100);
tokio::spawn(p2p_agent_store::p2p_put_all_batch(
p2p_agents_db.clone(),
rx,
));
let p2p_batch_sender = tx;
let countersigning_workspace = CountersigningWorkspace::new();
let incoming_op_hashes = IncomingOpHashes::default();
let incoming_ops_batch = IncomingOpsBatch::default();
let dht_query_cache = DhtDbQueryCache::new(dht_db.clone().into());
let r = Self {
dna_hash,
cache_db: cache,
authored_db,
dht_db,
p2p_agents_db,
p2p_metrics_db,
p2p_batch_sender,
countersigning_workspace,
incoming_op_hashes,
incoming_ops_batch,
dht_query_cache,
conductor_db,
};
Ok(r)
}