diff --git a/black.lst b/black.lst new file mode 100644 index 00000000000..fb1fcbeccd9 --- /dev/null +++ b/black.lst @@ -0,0 +1,8 @@ +pizza_mandate_apology(uint256) +gasprice_bit_ether(int128) +available_assert_time(uint16,uint64) +collate_propagate_storage(bytes16) +ideal_warn_timed(uint256,uint128) +link_classic_internal(uint64,int64) +many_msg_babbage(bytes1) +coral_cable_news(uint256) diff --git a/src/main/kotlin/org/ethereum/lists/methodsignatures/ImportOnline4ByteDirectory.kt b/src/main/kotlin/org/ethereum/lists/methodsignatures/ImportOnline4ByteDirectory.kt index f280c911b2e..64830ab7df8 100644 --- a/src/main/kotlin/org/ethereum/lists/methodsignatures/ImportOnline4ByteDirectory.kt +++ b/src/main/kotlin/org/ethereum/lists/methodsignatures/ImportOnline4ByteDirectory.kt @@ -6,11 +6,16 @@ import com.beust.klaxon.Parser import okhttp3.OkHttpClient import okhttp3.Request import org.kethereum.methodsignatures.FileBackedMethodSignatureStore +import java.io.File +import java.util.concurrent.TimeUnit const val PAGE_SIZE = 2000 const val url = "https://www.4byte.directory/api/v1/signatures/?page_size=$PAGE_SIZE&ordering=created_at" -val client = OkHttpClient() +val client = OkHttpClient.Builder().apply { + readTimeout(42, TimeUnit.SECONDS) +}.build() + val outDir = signatureDirectory.apply { mkdirs() } var total = 0 @@ -20,6 +25,8 @@ fun main(args: Array) { } private fun import(url: String) { + val blackList = File("black.lst").readLines().toSet() + val store = FileBackedMethodSignatureStore(outDir) val request = Request.Builder().url(url).build() @@ -35,9 +42,11 @@ private fun import(url: String) { array.map { it as JsonObject }.forEach { val hexSignature = it["hex_signature"] as String val textSignature = it["text_signature"] as String - if (store.upsert(hexSignature.replace("0x", ""), textSignature)) { - new++ - total++ + if (!blackList.contains(textSignature)) { + if (store.upsert(hexSignature.replace("0x", ""), textSignature)) { + new++ + total++ + } } } println("processed: ${array.size} - imported: $new - total: $total")