I am doing a project involving finding a suffix string given a prefix --for instance, "aaa", so that that its hashed value (SHA256) has a certain pattern -- for example, starting with "123".
My method of finding the required hash key is to generate the suffix string in an ordered way: first try all the string with one character -- basically it goes through the ASCII printable code chart, 95 trials in total. If the required hash key is not found, then try all the string with two characters (95*95 trails)... and so on so forth.
I am also required to use akka actor model to let multiple actors get involved in solving this problem concurrently. (The number of actors is an input)
Any idea about how to efficiently divide the total problem to multiple actors using this pattern? Or anyone has a better solution to this problem?
You can group your workers under a BalancingPool which will automatically distribute work to idle actors, with the manager and worker actors using work pulling to prevent the mailbox from growing too large.
work-request
and work-complete
. Work-request
is called by a worker when it has completed X
tasks (where X
is, say, 10), signalling the manager to add X
more tasks to the BalancingPool
. Work-complete
is called when a worker has found an appropriate string prefix, at which point the manager sends out a stop
command to the BalancingPool
instructing it to immediately terminate and to also terminate its workers. Aside from this, the manager is responsible for initially filling the BalancingPool
with sufficient prefixes for the workers to test (say, 20 * workerCount), and refilling the pool every time it receives a work-request
message.test-prefix
, which contains a string prefix for the worker to test. It also needs to maintain a count of messages that it has received and processed, and when this count reaches X
then it is zeroed and the worker sends a work-request
message to the manager.Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments