Files
papers/lux-fpc-consensus/sections/15-implementation-details.tex
zeekay abf99d05fc papers: reorganize into per-paper dirs, add Antje Worring as co-author
Restructured from flat .tex/.pdf files into per-paper subdirectories.
Added Antje Worring as co-author on all papers.
Synced PDFs to pdfs/ for download site.
2026-04-18 21:50:07 -07:00

49 lines
1.1 KiB
TeX

\section{Implementation Details}
\label{sec:implementation}
The reference implementation in Go demonstrates key optimizations:
\subsection{Caching Layer}
\begin{lstlisting}[language=Go, caption=Opinion caching for performance]
type OpinionCache struct {
cache map[CacheKey]Opinion
ttl time.Duration
maxSize int
mutex sync.RWMutex
}
func (oc *OpinionCache) Get(node NodeID, txID TxID) (Opinion, bool) {
oc.mutex.RLock()
defer oc.mutex.RUnlock()
key := CacheKey{node, txID}
if op, exists := oc.cache[key]; exists {
if time.Since(op.Timestamp) < oc.ttl {
return op, true
}
}
return Opinion{}, false
}
\end{lstlisting}
\subsection{Batch Processing}
\begin{lstlisting}[language=Go, caption=Batch consensus for multiple transactions]
func batchConsensus(txIDs []TxID) []Opinion {
results := make([]Opinion, len(txIDs))
samples := randomSample(k)
// Single network round for all transactions
responses := batchQuery(samples, txIDs)
for i, txID := range txIDs {
results[i] = processResponses(responses[txID])
}
return results
}
\end{lstlisting}