Skip to content

Commit

Permalink
fix: insert actor methods db error (#1331)
Browse files Browse the repository at this point in the history
* fix: add the table name for ActorMethod and ActorCode models

* fix: change the flag check

* fix: try to use use_zero
  • Loading branch information
Terryhung authored Dec 12, 2024
1 parent 3c617a3 commit 536300f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions commands/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ var ChainActorMethodsCmd = &cli.Command{
var strg model.Storage
var ctx context.Context

if chainActorFlags.persist {
if chainActorFlags.config != "" {
cfg, err := config.FromFile(chainActorFlags.config)
if err != nil {
return err
Expand Down Expand Up @@ -229,7 +229,7 @@ var ChainActorMethodsCmd = &cli.Command{
}
}

if chainActorFlags.persist {
if chainActorFlags.config != "" {
err := strg.PersistBatch(ctx, actorMethodList)
if err != nil {
return err
Expand Down
8 changes: 5 additions & 3 deletions model/actors/common/actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (states ActorStateList) Persist(ctx context.Context, s model.StorageBatch,
}

type ActorCode struct {
tableName struct{} `pg:"actor_codes"` // nolint: structcheck
// CID of the actor from builtin actors.
CID string `pg:",pk,notnull"`
// Human-readable identifier for the actor.
Expand Down Expand Up @@ -147,9 +148,10 @@ func (acl ActorCodeList) Persist(ctx context.Context, s model.StorageBatch, _ mo
}

type ActorMethod struct {
Family string `pg:",pk,notnull"`
MethodName string `pg:",notnull"`
Method uint64 `pg:",pk,notnull"`
tableName struct{} `pg:"actor_methods"` // nolint: structcheck
Family string `pg:",pk,notnull"`
MethodName string `pg:",notnull"`
Method uint64 `pg:",pk,notnull,use_zero"`
}

type ActorMethodList []*ActorMethod
Expand Down

0 comments on commit 536300f

Please sign in to comment.