v1.27.0-a #10
@ -137,7 +137,7 @@ func (s *server) serviceRequest(ctx context.Context, req *validatedRequest) (*Re
|
|||||||
|
|
||||||
chain, err := collectChainSegment(ctx, s.cs, req)
|
chain, err := collectChainSegment(ctx, s.cs, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("block sync request: collectChainSegment failed: ", err)
|
log.Info("block sync request: collectChainSegment failed: ", err)
|
||||||
return &Response{
|
return &Response{
|
||||||
Status: InternalError,
|
Status: InternalError,
|
||||||
ErrorMessage: err.Error(),
|
ErrorMessage: err.Error(),
|
||||||
@ -171,17 +171,11 @@ func collectChainSegment(ctx context.Context, cs *store.ChainStore, req *validat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if req.options.IncludeMessages {
|
if req.options.IncludeMessages {
|
||||||
bmsgs, bmincl, smsgs, smincl, err := gatherMessages(ctx, cs, ts)
|
bst.Messages, err = gatherMessages(ctx, cs, ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("gather messages failed: %w", err)
|
return nil, xerrors.Errorf("gather messages failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Pass the response to `gatherMessages()` and set all this there.
|
|
||||||
bst.Messages = &CompactedMessages{}
|
|
||||||
bst.Messages.Bls = bmsgs
|
|
||||||
bst.Messages.BlsIncludes = bmincl
|
|
||||||
bst.Messages.Secpk = smsgs
|
|
||||||
bst.Messages.SecpkIncludes = smincl
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bstips = append(bstips, &bst)
|
bstips = append(bstips, &bst)
|
||||||
@ -196,16 +190,16 @@ func collectChainSegment(ctx context.Context, cs *store.ChainStore, req *validat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func gatherMessages(ctx context.Context, cs *store.ChainStore, ts *types.TipSet) ([]*types.Message, [][]uint64, []*types.SignedMessage, [][]uint64, error) {
|
func gatherMessages(ctx context.Context, cs *store.ChainStore, ts *types.TipSet) (*CompactedMessages, error) {
|
||||||
|
msgs := new(CompactedMessages)
|
||||||
blsmsgmap := make(map[cid.Cid]uint64)
|
blsmsgmap := make(map[cid.Cid]uint64)
|
||||||
secpkmsgmap := make(map[cid.Cid]uint64)
|
secpkmsgmap := make(map[cid.Cid]uint64)
|
||||||
var secpkincl, blsincl [][]uint64
|
|
||||||
|
|
||||||
var blscids, secpkcids []cid.Cid
|
var blscids, secpkcids []cid.Cid
|
||||||
for _, block := range ts.Blocks() {
|
for _, block := range ts.Blocks() {
|
||||||
bc, sc, err := cs.ReadMsgMetaCids(ctx, block.Messages)
|
bc, sc, err := cs.ReadMsgMetaCids(ctx, block.Messages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: DRY. Use `chain.Message` interface.
|
// FIXME: DRY. Use `chain.Message` interface.
|
||||||
@ -220,7 +214,7 @@ func gatherMessages(ctx context.Context, cs *store.ChainStore, ts *types.TipSet)
|
|||||||
|
|
||||||
bmi = append(bmi, i)
|
bmi = append(bmi, i)
|
||||||
}
|
}
|
||||||
blsincl = append(blsincl, bmi)
|
msgs.BlsIncludes = append(msgs.BlsIncludes, bmi)
|
||||||
|
|
||||||
smi := make([]uint64, 0, len(sc))
|
smi := make([]uint64, 0, len(sc))
|
||||||
for _, m := range sc {
|
for _, m := range sc {
|
||||||
@ -233,18 +227,19 @@ func gatherMessages(ctx context.Context, cs *store.ChainStore, ts *types.TipSet)
|
|||||||
|
|
||||||
smi = append(smi, i)
|
smi = append(smi, i)
|
||||||
}
|
}
|
||||||
secpkincl = append(secpkincl, smi)
|
msgs.SecpkIncludes = append(msgs.SecpkIncludes, smi)
|
||||||
}
|
}
|
||||||
|
|
||||||
blsmsgs, err := cs.LoadMessagesFromCids(ctx, blscids)
|
var err error
|
||||||
|
msgs.Bls, err = cs.LoadMessagesFromCids(ctx, blscids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
secpkmsgs, err := cs.LoadSignedMessagesFromCids(ctx, secpkcids)
|
msgs.Secpk, err = cs.LoadSignedMessagesFromCids(ctx, secpkcids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return blsmsgs, blsincl, secpkmsgs, secpkincl, nil
|
return msgs, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user