mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
make supply type private
This commit is contained in:
parent
a6cabe11b0
commit
df69332109
1 changed files with 11 additions and 11 deletions
|
|
@ -43,8 +43,8 @@ type supplyTxCallstack struct {
|
||||||
burn *big.Int
|
burn *big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Supply struct {
|
|
||||||
delta SupplyInfo
|
delta SupplyInfo
|
||||||
|
type supply struct {
|
||||||
txCallstack []supplyTxCallstack // Callstack for current transaction
|
txCallstack []supplyTxCallstack // Callstack for current transaction
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +79,7 @@ func newSupply(cfg json.RawMessage) (*tracing.Hooks, error) {
|
||||||
|
|
||||||
supplyInfo := newSupplyInfo()
|
supplyInfo := newSupplyInfo()
|
||||||
|
|
||||||
t := &Supply{
|
t := &supply{
|
||||||
delta: supplyInfo,
|
delta: supplyInfo,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
|
|
@ -107,11 +107,11 @@ func newSupplyInfo() SupplyInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supply) resetDelta() {
|
func (s *supply) resetDelta() {
|
||||||
s.delta = newSupplyInfo()
|
s.delta = newSupplyInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supply) OnBlockStart(ev tracing.BlockEvent) {
|
func (s *supply) OnBlockStart(ev tracing.BlockEvent) {
|
||||||
s.resetDelta()
|
s.resetDelta()
|
||||||
|
|
||||||
s.delta.Number = ev.Block.NumberU64()
|
s.delta.Number = ev.Block.NumberU64()
|
||||||
|
|
@ -134,12 +134,12 @@ func (s *Supply) OnBlockStart(ev tracing.BlockEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supply) OnBlockEnd(err error) {
|
func (s *supply) OnBlockEnd(err error) {
|
||||||
out, _ := json.Marshal(s.delta)
|
out, _ := json.Marshal(s.delta)
|
||||||
s.logger.Println(string(out))
|
s.logger.Println(string(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supply) OnGenesisBlock(b *types.Block, alloc types.GenesisAlloc) {
|
func (s *supply) OnGenesisBlock(b *types.Block, alloc types.GenesisAlloc) {
|
||||||
s.resetDelta()
|
s.resetDelta()
|
||||||
|
|
||||||
s.delta.Number = b.NumberU64()
|
s.delta.Number = b.NumberU64()
|
||||||
|
|
@ -155,7 +155,7 @@ func (s *Supply) OnGenesisBlock(b *types.Block, alloc types.GenesisAlloc) {
|
||||||
s.logger.Println(string(out))
|
s.logger.Println(string(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supply) OnBalanceChange(a common.Address, prevBalance, newBalance *big.Int, reason tracing.BalanceChangeReason) {
|
func (s *supply) OnBalanceChange(a common.Address, prevBalance, newBalance *big.Int, reason tracing.BalanceChangeReason) {
|
||||||
diff := new(big.Int).Sub(newBalance, prevBalance)
|
diff := new(big.Int).Sub(newBalance, prevBalance)
|
||||||
|
|
||||||
// NOTE: don't handle "BalanceIncreaseGenesisBalance" because it is handled in OnGenesisBlock
|
// NOTE: don't handle "BalanceIncreaseGenesisBalance" because it is handled in OnGenesisBlock
|
||||||
|
|
@ -177,12 +177,12 @@ func (s *Supply) OnBalanceChange(a common.Address, prevBalance, newBalance *big.
|
||||||
s.delta.Delta.Add(s.delta.Delta, diff)
|
s.delta.Delta.Add(s.delta.Delta, diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supply) OnTxStart(vm *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (s *supply) OnTxStart(vm *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
s.txCallstack = make([]supplyTxCallstack, 0, 1)
|
s.txCallstack = make([]supplyTxCallstack, 0, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// interalTxsHandler handles internal transactions burned amount
|
// interalTxsHandler handles internal transactions burned amount
|
||||||
func (s *Supply) interalTxsHandler(call *supplyTxCallstack) {
|
func (s *supply) interalTxsHandler(call *supplyTxCallstack) {
|
||||||
// Handle Burned amount
|
// Handle Burned amount
|
||||||
if call.burn != nil {
|
if call.burn != nil {
|
||||||
s.delta.burn(call.burn)
|
s.delta.burn(call.burn)
|
||||||
|
|
@ -197,7 +197,7 @@ func (s *Supply) interalTxsHandler(call *supplyTxCallstack) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supply) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
func (s *supply) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
call := supplyTxCallstack{
|
call := supplyTxCallstack{
|
||||||
calls: make([]supplyTxCallstack, 0),
|
calls: make([]supplyTxCallstack, 0),
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +212,7 @@ func (s *Supply) OnEnter(depth int, typ byte, from common.Address, to common.Add
|
||||||
s.txCallstack = append(s.txCallstack, call)
|
s.txCallstack = append(s.txCallstack, call)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supply) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
func (s *supply) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
// No need to handle Burned amount if transaction is reverted
|
// No need to handle Burned amount if transaction is reverted
|
||||||
if !reverted {
|
if !reverted {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue