-
Notifications
You must be signed in to change notification settings - Fork 0
/
BulkSource.cs
33 lines (29 loc) · 1011 Bytes
/
BulkSource.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Collections.Generic;
using Akka;
using Akka.Streams.Dsl;
using Nethereum.Hex.HexTypes;
using System.Numerics;
using Prometheus;
namespace CirclesLand.BlockchainIndexer.Sources
{
public static class SourceMetrics
{
internal static readonly Counter BlocksEmitted =
Metrics.CreateCounter("indexer_source_emitted_blocks_total", "How many blocks have been emitted by a source.", "source");
}
public static class BulkSource
{
public static Source<HexBigInteger, NotUsed> Create(BigInteger from, BigInteger to)
{
IEnumerable<HexBigInteger> HexBigIntegerRange()
{
for (var i = from; i < to; i++)
{
SourceMetrics.BlocksEmitted.WithLabels("bulk").Inc();
yield return new HexBigInteger(i);
}
}
return Source.FromEnumerator(() => HexBigIntegerRange().GetEnumerator());
}
}
}