This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.18; | |
import "./ERC20Interface.sol"; | |
/** | |
* Contract that will forward any incoming Ether to the creator of the contract | |
*/ | |
contract Forwarder { | |
// Address to which any funds sent to this contract will be forwarded | |
address public parentAddress; | |
event EthForwarded(address indexed from, address indexed to, uint256 value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Sender { | |
function () payable {} | |
function transfer(address _receiver) payable { | |
_receiver.transfer(100); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature | Akka | Akka Typed | Monix | ZIO | |
---|---|---|---|---|---|
Effect wrapper | Future | Future | Task | IO | |
Evaluation | Eager | Hybrid: lazy behavior & eager Futures | Lazy | Lazy | |
Communication channel type-safety | No | Yes | Yes | Yes including errors | |
Communication channel | ActorRef | ActorRef[T] | MVar[T]/MQueue[T] | IOQueue[T] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handleMessage(msg: CrawlerMessage, | |
data: CrawlerData | |
): IO[Nothing, CrawlerData] = msg match { | |
case Start(url) => | |
crawlUrl(data, url) | |
case CrawlResult(url, links) => | |
val data2 = data.copy(inProgress = data.inProgress - url) | |
links.foldM(data2) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handleMessage(msg: CrawlerMessage, | |
data: CrawlerData | |
): IO[Nothing, CrawlerData] = msg match { | |
case Start(url) => | |
crawlUrl(data, url) | |
case CrawlResult(url, links) => | |
val data2 = data.copy(inProgress = data.inProgress - url) | |
links.foldM(data2) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def crawlUrl(data: CrawlerData, url: Url): IO[Nothing, CrawlerData] = { | |
if (!data.visitedLinks.contains(url)) { | |
workerFor(data, url.host).flatMap { | |
case (data2, workerQueue) => | |
workerQueue.offer(url).map { _ => | |
data2.copy( | |
visitedLinks = data.visitedLinks + url, | |
inProgress = data.inProgress + url | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override def receive: Receive = { | |
case Crawl(url) => | |
// ... | |
case HttpGetResult(url, Success(body)) => | |
getInProgress = false | |
startHttpGetIfPossible() | |
val links = parseLinks(body) | |
master ! CrawlResult(url, links) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override def receive: Receive = { | |
case Crawl(url) => | |
urlsPending = urlsPending :+ url | |
startHttpGetIfPossible() | |
// ... | |
} | |
private def startHttpGetIfPossible(): Unit = { | |
urlsPending match { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override def receive: Receive = { | |
case Start(start) => | |
crawlUrl(start) | |
case CrawlResult(url, links) => | |
inProgress -= url | |
links.foreach { link => | |
crawlUrl(link) | |
referenceCount = referenceCount.updated(link.host, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def crawlUrl(url: Url): Unit = { | |
if (!visitedLinks.contains(url)) { | |
visitedLinks += url | |
inProgress += url | |
actorFor(url.host) ! Crawl(url) | |
} | |
} | |
private def actorFor(host: Host): ActorRef = { | |
workers.get(host) match { |