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,13 +73,19 @@ const (
evtTypeMpoolRepub
)
// MessagePoolEvt is the journal event type emitted by the MessagePool.
// MessagePoolEvt is the journal entry for message pool events.
type MessagePoolEvt struct {
Action string
MessageCIDs []cid.Cid
Messages []MessagePoolEvt_Message
Error error `json:",omitempty"`
}
type MessagePoolEvt_Message struct {
types.Message
CID cid.Cid
}
type MessagePool struct {
lk sync.Mutex
@ -310,13 +316,13 @@ func (mp *MessagePool) repubLocal() {
}
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 {
cids = append(cids, m.Cid())
msgs = append(msgs, MessagePoolEvt_Message{Message: m.Message, CID: m.Cid()})
}
return MessagePoolEvt{
Action: "repub",
MessageCIDs: cids,
Messages: msgs,
Error: errout,
}
})
@ -489,7 +495,7 @@ func (mp *MessagePool) addLocked(m *types.SignedMessage) error {
journal.MaybeAddEntry(mp.jrnl, mp.evtTypes[evtTypeMpoolAdd], func() interface{} {
return MessagePoolEvt{
Action: "add",
MessageCIDs: []cid.Cid{m.Cid()},
Messages: []MessagePoolEvt_Message{{Message: m.Message, CID: m.Cid()}},
}
})
@ -629,8 +635,7 @@ func (mp *MessagePool) Remove(from address.Address, nonce uint64) {
journal.MaybeAddEntry(mp.jrnl, mp.evtTypes[evtTypeMpoolRemove], func() interface{} {
return MessagePoolEvt{
Action: "remove",
MessageCIDs: []cid.Cid{m.Cid()},
}
Messages: []MessagePoolEvt_Message{{Message: m.Message, CID: m.Cid()}}}
})
}