use of co.rsk.db.importer.BootstrapURLProvider in project rskj by rsksmart.
the class BootstrapIndexRetrieverTest method retrievePublicKey.
@Test
public void retrievePublicKey() throws IOException {
ObjectMapper objectMapper = mock(ObjectMapper.class);
BootstrapDataIndex bdi = new BootstrapDataIndex(Collections.singletonList(new BootstrapDataEntry(1, "", "db", "hash", new BootstrapDataSignature("r", "s"))));
when(objectMapper.readValue(any(URL.class), eq(BootstrapDataIndex.class))).thenReturn(bdi);
BootstrapURLProvider bootstrapUrlProvider = mock(BootstrapURLProvider.class);
when(bootstrapUrlProvider.getFullURL(any())).thenReturn(new URL("http://localhost"));
BootstrapIndexRetriever bootstrapIndexRetriever = new BootstrapIndexRetriever(Collections.singletonList("key1"), bootstrapUrlProvider, objectMapper);
List<BootstrapDataIndex> indices = bootstrapIndexRetriever.retrieve();
Assert.assertTrue(indices.contains(bdi));
}
use of co.rsk.db.importer.BootstrapURLProvider in project rskj by rsksmart.
the class RskContext method getBootstrapImporter.
public synchronized BootstrapImporter getBootstrapImporter() {
checkIfNotClosed();
if (bootstrapImporter == null) {
RskSystemProperties systemProperties = getRskSystemProperties();
List<String> publicKeys = systemProperties.importTrustedKeys();
int minimumRequired = publicKeys.size() / 2 + 1;
if (minimumRequired < 2) {
logger.warn("Configuration has less trusted sources than the minimum required {} of 2", minimumRequired);
minimumRequired = 2;
}
BootstrapURLProvider bootstrapUrlProvider = new BootstrapURLProvider(systemProperties.importUrl());
bootstrapImporter = new BootstrapImporter(getBlockStore(), getTrieStore(), blockFactory, new BootstrapDataProvider(new BootstrapDataVerifier(), new BootstrapFileHandler(bootstrapUrlProvider, new Unzipper()), new BootstrapIndexCandidateSelector(publicKeys, minimumRequired), new BootstrapIndexRetriever(publicKeys, bootstrapUrlProvider, new ObjectMapper()), minimumRequired));
}
return bootstrapImporter;
}
Aggregations