Files
consensus/codec/codec.go
T
zeekay af0bbdc3d6 feat: complete integration of all three consensus engines
- Implement chain, DAG, and post-quantum consensus engines with full test coverage
- Create IntegratedEngine in node package combining all three engines
- Add production-ready cmd tools (params, checker, sim, zmq-bench)
- Implement Acceptor interface for node consensus integration
- Add WithBlockTime method to config Parameters
- Ensure all tests pass across consensus and node packages
- Remove stub implementations and add proper production code
- Fix config validation with detailed error messages
- Clean up duplicate files and unused code
2025-08-21 19:25:56 -05:00

35 lines
855 B
Go

// Package codec provides encoding/decoding for consensus types
package codec
import (
"encoding/json"
"fmt"
)
// CodecVersion represents the codec version
type CodecVersion uint16
const (
// CurrentVersion is the current codec version
CurrentVersion CodecVersion = 0
)
// Codec provides marshaling/unmarshaling
var Codec = &JSONCodec{}
// JSONCodec implements JSON encoding/decoding
type JSONCodec struct{}
// Marshal marshals an object to bytes
func (c *JSONCodec) Marshal(version CodecVersion, v interface{}) ([]byte, error) {
if version != CurrentVersion {
return nil, fmt.Errorf("unsupported codec version: %d", version)
}
return json.Marshal(v)
}
// Unmarshal unmarshals bytes to an object
func (c *JSONCodec) Unmarshal(data []byte, v interface{}) (CodecVersion, error) {
err := json.Unmarshal(data, v)
return CurrentVersion, err
}