Skip to content

Encoding and channels

Luke Champine requested to merge tests into master

A silly bug was causing an 8x blowup in the size of encoded byte slices/arrays. They are now encoded with optimal efficiency.

Incoming blocks from the Miner and TCPServer are now routed down the same channel. The Environment reads from the channel and calls AcceptBlock() on blocks sequentially as they arrive. Both channels can buffer up to 100 blocks/transactions. This should (hopefully) prevent some synchronization bugs.

One of the cool things here is that the block channel is cast to a chan<- Block before being passed to the Miner, which means it can send but not receive.

The Environment's AcceptBlock and AcceptTransaction functions don't seem terribly necessary now; all they do is shoot their argument down a channel. I can remove them if they aren't needed elsewhere.

Merge request reports