fix up the tests and cli

This commit is contained in:
whyrusleeping 2019-08-01 20:51:34 -07:00
parent dc7c0fcabe
commit e5f4c75ca4
4 changed files with 23 additions and 8 deletions

View File

@ -41,6 +41,11 @@ type MsgWait struct {
Receipt types.MessageReceipt
}
type BlockMessages struct {
BlsMessages []*types.Message
SecpkMessages []*types.SignedMessage
}
type Common interface {
// Auth
AuthVerify(ctx context.Context, token string) ([]string, error)
@ -72,7 +77,7 @@ type FullNode interface {
ChainGetRandomness(context.Context, *types.TipSet) ([]byte, error)
ChainWaitMsg(context.Context, cid.Cid) (*MsgWait, error)
ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error)
ChainGetBlockMessages(context.Context, cid.Cid) ([]*types.Message, []*types.SignedMessage, error)
ChainGetBlockMessages(context.Context, cid.Cid) (*BlockMessages, error)
// if tipset is nil, we'll use heaviest
ChainCall(context.Context, *types.Message, *types.TipSet) (*types.MessageReceipt, error)

View File

@ -45,7 +45,7 @@ type FullNodeStruct struct {
ChainGetRandomness func(context.Context, *types.TipSet) ([]byte, error) `perm:"read"`
ChainWaitMsg func(context.Context, cid.Cid) (*MsgWait, error) `perm:"read"`
ChainGetBlock func(context.Context, cid.Cid) (*types.BlockHeader, error) `perm:"read"`
ChainGetBlockMessages func(context.Context, cid.Cid) ([]*types.Message, []*types.SignedMessage, error) `perm:"read"`
ChainGetBlockMessages func(context.Context, cid.Cid) (*BlockMessages, error) `perm:"read"`
ChainCall func(context.Context, *types.Message, *types.TipSet) (*types.MessageReceipt, error) `perm:"read"`
MpoolPending func(context.Context, *types.TipSet) ([]*types.SignedMessage, error) `perm:"read"`
@ -188,7 +188,7 @@ func (c *FullNodeStruct) ChainGetBlock(ctx context.Context, b cid.Cid) (*types.B
return c.Internal.ChainGetBlock(ctx, b)
}
func (c *FullNodeStruct) ChainGetBlockMessages(ctx context.Context, b cid.Cid) ([]*types.Message, []*types.SignedMessage, error) {
func (c *FullNodeStruct) ChainGetBlockMessages(ctx context.Context, b cid.Cid) (*BlockMessages, error) {
return c.Internal.ChainGetBlockMessages(ctx, b)
}

View File

@ -88,11 +88,13 @@ var chainGetBlock = &cli.Command{
cblock := struct {
types.BlockHeader
Messages []*types.SignedMessage
BlsMessages []*types.Message
SecpkMessages []*types.SignedMessage
}{}
cblock.BlockHeader = *blk
cblock.Messages = msgs
cblock.BlsMessages = msgs.BlsMessages
cblock.SecpkMessages = msgs.SecpkMessages
out, err := json.MarshalIndent(cblock, "", " ")
if err != nil {

View File

@ -77,13 +77,21 @@ func (a *FullNodeAPI) ChainGetBlock(ctx context.Context, msg cid.Cid) (*types.Bl
return a.Chain.GetBlock(msg)
}
func (a *FullNodeAPI) ChainGetBlockMessages(ctx context.Context, msg cid.Cid) ([]*types.Message, []*types.SignedMessage, error) {
func (a *FullNodeAPI) ChainGetBlockMessages(ctx context.Context, msg cid.Cid) (*api.BlockMessages, error) {
b, err := a.Chain.GetBlock(msg)
if err != nil {
return nil, nil, err
return nil, err
}
return a.Chain.MessagesForBlock(b)
bmsgs, smsgs, err := a.Chain.MessagesForBlock(b)
if err != nil {
return nil, err
}
return &api.BlockMessages{
BlsMessages: bmsgs,
SecpkMessages: smsgs,
}, nil
}
func (a *FullNodeAPI) ChainCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error) {