RPC methods get pubsub topics from chain spec

This commit is contained in:
Age Manning 2019-04-03 13:50:11 +11:00
parent e9181e120c
commit f54bd79f84
No known key found for this signature in database
GPG Key ID: 05EED64B79E06A93
3 changed files with 9 additions and 5 deletions

View File

@ -4,7 +4,8 @@ use beacon_chain::{BeaconChain, BeaconChainTypes, BlockProcessingOutcome};
use eth2_libp2p::rpc::methods::*;
use eth2_libp2p::rpc::{RPCRequest, RPCResponse, RequestId};
use eth2_libp2p::PeerId;
use slog::{debug, error, info, o, warn};
use slog::{debug, error, info, o, trace, warn};
use ssz::TreeHash;
use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;

View File

@ -136,8 +136,11 @@ impl<T: BeaconChainTypes> AttestationService for AttestationServiceInstance<T> {
"type" => "valid_attestation",
);
// get the network topic to send on
let topic_string = self.chain.get_spec().shard_topic_prefix.clone();
// valid attestation, propagate to the network
let topic = types::TopicBuilder::new("attestations".to_string()).build();
let topic = types::TopicBuilder::new(topic_string).build();
let message = PubsubMessage::Attestation(attestation);
self.network_chan

View File

@ -104,9 +104,9 @@ impl<T: BeaconChainTypes> BeaconBlockService for BeaconBlockServiceInstance<T> {
"block_root" => format!("{}", block_root),
);
// TODO: Obtain topics from the network service properly.
let topic =
types::TopicBuilder::new("beacon_chain".to_string()).build();
// get the network topic to send on
let topic_string = self.chain.get_spec().beacon_chain_topic.clone();
let topic = types::TopicBuilder::new(topic_string).build();
let message = PubsubMessage::Block(block);
// Publish the block to the p2p network via gossipsub.