Not all data needs to be permanent. Some things simply don’t need to become a matter of record, and other things should remain private between two parties. Putting them in the DHT would be a waste of space or, even worse, a privacy risk. It’s also not the fastest or most reliable way to share real-time updates or guarantee a quick response.

Holochain lets two peers directly exchange private messages with each other. When you send a message to another node, it’s encrypted in-transit just like any communication, but it doesn’t get ‘gossiped’ through the DHT. This makes it useful for completely private, end-to-end encrypted messaging.

Holochain exposes a send function to the DNA to allow one agent to send a message to another, and expects the DNA to implement a receive callback to process received messages.

Here’s an example of what happens in a node-to-node message exchange, using a silent auction app.

From within a zome function called place_bid, Alice creates a message that says, “$50 on the black velvet painting of a clown” and calls the send function. Message sending pauses or ‘blocks’ the execution of the place_bid function.

Alice’s Holochain conductor uses the DHT to look up Bob’s current IP address and sends the message to Bob’s device.

Bob’s conductor calls a receive callback in his running DNA instance. It receives the message, registers Alice’s bid as an entry on his source chain, and returns a response containing an acknowledgment of her registered bid.

Bob’s conductor sends the acknowledgement message back to Alice’s conductor.

Alice’s conductor returns Bob’s acknowledgement message to the place_bid function, which records the message on her own source chain so she can claim her painting later.