fix: Logic bug; Schema column update stateroot -> state_root

This commit is contained in:
Mike Greenberg 2020-07-10 11:54:11 -04:00
parent 1081679360
commit 3332290626
2 changed files with 8 additions and 8 deletions

View File

@ -299,7 +299,7 @@ create table if not exists miner_info
*/
create table if not exists chain_power
(
stateroot text not null
state_root text not null
constraint chain_power_pk
primary key,
baseline_power text not null
@ -311,11 +311,11 @@ create table if not exists chain_power
create table if not exists miner_power
(
miner_id text not null,
stateroot text not null,
state_root text not null,
raw_bytes_power text not null,
quality_adjusted_power text not null,
constraint miner_power_pk
primary key (miner_id, stateroot)
primary key (miner_id, state_root)
);
/* used to tell when a miners sectors (proven-not-yet-expired) changed if the miner_sectors_cid's are different a new sector was added or removed (terminated/expired) */
@ -535,7 +535,7 @@ func (st *storage) storeChainPower(rewardTips map[types.TipSetKey]*rewardStateIn
return xerrors.Errorf("prep chain_power temp: %w", err)
}
stmt, err := tx.Prepare(`copy cp (stateroot, baseline_power) from STDIN`)
stmt, err := tx.Prepare(`copy cp (state_root, baseline_power) from STDIN`)
if err != nil {
return xerrors.Errorf("prepare tmp chain_power: %w", err)
}
@ -545,7 +545,7 @@ func (st *storage) storeChainPower(rewardTips map[types.TipSetKey]*rewardStateIn
rewardState.stateroot.String(),
rewardState.baselinePower.String(),
); err != nil {
log.Errorw("failed to store chain power", "stateroot", rewardState.stateroot, "error", err)
log.Errorw("failed to store chain power", "state_root", rewardState.stateroot, "error", err)
}
}
@ -682,7 +682,7 @@ func (st *storage) storeMinerPower(minerTips map[types.TipSetKey][]*minerStateIn
return xerrors.Errorf("prep miner_power temp: %w", err)
}
stmt, err := tx.Prepare(`copy cp (miner_id, stateroot, raw_bytes_power, quality_adjusted_power) from STDIN`)
stmt, err := tx.Prepare(`copy mp (miner_id, state_root, raw_bytes_power, quality_adjusted_power) from STDIN`)
if err != nil {
return xerrors.Errorf("prepare tmp miner_power: %w", err)
}

View File

@ -317,7 +317,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, headTs *types.
for addr, m := range actors {
for actor, c := range m {
// reward actor
if actor.Code != builtin.RewardActorCodeID {
if actor.Code == builtin.RewardActorCodeID {
rewardTips[c.tsKey] = &rewardStateInfo{
stateroot: c.stateroot,
baselinePower: big.Zero(),
@ -326,7 +326,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, headTs *types.
}
// miner actors with head change events
if actor.Code != builtin.StorageMinerActorCodeID {
if actor.Code == builtin.StorageMinerActorCodeID {
if _, found := headsSeen[actor.Head]; found {
continue
}