748d2e82a7
Motivation: * Run lotus with the race detector enabled (primary motivation). * Allow multiple lotus nodes in a process (not a high priority). Previously, the journal was shared between all lotus instances, but it was initialized for every new node. This caused safety problems in tests (at a minimum). This patch explicitly passes the journal to all services that need it.
77 lines
2.4 KiB
Go
77 lines
2.4 KiB
Go
package markets
|
|
|
|
import (
|
|
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
|
|
|
"github.com/filecoin-project/lotus/journal"
|
|
)
|
|
|
|
type StorageClientEvt struct {
|
|
Event string
|
|
Deal storagemarket.ClientDeal
|
|
}
|
|
|
|
type StorageProviderEvt struct {
|
|
Event string
|
|
Deal storagemarket.MinerDeal
|
|
}
|
|
|
|
type RetrievalClientEvt struct {
|
|
Event string
|
|
Deal retrievalmarket.ClientDealState
|
|
}
|
|
|
|
type RetrievalProviderEvt struct {
|
|
Event string
|
|
Deal retrievalmarket.ProviderDealState
|
|
}
|
|
|
|
// StorageClientJournaler records journal events from the storage client.
|
|
func StorageClientJournaler(j journal.Journal, evtType journal.EventType) func(event storagemarket.ClientEvent, deal storagemarket.ClientDeal) {
|
|
return func(event storagemarket.ClientEvent, deal storagemarket.ClientDeal) {
|
|
j.RecordEvent(evtType, func() interface{} {
|
|
return StorageClientEvt{
|
|
Event: storagemarket.ClientEvents[event],
|
|
Deal: deal,
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// StorageProviderJournaler records journal events from the storage provider.
|
|
func StorageProviderJournaler(j journal.Journal, evtType journal.EventType) func(event storagemarket.ProviderEvent, deal storagemarket.MinerDeal) {
|
|
return func(event storagemarket.ProviderEvent, deal storagemarket.MinerDeal) {
|
|
j.RecordEvent(evtType, func() interface{} {
|
|
return StorageProviderEvt{
|
|
Event: storagemarket.ProviderEvents[event],
|
|
Deal: deal,
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// RetrievalClientJournaler records journal events from the retrieval client.
|
|
func RetrievalClientJournaler(j journal.Journal, evtType journal.EventType) func(event retrievalmarket.ClientEvent, deal retrievalmarket.ClientDealState) {
|
|
return func(event retrievalmarket.ClientEvent, deal retrievalmarket.ClientDealState) {
|
|
j.RecordEvent(evtType, func() interface{} {
|
|
return RetrievalClientEvt{
|
|
Event: retrievalmarket.ClientEvents[event],
|
|
Deal: deal,
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// RetrievalProviderJournaler records journal events from the retrieval provider.
|
|
func RetrievalProviderJournaler(j journal.Journal, evtType journal.EventType) func(event retrievalmarket.ProviderEvent, deal retrievalmarket.ProviderDealState) {
|
|
return func(event retrievalmarket.ProviderEvent, deal retrievalmarket.ProviderDealState) {
|
|
j.RecordEvent(evtType, func() interface{} {
|
|
return RetrievalProviderEvt{
|
|
Event: retrievalmarket.ProviderEvents[event],
|
|
Deal: deal,
|
|
}
|
|
})
|
|
}
|
|
}
|