Files
dchain/node/version/version.go
vsecoder 7e7393e4f8 chore: initial commit for v0.0.1
DChain single-node blockchain + React Native messenger client.

Core:
- PBFT consensus with multi-sig validator admission + equivocation slashing
- BadgerDB + schema migration scaffold (CurrentSchemaVersion=0)
- libp2p gossipsub (tx/v1, blocks/v1, relay/v1, version/v1)
- Native Go contracts (username_registry) alongside WASM (wazero)
- WebSocket gateway with topic-based fanout + Ed25519-nonce auth
- Relay mailbox with NaCl envelope encryption (X25519 + Ed25519)
- Prometheus /metrics, per-IP rate limit, body-size cap

Deployment:
- Single-node compose (deploy/single/) with Caddy TLS + optional Prometheus
- 3-node dev compose (docker-compose.yml) with mocked internet topology
- 3-validator prod compose (deploy/prod/) for federation
- Auto-update from Gitea via /api/update-check + systemd timer
- Build-time version injection (ldflags → node --version)
- UI / Swagger toggle flags (DCHAIN_DISABLE_UI, DCHAIN_DISABLE_SWAGGER)

Client (client-app/):
- Expo / React Native / NativeWind
- E2E NaCl encryption, typing indicator, contact requests
- Auto-discovery of canonical contracts, chain_id aware, WS reconnect on node switch

Documentation:
- README.md, CHANGELOG.md, CONTEXT.md
- deploy/single/README.md with 6 operator scenarios
- deploy/UPDATE_STRATEGY.md with 4-layer forward-compat design
- docs/contracts/*.md per contract
2026-04-17 14:16:44 +03:00

71 lines
2.8 KiB
Go

// Package version carries build-time identity for the node binary.
//
// All four variables below are overridable at link time via -ldflags -X. The
// canonical build command is:
//
// VERSION_TAG=$(git describe --tags --always --dirty)
// VERSION_COMMIT=$(git rev-parse HEAD)
// VERSION_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
// VERSION_DIRTY=$(git diff --quiet HEAD -- 2>/dev/null && echo false || echo true)
//
// go build -ldflags "\
// -X go-blockchain/node/version.Tag=$VERSION_TAG \
// -X go-blockchain/node/version.Commit=$VERSION_COMMIT \
// -X go-blockchain/node/version.Date=$VERSION_DATE \
// -X go-blockchain/node/version.Dirty=$VERSION_DIRTY" ./cmd/node
//
// Both Dockerfile and Dockerfile.slim run this at image build time (see ARG
// VERSION_* + RUN go build … -ldflags lines). A naked `go build ./...`
// without ldflags falls back to the zero defaults — that's fine for local
// dev, just not shipped to users.
//
// Protocol versions come from a different source: see node.ProtocolVersion,
// which is a compile-time const that only bumps on wire-protocol breaking
// changes. Protocol version can be the same across many build tags.
package version
// Tag is a human-readable version label, typically `git describe --tags
// --always --dirty`. Examples: "v0.5.1", "v0.5.1-3-gabc1234", "abc1234-dirty".
// "dev" is the fallback when built without ldflags.
var Tag = "dev"
// Commit is the full 40-char git SHA of the HEAD at build time. "none" when
// unset. Useful for precise bisect / release-channel lookups even when Tag
// is a non-unique label like "dev".
var Commit = "none"
// Date is the build timestamp in RFC3339 (UTC). "unknown" when unset.
// Exposed in /api/well-known-version so operators can see how stale a
// deployed binary is without `docker exec`.
var Date = "unknown"
// Dirty is the string "true" if the working tree had uncommitted changes at
// build time, "false" otherwise. Always a string (not bool) because ldflags
// can only inject strings — parse with == "true" at call sites.
var Dirty = "false"
// String returns a one-line summary suitable for `node --version` output.
// Format: "dchain-node <tag> (commit=<short> date=<date> dirty=<bool>)".
func String() string {
short := Commit
if len(short) > 8 {
short = short[:8]
}
return "dchain-node " + Tag + " (commit=" + short + " date=" + Date + " dirty=" + Dirty + ")"
}
// Info returns the version fields as a map, suitable for JSON embedding in
// /api/well-known-version and similar introspection endpoints.
func Info() map[string]string {
return map[string]string{
"tag": Tag,
"commit": Commit,
"date": Date,
"dirty": Dirty,
}
}
// IsDirty reports whether the build was from an unclean working tree.
// Convenience over parsing Dirty == "true" at call sites.
func IsDirty() bool { return Dirty == "true" }