Skip to content

Commit

Permalink
Remove InsertZeroingCoinbase from pegnet client
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonheaven committed Nov 17, 2020
1 parent 1d045c1 commit 41ace06
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 69 deletions.
60 changes: 0 additions & 60 deletions node/pegnet/txhistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,63 +555,3 @@ func (p *Pegnet) InsertDeveloperRewardCoinbase(tx *sql.Tx, txid string, addTxid

return nil
}

// Special construction to nullify burn address
func (p *Pegnet) InsertZeroingCoinbase(tx *sql.Tx, txid string, addTxid string, height uint32, heightTimestamp time.Time, payout uint64, asset string, faAdd factom.FAAddress) error {
txidBytes, err := hex.DecodeString(txid)
if err != nil {
return err
}

// First we need to record the batch. The batch is the entire set of transactions, where
// each tx is a stake payout.
stmt, err := tx.Prepare(`INSERT INTO "pn_history_txbatch"
(entry_hash, height, blockorder, timestamp, executed) VALUES
(?, ?, ?, ?, ?)`)
if err != nil {
return err
}

// The Entryhash is the custom txid, it is not an actual entry on chain
// The executed height is the same height as the recorded.
_, err = stmt.Exec(txidBytes, height, 0, heightTimestamp.Unix(), height)
if err != nil {
return err
}

// Now we record balance zeroing .

// All addresses are stored as bytes in the sqlitedb
add := faAdd[:]
// index for the address
index, _, err := SplitTxID(addTxid)
if err != nil {
return err
}

// Decrease each balance as a coinbase.
// Insert the TX
coinbaseStatement, err := tx.Prepare(`INSERT INTO "pn_history_transaction"
(entry_hash, tx_index, action_type, from_address, from_asset, from_amount, to_asset, to_amount, outputs) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?)`)
if err != nil {
return err
}

_, err = coinbaseStatement.Exec(txidBytes, index, Coinbase, add, "", 0, asset, -payout, "") // -payout means we substract value
if err != nil {
return err
}

// Insert into lookup table
lookup, err := tx.Prepare(insertLookupQuery)
if err != nil {
return err
}

if _, err = lookup.Exec(txidBytes, index, add); err != nil {
return err
}

return nil
}
9 changes: 0 additions & 9 deletions node/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,6 @@ func (d *Pegnetd) NullifyBurnAddress(ctx context.Context, tx *sql.Tx, height uin
"txid": txid,
"addtxid": addTxid,
}).Info("burn nullify | prep")

err = d.Pegnet.InsertZeroingCoinbase(tx, txid, addTxid, height, heightTimestamp, value, ticker.String(), FAGlobalBurnAddress)
if err != nil {
fLog.WithFields(log.Fields{
"error": err,
}).Info("zeroing burn | coinbase tx failed")
return err
}

}

return nil
Expand Down

0 comments on commit 41ace06

Please sign in to comment.