diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainDotCom.scala b/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainDotCom.scala index 52a657f0b2..99c937777e 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainDotCom.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainDotCom.scala @@ -89,7 +89,7 @@ object BlockchainDotCom { implicit val classicSystem: ActorSystem = context.system.classicSystem implicit val ec: ExecutionContext = context.system.executionContext // We need to add delays between API calls otherwise we get throttled. - Future.sequence((from to to).map(i => after((i - from).toInt.seconds)(getHeader(baseUri, i)))) + Future.sequence((from to to).map(i => after((i - from).toInt * 5.seconds)(getHeader(baseUri, i)))) .map(headers => LatestHeaders(from, headers.flatten.filter(_.blockCount >= from).toSet, Source)) } diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/watchdogs/HeadersOverDns.scala b/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/watchdogs/HeadersOverDns.scala index 1cc2c6d89d..614f32f6c4 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/watchdogs/HeadersOverDns.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/blockchain/watchdogs/HeadersOverDns.scala @@ -62,6 +62,7 @@ object HeadersOverDns { // Headers over DNS is only supported for mainnet. Behaviors.stopped } + case _ => Behaviors.unhandled } } } @@ -85,6 +86,8 @@ object HeadersOverDns { case WrappedDnsFailed(ex) => context.log.warn("bitcoinheaders.net failed to resolve: {}", ex) stopOrCollect(replyTo, currentBlockCount, received, remaining - 1) + + case _ => Behaviors.unhandled } } } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainDotComSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainDotComSpec.scala index 6a2d170269..c6b55e4cfc 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainDotComSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/blockchain/watchdogs/BlockchainDotComSpec.scala @@ -49,23 +49,17 @@ class BlockchainDotComSpec extends ScalaTestWithActorTestKit(ConfigFactory.load( } test("fetch some block headers") { - val blockchainDotCom = testKit.spawn(BlockchainDotCom(Block.LivenetGenesisBlock.hash, 630445, 10)) + val blockchainDotCom = testKit.spawn(BlockchainDotCom(Block.LivenetGenesisBlock.hash, 630449, 4)) val sender = testKit.createTestProbe[LatestHeaders]() blockchainDotCom ! CheckLatestHeaders(sender.ref) val expectedHeaders = Set( - (630445, hex"00008020c9a361f908b41cfa5d4d5a22850719d3213621a6417b07000000000000000000bd7fc42085d949986f6802f90d42f39ca822f840c46d4746ddf370d5eb40ad925645be5e397a111730e92a67"), - (630446, hex"0000002008b915b9dbaddebafcc61e2bf6a5843c370d31d672d90a000000000000000000aa928c1e15fbed85c745302da42118836048addc2114e124a84ec4a4596c688a474cbe5e397a1117aaa9a843"), - (630447, hex"00004020c7e66a0336656b9974a4f51c447f0a5f87899afb99fa07000000000000000000ffb8e39f4aa966d2f4bf80897a91fbb06467e5cc337a93be186d85855485686ed44fbe5e397a1117b46a60a5"), - (630448, hex"0000002000d1e3946de355a4fb2040b11c68ae5a949ea37d5f2e0f0000000000000000002f2ed4b24c0bd0fb4787736c835e415095aba06c412833a3b582abd65b3b33c62c50be5e397a1117b5181a11"), (630449, hex"00e0ff374a01f5bf64dd4a6368999d708d8ddd5eb3ee71dd9fee070000000000000000000d58b9d04b6a8fa68abbf673e50965668853cad896ae27c9949c70e3e4fa128b9756be5e397a1117e170e749"), (630450, hex"0000802069ed618b1e0f87ce804e2624a34f507c13322c8f28b3010000000000000000000e370896b5a57abf5426bc51e82a3fcb626a5af32c9eb8147fe9c513efbb1701235abe5e397a111728cf439c"), (630451, hex"00e0ff3f45367792598312e4cdbbf1caaeceafe38aef17eed8340d00000000000000000047e447403a779461d013581137f66425c609fac6ed426bdba4f83a35f00786f3db5cbe5e397a11173e155226"), - (630452, hex"000000200fce94e6ace8c26d3e9bb1fc7e9b85dc9c94ad51d8b00f000000000000000000ca0a5ba5b2cdba07b8926809e4909278c392587e7c8362dd6bd2a6669affff32715ebe5e397a1117efc39f19"), - (630453, hex"00000020db608b10a44b0b60b556f40775edcfb29d5f39eeeb7f0b000000000000000000312b2dece5824b0cb3153a8ef7a06af70ae68fc2e45a694936cbbd609c747aa56762be5e397a1117fba42eac"), - (630454, hex"0000c0200951bd9340565493bc25101f4f7cbad1d094614ea8010e000000000000000000fd0377e4c6753830fe345657921aface6159e41a57c09be4a6658ca9e2704ff0c665be5e397a11172d2ee501") + (630452, hex"000000200fce94e6ace8c26d3e9bb1fc7e9b85dc9c94ad51d8b00f000000000000000000ca0a5ba5b2cdba07b8926809e4909278c392587e7c8362dd6bd2a6669affff32715ebe5e397a1117efc39f19") ) val headers = sender.expectMessageType[LatestHeaders] - assert(headers.currentBlockCount === 630445) + assert(headers.currentBlockCount === 630449) assert(headers.source === BlockchainDotCom.Source) assert(headers.blockHeaders.map(h => (h.blockCount, BlockHeader.write(h.blockHeader))) === expectedHeaders) }