message pool: write message(s) in journal entries.

This commit is contained in:
Raúl Kripalani 2020-07-21 13:10:29 +01:00
parent d6e6eedd58
commit 3bd9d55a15

View File

@ -73,11 +73,17 @@ const (
evtTypeMpoolRepub evtTypeMpoolRepub
) )
// MessagePoolEvt is the journal event type emitted by the MessagePool. // MessagePoolEvt is the journal entry for message pool events.
type MessagePoolEvt struct { type MessagePoolEvt struct {
Action string Action string
MessageCIDs []cid.Cid Messages []MessagePoolEvt_Message
Error error `json:",omitempty"` Error error `json:",omitempty"`
}
type MessagePoolEvt_Message struct {
types.Message
CID cid.Cid
} }
type MessagePool struct { type MessagePool struct {
@ -310,14 +316,14 @@ func (mp *MessagePool) repubLocal() {
} }
journal.MaybeAddEntry(mp.jrnl, mp.evtTypes[evtTypeMpoolRepub], func() interface{} { journal.MaybeAddEntry(mp.jrnl, mp.evtTypes[evtTypeMpoolRepub], func() interface{} {
cids := make([]cid.Cid, 0, len(outputMsgs)) msgs := make([]MessagePoolEvt_Message, 0, len(outputMsgs))
for _, m := range outputMsgs { for _, m := range outputMsgs {
cids = append(cids, m.Cid()) msgs = append(msgs, MessagePoolEvt_Message{Message: m.Message, CID: m.Cid()})
} }
return MessagePoolEvt{ return MessagePoolEvt{
Action: "repub", Action: "repub",
MessageCIDs: cids, Messages: msgs,
Error: errout, Error: errout,
} }
}) })
@ -488,8 +494,8 @@ func (mp *MessagePool) addLocked(m *types.SignedMessage) error {
journal.MaybeAddEntry(mp.jrnl, mp.evtTypes[evtTypeMpoolAdd], func() interface{} { journal.MaybeAddEntry(mp.jrnl, mp.evtTypes[evtTypeMpoolAdd], func() interface{} {
return MessagePoolEvt{ return MessagePoolEvt{
Action: "add", Action: "add",
MessageCIDs: []cid.Cid{m.Cid()}, Messages: []MessagePoolEvt_Message{{Message: m.Message, CID: m.Cid()}},
} }
}) })
@ -628,9 +634,8 @@ func (mp *MessagePool) Remove(from address.Address, nonce uint64) {
journal.MaybeAddEntry(mp.jrnl, mp.evtTypes[evtTypeMpoolRemove], func() interface{} { journal.MaybeAddEntry(mp.jrnl, mp.evtTypes[evtTypeMpoolRemove], func() interface{} {
return MessagePoolEvt{ return MessagePoolEvt{
Action: "remove", Action: "remove",
MessageCIDs: []cid.Cid{m.Cid()}, Messages: []MessagePoolEvt_Message{{Message: m.Message, CID: m.Cid()}}}
}
}) })
} }