Skip to content

Instantly share code, notes, and snippets.

@kylemccollom
Created December 17, 2018 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylemccollom/5b371e58dd3f0dfbfe33841b93ecd983 to your computer and use it in GitHub Desktop.
Save kylemccollom/5b371e58dd3f0dfbfe33841b93ecd983 to your computer and use it in GitHub Desktop.
batch match {
 // this is the first of the batch
 case Nil =>
  // add this payment to the batch
  context.become(ready(accnKey, accn, replyTo, Seq(payment)))
  // remind myself in 1 second from now to flush the batch
  context.system.scheduler.scheduleOnce(1.second, self, Flush)
 // this is the last that can fit inside the batch
 case _ if batch.size == MaxTxnLength - 1 =>
  // transact the batch right now
  transmit(payment +: batch)
  // clear the batch
  context.become(ready(accnKey, accn.withIncSeq, replyTo))
 // it’s not the first payment, nor the last
 case _ =>
  // add this payment to the batch
  context.become(ready(accnKey, accn, replyTo, payment +: batch))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment