From aea8a71f5bde4566a3daa8c6d685a75dd185ef67 Mon Sep 17 00:00:00 2001 From: lukechampine Date: Tue, 19 Nov 2024 23:17:11 -0500 Subject: [PATCH] consensus: Rename SiafundPool -> SiafundTaxRevenue --- consensus/state.go | 30 +++++++++++++++--------------- consensus/update.go | 12 ++++++------ types/types.go | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/consensus/state.go b/consensus/state.go index 2db710f4..f34b3e6b 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -91,11 +91,11 @@ func (n *Network) GenesisState() State { return State{ Network: n, - Index: types.ChainIndex{Height: ^uint64(0)}, - PrevTimestamps: [11]time.Time{}, - Depth: intToTarget(maxTarget), - ChildTarget: n.InitialTarget, - SiafundPool: types.ZeroCurrency, + Index: types.ChainIndex{Height: ^uint64(0)}, + PrevTimestamps: [11]time.Time{}, + Depth: intToTarget(maxTarget), + ChildTarget: n.InitialTarget, + SiafundTaxRevenue: types.ZeroCurrency, OakTime: 0, OakTarget: intToTarget(maxTarget), @@ -111,11 +111,11 @@ func (n *Network) GenesisState() State { type State struct { Network *Network `json:"-"` // network parameters are not encoded - Index types.ChainIndex `json:"index"` - PrevTimestamps [11]time.Time `json:"prevTimestamps"` // newest -> oldest - Depth types.BlockID `json:"depth"` - ChildTarget types.BlockID `json:"childTarget"` - SiafundPool types.Currency `json:"siafundPool"` + Index types.ChainIndex `json:"index"` + PrevTimestamps [11]time.Time `json:"prevTimestamps"` // newest -> oldest + Depth types.BlockID `json:"depth"` + ChildTarget types.BlockID `json:"childTarget"` + SiafundTaxRevenue types.Currency `json:"siafundTaxRevenue"` // Oak hardfork state OakTime time.Duration `json:"oakTime"` @@ -139,7 +139,7 @@ func (s State) EncodeTo(e *types.Encoder) { } s.Depth.EncodeTo(e) s.ChildTarget.EncodeTo(e) - types.V2Currency(s.SiafundPool).EncodeTo(e) + types.V2Currency(s.SiafundTaxRevenue).EncodeTo(e) e.WriteUint64(uint64(s.OakTime)) s.OakTarget.EncodeTo(e) @@ -160,7 +160,7 @@ func (s *State) DecodeFrom(d *types.Decoder) { } s.Depth.DecodeFrom(d) s.ChildTarget.DecodeFrom(d) - (*types.V2Currency)(&s.SiafundPool).DecodeFrom(d) + (*types.V2Currency)(&s.SiafundTaxRevenue).DecodeFrom(d) s.OakTime = time.Duration(d.ReadUint64()) s.OakTarget.DecodeFrom(d) @@ -533,7 +533,7 @@ func (s State) PartialSigHash(txn types.Transaction, cf types.CoveredFields) typ // TransactionsCommitment returns the commitment hash covering the transactions // that comprise a child block. -func (s *State) TransactionsCommitment(txns []types.Transaction, v2txns []types.V2Transaction) types.Hash256 { +func (s State) TransactionsCommitment(txns []types.Transaction, v2txns []types.V2Transaction) types.Hash256 { var acc blake2b.Accumulator for _, txn := range txns { acc.AddLeaf(txn.FullHash()) @@ -595,7 +595,7 @@ type MidState struct { res map[types.FileContractID]bool v2revs map[types.FileContractID]*types.V2FileContractElement v2res map[types.FileContractID]types.V2FileContractResolutionType - siafundPool types.Currency + siafundTaxRevenue types.Currency foundationPrimary types.Address foundationFailsafe types.Address @@ -657,7 +657,7 @@ func NewMidState(s State) *MidState { res: make(map[types.FileContractID]bool), v2revs: make(map[types.FileContractID]*types.V2FileContractElement), v2res: make(map[types.FileContractID]types.V2FileContractResolutionType), - siafundPool: s.SiafundPool, + siafundTaxRevenue: s.SiafundTaxRevenue, foundationPrimary: s.FoundationPrimaryAddress, foundationFailsafe: s.FoundationFailsafeAddress, } diff --git a/consensus/update.go b/consensus/update.go index a383a817..a2f3414a 100644 --- a/consensus/update.go +++ b/consensus/update.go @@ -367,7 +367,7 @@ func (ms *MidState) addSiafundElement(id types.SiafundOutputID, sfo types.Siafun StateElement: types.StateElement{LeafIndex: types.UnassignedLeafIndex}, ID: id, SiafundOutput: sfo, - ClaimStart: ms.siafundPool, + ClaimStart: ms.siafundTaxRevenue, } ms.sfes = append(ms.sfes, sfe) ms.created[ms.sfes[len(ms.sfes)-1].ID] = len(ms.sfes) - 1 @@ -389,7 +389,7 @@ func (ms *MidState) addFileContractElement(id types.FileContractID, fc types.Fil } ms.fces = append(ms.fces, fce) ms.created[ms.fces[len(ms.fces)-1].ID] = len(ms.fces) - 1 - ms.siafundPool = ms.siafundPool.Add(ms.base.FileContractTax(fce.FileContract)) + ms.siafundTaxRevenue = ms.siafundTaxRevenue.Add(ms.base.FileContractTax(fce.FileContract)) } func (ms *MidState) reviseFileContractElement(fce types.FileContractElement, rev types.FileContract) { @@ -426,7 +426,7 @@ func (ms *MidState) addV2FileContractElement(id types.FileContractID, fc types.V } ms.v2fces = append(ms.v2fces, fce) ms.created[ms.v2fces[len(ms.v2fces)-1].ID] = len(ms.v2fces) - 1 - ms.siafundPool = ms.siafundPool.Add(ms.base.V2FileContractTax(fce.V2FileContract)) + ms.siafundTaxRevenue = ms.siafundTaxRevenue.Add(ms.base.V2FileContractTax(fce.V2FileContract)) } func (ms *MidState) reviseV2FileContractElement(fce types.V2FileContractElement, rev types.V2FileContract) { @@ -477,7 +477,7 @@ func (ms *MidState) ApplyTransaction(txn types.Transaction, ts V1TransactionSupp if !ok { panic("missing SiafundElement") } - claimPortion := ms.siafundPool.Sub(sfe.ClaimStart).Div64(ms.base.SiafundCount()).Mul64(sfe.SiafundOutput.Value) + claimPortion := ms.siafundTaxRevenue.Sub(sfe.ClaimStart).Div64(ms.base.SiafundCount()).Mul64(sfe.SiafundOutput.Value) ms.spendSiafundElement(sfe, txid) ms.addImmatureSiacoinElement(sfi.ParentID.ClaimOutputID(), types.SiacoinOutput{Value: claimPortion, Address: sfi.ClaimAddress}) } @@ -528,7 +528,7 @@ func (ms *MidState) ApplyV2Transaction(txn types.V2Transaction) { } for _, sfi := range txn.SiafundInputs { ms.spendSiafundElement(sfi.Parent, txid) - claimPortion := ms.siafundPool.Sub(sfi.Parent.ClaimStart).Div64(ms.base.SiafundCount()).Mul64(sfi.Parent.SiafundOutput.Value) + claimPortion := ms.siafundTaxRevenue.Sub(sfi.Parent.ClaimStart).Div64(ms.base.SiafundCount()).Mul64(sfi.Parent.SiafundOutput.Value) ms.addImmatureSiacoinElement(sfi.Parent.ID.V2ClaimOutputID(), types.SiacoinOutput{Value: claimPortion, Address: sfi.ClaimAddress}) } for i, sfo := range txn.SiafundOutputs { @@ -736,7 +736,7 @@ func ApplyBlock(s State, b types.Block, bs V1BlockSupplement, targetTimestamp ti ms := NewMidState(s) ms.ApplyBlock(b, bs) - s.SiafundPool = ms.siafundPool + s.SiafundTaxRevenue = ms.siafundTaxRevenue s.Attestations += uint64(len(ms.aes)) s.FoundationPrimaryAddress = ms.foundationPrimary s.FoundationFailsafeAddress = ms.foundationFailsafe diff --git a/types/types.go b/types/types.go index 94bfbd11..40a81ae8 100644 --- a/types/types.go +++ b/types/types.go @@ -641,7 +641,7 @@ type SiafundElement struct { ID SiafundOutputID `json:"id"` StateElement StateElement `json:"stateElement"` SiafundOutput SiafundOutput `json:"siafundOutput"` - ClaimStart Currency `json:"claimStart"` // value of SiafundPool when element was created + ClaimStart Currency `json:"claimStart"` // value of SiafundTaxRevenue when element was created } // A FileContractElement is a record of a FileContract within the state