Go implementation

peoplecoin

Standard library only. Primitives, the state machine, and the nine operations — no networking, no video, no wallet yet.

params/params.go

56 lines

1// Package params holds the protocol constants, mirroring the "Constants"
2// section of the specification. Everything else derives from these.
3package params
4
5const (
6 // TOKEN is one token in base units (8 decimals).
7 TOKEN uint64 = 100_000_000
8
9 // SlotsPerPeriod is four weeks in one-minute slots.
10 SlotsPerPeriod uint64 = 40320
11 SlotSeconds uint64 = 60
12 PeriodSeconds uint64 = SlotsPerPeriod * SlotSeconds // 2 419 200
13 SlotsPerPhase uint64 = 10080 // one week
14 NumPhases uint64 = 4
15
16 // Demurrage: coins retain 0.983 of their value per period (~20%/year).
17 // DecayShift is the fixed-point width and Decay0 the per-slot factor,
18 // floor(2^63 × 0.983^(1/SlotsPerPeriod)). The squaring chain built from
19 // Decay0 (see package coin) is the definition of the curve.
20 DecayShift uint = 63
21 Decay0 uint64 = 9223368114598617273
22
23 // UBIPerPeriod equals the demurrage on one token over one period:
24 // TOKEN × 1.7%.
25 UBIPerPeriod uint64 = 1_700_000
26
27 // RentShift: rent = 1 base unit per 1 024 slots (~39 per period).
28 RentShift uint = 10
29
30 MaxMixes uint32 = 32 // cap on a token's mix_count
31 MaxOwners int = 8 // max owners per coin UTXO
32 InviteCost int = 3 // invite tokens per new registration
33
34 // MaxBlockSize is a matter of consensus outside this library (e.g. 1 GB).
35)
36
37// Token types in the token trie.
38const (
39 TokenElection uint8 = 0x00
40 TokenRegistration uint8 = 0x01
41 TokenInvite uint8 = 0x02
42)
43
44// Operation codes.
45const (
46 OpTransfer uint8 = 0x00
47 OpMix uint8 = 0x01
48 OpVote uint8 = 0x02
49 OpRegister uint8 = 0x03
50 OpVerify uint8 = 0x04
51 OpVerified uint8 = 0x05
52 OpCommit uint8 = 0x06
53 OpReveal uint8 = 0x07
54 OpPrune uint8 = 0xFF
55)