2020-09-14 18:01:35 +00:00
|
|
|
package markets
|
2020-09-14 15:20:01 +00:00
|
|
|
|
|
|
|
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.
|
2020-10-09 19:52:04 +00:00
|
|
|
func StorageClientJournaler(j journal.Journal, evtType journal.EventType) func(event storagemarket.ClientEvent, deal storagemarket.ClientDeal) {
|
2020-09-14 15:20:01 +00:00
|
|
|
return func(event storagemarket.ClientEvent, deal storagemarket.ClientDeal) {
|
2020-10-09 19:52:04 +00:00
|
|
|
j.RecordEvent(evtType, func() interface{} {
|
2020-09-14 15:20:01 +00:00
|
|
|
return StorageClientEvt{
|
|
|
|
Event: storagemarket.ClientEvents[event],
|
|
|
|
Deal: deal,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// StorageProviderJournaler records journal events from the storage provider.
|
2020-10-09 19:52:04 +00:00
|
|
|
func StorageProviderJournaler(j journal.Journal, evtType journal.EventType) func(event storagemarket.ProviderEvent, deal storagemarket.MinerDeal) {
|
2020-09-14 15:20:01 +00:00
|
|
|
return func(event storagemarket.ProviderEvent, deal storagemarket.MinerDeal) {
|
2020-10-09 19:52:04 +00:00
|
|
|
j.RecordEvent(evtType, func() interface{} {
|
2020-09-14 15:20:01 +00:00
|
|
|
return StorageProviderEvt{
|
|
|
|
Event: storagemarket.ProviderEvents[event],
|
|
|
|
Deal: deal,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RetrievalClientJournaler records journal events from the retrieval client.
|
2020-10-09 19:52:04 +00:00
|
|
|
func RetrievalClientJournaler(j journal.Journal, evtType journal.EventType) func(event retrievalmarket.ClientEvent, deal retrievalmarket.ClientDealState) {
|
2020-09-14 15:20:01 +00:00
|
|
|
return func(event retrievalmarket.ClientEvent, deal retrievalmarket.ClientDealState) {
|
2020-10-09 19:52:04 +00:00
|
|
|
j.RecordEvent(evtType, func() interface{} {
|
2020-09-14 15:20:01 +00:00
|
|
|
return RetrievalClientEvt{
|
|
|
|
Event: retrievalmarket.ClientEvents[event],
|
|
|
|
Deal: deal,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RetrievalProviderJournaler records journal events from the retrieval provider.
|
2020-10-09 19:52:04 +00:00
|
|
|
func RetrievalProviderJournaler(j journal.Journal, evtType journal.EventType) func(event retrievalmarket.ProviderEvent, deal retrievalmarket.ProviderDealState) {
|
2020-09-14 15:20:01 +00:00
|
|
|
return func(event retrievalmarket.ProviderEvent, deal retrievalmarket.ProviderDealState) {
|
2020-10-09 19:52:04 +00:00
|
|
|
j.RecordEvent(evtType, func() interface{} {
|
2020-09-14 15:20:01 +00:00
|
|
|
return RetrievalProviderEvt{
|
|
|
|
Event: retrievalmarket.ProviderEvents[event],
|
|
|
|
Deal: deal,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|