fn new_state_keys(keys_map: &mut HashMap<ContractAddress, StateKey>,
                  sc_addrs: &[ContractAddress]) -> Result<Vec<StateKey>, EnclaveError> {
    let mut results: Vec<StateKey> = Vec::new();
    for &addr in sc_addrs {
        let mut doc: SealedDocumentStorage<StateKey> = SealedDocumentStorage {
            version: 0x1234, // TODO: what's this?
            data: [0; 32],
        };
        // Generate a new key randomly
        rsgx_read_rand(&mut doc.data)?;

        let mut sealed_log_in = [0u8; SEAL_LOG_SIZE];
        doc.seal(&mut sealed_log_in)?;
        // Save sealed_log to file
        let path = get_document_path(&addr);
        save_sealed_document(&path, &sealed_log_in)?;
        // Add to cache
        match keys_map.insert(addr, doc.data) {
            Some(prev) => println!("New key stored successfully, previous key: {:?}", prev), // TODO: What is that?
            None => println!("Initial key stored successfully"),
        }
        results.push(doc.data);
    }
    Ok(results)
}
/// Creates new state keys both in the cache and as sealed documents
Creates new state keys both in the cache and as sealed documents
Creates new state keys both in the cache and as sealed documents
fn new_state_keys(keys_map: &mut HashMap<ContractAddress, StateKey>,
                  sc_addrs: &[ContractAddress]) -> Result<Vec<StateKey>, EnclaveError> {
    let mut results: Vec<StateKey> = Vec::new();
    for &addr in sc_addrs {
        let mut doc: SealedDocumentStorage<StateKey> = SealedDocumentStorage {
            version: 0x1234, // TODO: what's this?
            data: [0; 32],
        };
        // Generate a new key randomly
        rsgx_read_rand(&mut doc.data)?;
        let mut sealed_log_in = [0u8; SEAL_LOG_SIZE];
        doc.seal(&mut sealed_log_in)?;
        // Save sealed_log to file
        let path = get_document_path(&addr);
        save_sealed_document(&path, &sealed_log_in)?;
        // Add to cache
        match keys_map.insert(addr, doc.data) {
            Some(prev) => println!("New key stored successfully, previous key: {:?}", prev), // TODO: What is that?
            None => println!("Initial key stored successfully"),
        }
        results.push(doc.data);
    }
    Ok(results)
}
fn new_state_keys ( keys_map : & mut HashMap < ContractAddress , StateKey > , sc_addrs : & [ ContractAddress ] ) -> Result < Vec < StateKey > , EnclaveError > { let mut results : Vec < StateKey > = Vec :: new ( ) ; for & addr in sc_addrs { let mut doc : SealedDocumentStorage < StateKey > = SealedDocumentStorage { version : 0x1234 , // TODO: what's this? data : [ 0 ; 32 ] , } ; // Generate a new key randomly rsgx_read_rand ( & mut doc . data ) ? ; let mut sealed_log_in = [ 0u8 ; SEAL_LOG_SIZE ] ; doc . seal ( & mut sealed_log_in ) ? ; // Save sealed_log to file let path = get_document_path ( & addr ) ; save_sealed_document ( & path , & sealed_log_in ) ? ; // Add to cache match keys_map . insert ( addr , doc . data ) { Some ( prev ) => println ! ( " " prev ) , // TODO: What is that? None => println ! ( " " ) , } results . push ( doc . data ) ; } Ok ( results ) }
Creates new state keys both in the cache and as sealed documents
Creates new state keys both in the cache and as sealed documents
keys_map
&mut HashMap<ContractAddress, StateKey>
sc_addrs
&[ContractAddress]
keys_map
&mut HashMap<ContractAddress, StateKey>
sc_addrs
&[ContractAddress]