No longer serialize as JSON-encoded pkcs8

That's supposed to be an ASCII format, but we're not making use
of it. We can switch back to that some day, but if we do, it shouldn't
be JSON-encoded.
This commit is contained in:
Greg Fitzgerald
2018-11-09 16:19:22 -07:00
parent 7c610b216b
commit fea86b2955
6 changed files with 33 additions and 32 deletions

View File

@@ -107,18 +107,22 @@ pub struct Fullnode {
/// Fullnode configuration to be stored in file
pub struct Config {
pub node_info: NodeInfo,
pkcs8: Vec<u8>,
keypair_bytes: Vec<u8>,
}
impl Config {
pub fn new(bind_addr: &SocketAddr, pkcs8: Vec<u8>) -> Self {
let keypair = Keypair::from_bytes(&pkcs8).expect("from_pkcs8 in fullnode::Config new");
pub fn new(bind_addr: &SocketAddr, keypair_bytes: Vec<u8>) -> Self {
let keypair =
Keypair::from_bytes(&keypair_bytes).expect("from_bytes in fullnode::Config new");
let pubkey = keypair.pubkey();
let node_info = NodeInfo::new_with_pubkey_socketaddr(pubkey, bind_addr);
Config { node_info, pkcs8 }
Config {
node_info,
keypair_bytes,
}
}
pub fn keypair(&self) -> Keypair {
Keypair::from_bytes(&self.pkcs8).expect("from_pkcs8 in fullnode::Config keypair")
Keypair::from_bytes(&self.keypair_bytes).expect("from_bytes in fullnode::Config keypair")
}
}