|
|
@@ -84,24 +84,24 @@ struct Args {
|
|
|
rpc_listen: Url,
|
|
|
|
|
|
#[structopt(long)]
|
|
|
- /// P2P accept address
|
|
|
- p2p_accept: Option<SocketAddr>,
|
|
|
+ /// P2P accept address for the syncing protocol
|
|
|
+ sync_p2p_accept: Option<SocketAddr>,
|
|
|
|
|
|
#[structopt(long)]
|
|
|
- /// P2P external address
|
|
|
- p2p_external: Option<SocketAddr>,
|
|
|
+ /// P2P external address for the syncing protocol
|
|
|
+ sync_p2p_external: Option<SocketAddr>,
|
|
|
|
|
|
#[structopt(long, default_value = "8")]
|
|
|
- /// Connection slots
|
|
|
- slots: u32,
|
|
|
+ /// Connection slots for the syncing protocol
|
|
|
+ sync_slots: u32,
|
|
|
|
|
|
#[structopt(long)]
|
|
|
- /// Connect to seed (repeatable flag)
|
|
|
- seed: Vec<SocketAddr>,
|
|
|
+ /// Connect to seed for the syncing protocol (repeatable flag)
|
|
|
+ sync_seed: Vec<SocketAddr>,
|
|
|
|
|
|
#[structopt(long)]
|
|
|
- /// Connect to peer (repeatable flag)
|
|
|
- peer: Vec<SocketAddr>,
|
|
|
+ /// Connect to peer for the syncing protocol (repeatable flag)
|
|
|
+ sync_peer: Vec<SocketAddr>,
|
|
|
|
|
|
#[structopt(long, default_value = "600")]
|
|
|
/// Airdrop timeout limit in seconds
|
|
|
@@ -114,6 +114,10 @@ struct Args {
|
|
|
#[structopt(short, parse(from_occurrences))]
|
|
|
/// Increase verbosity (-vvv supported)
|
|
|
verbose: u8,
|
|
|
+
|
|
|
+ #[structopt(short)]
|
|
|
+ /// Genesis time
|
|
|
+ genesis_time: i64,
|
|
|
}
|
|
|
|
|
|
pub struct Faucetd {
|
|
|
@@ -213,6 +217,11 @@ impl Faucetd {
|
|
|
};
|
|
|
drop(map);
|
|
|
|
|
|
+ if *self.synced.lock().await == false {
|
|
|
+ error!("airdrop(): Blockchain is not yet synced");
|
|
|
+ return jsonrpc::error(InternalError, None, id).into()
|
|
|
+ }
|
|
|
+
|
|
|
// TODO: Token ID decision
|
|
|
// TODO: Rename this function to tx build
|
|
|
let tx = match self
|
|
|
@@ -291,7 +300,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
|
|
|
|
|
// Initialize validator state
|
|
|
// TODO: genesis_ts should be some hardcoded constant
|
|
|
- let genesis_ts = Timestamp(1650103269);
|
|
|
+ let genesis_ts = Timestamp(args.genesis_time);
|
|
|
let genesis_data = match args.chain.as_str() {
|
|
|
"mainnet" => *MAINNET_GENESIS_HASH_BYTES,
|
|
|
"testnet" => *TESTNET_GENESIS_HASH_BYTES,
|
|
|
@@ -311,11 +320,11 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
|
|
// P2P network. The faucet doesn't participate in consensus, so we only
|
|
|
// build the sync protocol.
|
|
|
let network_settings = net::Settings {
|
|
|
- inbound: args.p2p_accept,
|
|
|
- outbound_connections: args.slots,
|
|
|
- external_addr: args.p2p_external,
|
|
|
- peers: args.peer.clone(),
|
|
|
- seeds: args.seed.clone(),
|
|
|
+ inbound: args.sync_p2p_accept,
|
|
|
+ outbound_connections: args.sync_slots,
|
|
|
+ external_addr: args.sync_p2p_external,
|
|
|
+ peers: args.sync_peer.clone(),
|
|
|
+ seeds: args.sync_seed.clone(),
|
|
|
..Default::default()
|
|
|
};
|
|
|
|
|
|
@@ -325,7 +334,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
|
|
info!("Registering block sync P2P protocols...");
|
|
|
let _state = state.clone();
|
|
|
registry
|
|
|
- .register(!net::SESSION_SEED, move |channel, p2p| {
|
|
|
+ .register(net::SESSION_ALL, move |channel, p2p| {
|
|
|
let state = _state.clone();
|
|
|
async move { ProtocolSync::init(channel, state, p2p, false).await.unwrap() }
|
|
|
})
|
|
|
@@ -333,7 +342,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
|
|
|
|
|
let _state = state.clone();
|
|
|
registry
|
|
|
- .register(!net::SESSION_SEED, move |channel, p2p| {
|
|
|
+ .register(net::SESSION_ALL, move |channel, p2p| {
|
|
|
let state = _state.clone();
|
|
|
async move { ProtocolTx::init(channel, state, p2p).await.unwrap() }
|
|
|
})
|