Skip to content

Commit 7d600bc

Browse files
author
dragonheaven
committed
NullifyMintTokens
1 parent cd1efd4 commit 7d600bc

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

node/node.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ var (
7676
// V204EnhanceActivation indicates the activation of PegNet 2.0.4.
7777
// Estimated to be Mar 15th 2021
7878
V204EnhanceActivation uint32 = 999999
79+
80+
// V204EnhanceActivation indicates the activation of PegNet 2.0.4.
81+
// Estimated to be Mar 15th 2021
82+
V204BurnMintTokenActivation uint32 = 999999
7983
)
8084

8185
func SetAllActivations(act uint32) {

node/sync.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,41 @@ func (d *Pegnetd) MintTokensForBalance(ctx context.Context, tx *sql.Tx, height u
198198
return nil
199199
}
200200

201+
func (d *Pegnetd) NullifyMintTokens(ctx context.Context, tx *sql.Tx, height uint32) error {
202+
fLog := log.WithFields(log.Fields{"height": height})
203+
204+
FAGlobalMintAddress, err := factom.NewFAAddress(GlobalMintAddress)
205+
if err != nil {
206+
log.WithFields(log.Fields{
207+
"error": err,
208+
}).Info("error getting mint address")
209+
return err
210+
}
211+
212+
// Get all balances for the address
213+
balances, err := d.Pegnet.SelectBalances(&FAGlobalMintAddress)
214+
if err != nil {
215+
fLog.WithFields(log.Fields{
216+
"err": err,
217+
}).Info("zeroing burn | balances retrieval failed")
218+
}
219+
220+
for _, tokenSupply := range MintTotalSupplyMap {
221+
// Substract from every issuance
222+
ticker := tokenSupply.Ticker
223+
value, _ := balances[ticker]
224+
_, _, err := d.Pegnet.SubFromBalance(tx, &FAGlobalMintAddress, ticker, value) // lastInd, txErr, err
225+
if err != nil {
226+
fLog.WithFields(log.Fields{
227+
"ticker": ticker,
228+
"balance": value,
229+
}).Info("zeroing burn | substract from balance failed")
230+
return err
231+
}
232+
}
233+
return nil
234+
}
235+
201236
func (d *Pegnetd) NullifyBurnAddress(ctx context.Context, tx *sql.Tx, height uint32) error {
202237
fLog := log.WithFields(log.Fields{"height": height})
203238

@@ -310,6 +345,12 @@ func (d *Pegnetd) SyncBlock(ctx context.Context, tx *sql.Tx, height uint32) erro
310345
}
311346
}
312347

348+
if height == V204BurnMintTokenActivation {
349+
if err := d.NullifyMintTokens(ctx, tx, d.Sync.Synced+1); err != nil {
350+
return err
351+
}
352+
}
353+
313354
dblock := new(factom.DBlock)
314355
dblock.Height = height
315356
if err := dblock.Get(nil, d.FactomClient); err != nil {

0 commit comments

Comments
 (0)