Skip to content

Commit 02b615d

Browse files
committed
x
1 parent 083613c commit 02b615d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

action/protocol/staking/protocol.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ func (p *Protocol) saveStakingAddressHistory(height uint64, sm protocol.StateMan
271271
if balance.amount.Sign() <= 0 {
272272
return nil
273273
}
274-
//hei := byteutil.Uint64ToBytesBigEndian(height - 1)
275-
hei := byteutil.Uint64ToBytesBigEndian(height)
274+
hei := byteutil.Uint64ToBytesBigEndian(height - 1)
275+
//hei := byteutil.Uint64ToBytesBigEndian(height)
276276
historyKey := append(bucketPoolAddrKey, hei...)
277277
fmt.Println("saveStakingAddressHistory2", height, hex.EncodeToString(historyKey), balance.amount)
278278

@@ -475,7 +475,7 @@ func (p *Protocol) ReadState(ctx context.Context, sr protocol.StateReader, metho
475475
resp, height, err = readStateCandidateByAddress(ctx, csr, r.GetCandidateByAddress())
476476
case iotexapi.ReadStakingDataMethod_TOTAL_STAKING_AMOUNT:
477477
if p.archiveMode && p.hu.IsPre(config.Greenland, height) {
478-
resp, height, err = readStateTotalStakingAmountFromIndexer(csr, r.GetTotalStakingAmount(), inputHeight)
478+
resp, height, err = readStateTotalStakingAmountFromIndexer(sr, r.GetTotalStakingAmount(), inputHeight)
479479
} else {
480480
resp, height, err = readStateTotalStakingAmount(ctx, csr, r.GetTotalStakingAmount())
481481
}

action/protocol/staking/read_state.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func readStateTotalStakingAmount(ctx context.Context, csr CandidateStateReader,
147147
return &meta, csr.Height(), nil
148148
}
149149

150-
func readStateTotalStakingAmountFromIndexer(csr CandidateStateReader, _ *iotexapi.ReadStakingDataRequest_TotalStakingAmount, height uint64) (*iotextypes.AccountMeta, uint64, error) {
150+
func readStateTotalStakingAmountFromIndexer(csr protocol.StateReader, _ *iotexapi.ReadStakingDataRequest_TotalStakingAmount, height uint64) (*iotextypes.AccountMeta, uint64, error) {
151151
fmt.Println("readStateTotalStakingAmountFromHeight", height)
152152
meta := iotextypes.AccountMeta{}
153153
meta.Address = address.StakingBucketPoolAddr
@@ -232,11 +232,11 @@ func getTotalStakedAmount(ctx context.Context, csr CandidateStateReader) (*big.I
232232
return csr.TotalStakedAmount(), nil
233233
}
234234

235-
func getTotalStakedAmountFromHeight(csr CandidateStateReader, height uint64) (*big.Int, error) {
235+
func getTotalStakedAmountFromHeight(csr protocol.StateReader, height uint64) (*big.Int, error) {
236236
hei := byteutil.Uint64ToBytesBigEndian(height)
237237
historyKey := append(bucketPoolAddrKey, hei...)
238238
var total totalAmount
239-
_, err := csr.SR().State(&total, protocol.NamespaceOption(StakingNameSpace), protocol.KeyOption(historyKey))
239+
_, err := csr.State(&total, protocol.NamespaceOption(StakingNameSpace), protocol.KeyOption(historyKey))
240240
fmt.Println("getTotalStakedAmountFromHeight", height, hex.EncodeToString(historyKey), err)
241241
return total.amount, err
242242
}

0 commit comments

Comments
 (0)