#Basis
OpenDHT is a Kademlia-based DHT which creates a key-value store. Keys can be arbitrary, and values are allowed to collide. Network queries will return multiple values if more than one is associated with the same key.
#Design
The basic structure of OpenDHT can be used to create a network for efficient lookup of individual transactions by outpoint.
The purpose of the network is to answer two questions:
- Does the input to a transaction I've received actually exist?
- Has a given transaction output been spent?
Keys in this network are outpoint (txid + output index). A transaction matches an outpoint either if it creates the outpoint, or if it spends it.
This means for every query of a key in the network, the queriant would expect to receive zero, one, or two transactions in response.
Nodes which respond to a query package the transaction into a message which also contains the applicable merkle proofs to show which block mined the transaction(s) in question.
#Response format
The response to a query is in the form of a serialized protobuf message:
message QueryResult {
repeated Transaction = 1;
}
message Transaction {
optional MerkleProof = 1;
bytes Data = 2;
}
message MerkleProof {
oneof left {
bytes lefthash = 1;
MerkleProof leftchild = 2;
}
oneof right {
bytes righthash = 3;
MerkleProof rightchild = 4;
}
}