Use EmptyTSK where appropriate

This commit is contained in:
Aayush Rajasekaran 2021-04-29 00:56:16 -04:00
parent b23837a7d6
commit d794b49df3
5 changed files with 6 additions and 6 deletions

View File

@ -47,7 +47,7 @@ func NewTipSetKey(cids ...cid.Cid) TipSetKey {
func TipSetKeyFromBytes(encoded []byte) (TipSetKey, error) { func TipSetKeyFromBytes(encoded []byte) (TipSetKey, error) {
_, err := decodeKey(encoded) _, err := decodeKey(encoded)
if err != nil { if err != nil {
return TipSetKey{}, err return EmptyTSK, err
} }
return TipSetKey{string(encoded)}, nil return TipSetKey{string(encoded)}, nil
} }

View File

@ -19,7 +19,7 @@ func TestTipSetKey(t *testing.T) {
fmt.Println(len(c1.Bytes())) fmt.Println(len(c1.Bytes()))
t.Run("zero value", func(t *testing.T) { t.Run("zero value", func(t *testing.T) {
assert.Equal(t, TipSetKey{}, NewTipSetKey()) assert.Equal(t, EmptyTSK, NewTipSetKey())
}) })
t.Run("CID extraction", func(t *testing.T) { t.Run("CID extraction", func(t *testing.T) {

View File

@ -254,7 +254,7 @@ var terminateSectorPenaltyEstimationCmd = &cli.Command{
//TODO: 4667 add an option to give a more precise estimation with pending termination penalty excluded //TODO: 4667 add an option to give a more precise estimation with pending termination penalty excluded
invocResult, err := nodeApi.StateCall(ctx, msg, types.TipSetKey{}) invocResult, err := nodeApi.StateCall(ctx, msg, types.EmptyTSK)
if err != nil { if err != nil {
return xerrors.Errorf("fail to state call: %w", err) return xerrors.Errorf("fail to state call: %w", err)
} }

View File

@ -324,7 +324,7 @@ func gasEstimateGasLimit(
func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, _ types.TipSetKey) (*types.Message, error) { func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, _ types.TipSetKey) (*types.Message, error) {
if msg.GasLimit == 0 { if msg.GasLimit == 0 {
gasLimit, err := m.GasEstimateGasLimit(ctx, msg, types.TipSetKey{}) gasLimit, err := m.GasEstimateGasLimit(ctx, msg, types.EmptyTSK)
if err != nil { if err != nil {
return nil, xerrors.Errorf("estimating gas used: %w", err) return nil, xerrors.Errorf("estimating gas used: %w", err)
} }
@ -332,7 +332,7 @@ func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Messag
} }
if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 { if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 {
gasPremium, err := m.GasEstimateGasPremium(ctx, 10, msg.From, msg.GasLimit, types.TipSetKey{}) gasPremium, err := m.GasEstimateGasPremium(ctx, 10, msg.From, msg.GasLimit, types.EmptyTSK)
if err != nil { if err != nil {
return nil, xerrors.Errorf("estimating gas price: %w", err) return nil, xerrors.Errorf("estimating gas price: %w", err)
} }

View File

@ -821,7 +821,7 @@ func (s *WindowPoStScheduler) setSender(ctx context.Context, msg *types.Message,
// estimate // estimate
minGasFeeMsg := *msg minGasFeeMsg := *msg
minGasFeeMsg.GasPremium, err = s.api.GasEstimateGasPremium(ctx, 5, msg.From, msg.GasLimit, types.TipSetKey{}) minGasFeeMsg.GasPremium, err = s.api.GasEstimateGasPremium(ctx, 5, msg.From, msg.GasLimit, types.EmptyTSK)
if err != nil { if err != nil {
log.Errorf("failed to estimate minimum gas premium: %+v", err) log.Errorf("failed to estimate minimum gas premium: %+v", err)
minGasFeeMsg.GasPremium = msg.GasPremium minGasFeeMsg.GasPremium = msg.GasPremium