decred.org/dcrdex@v1.0.5/client/mm/notification.go (about)

     1  // This code is available on the terms of the project LICENSE.md file,
     2  // also available online at https://blueoakcouncil.org/license/1.0.0.
     3  
     4  package mm
     5  
     6  import (
     7  	"decred.org/dcrdex/client/db"
     8  )
     9  
    10  const (
    11  	NoteTypeRunStats        = "runstats"
    12  	NoteTypeRunEvent        = "runevent"
    13  	NoteTypeCEXNotification = "cexnote"
    14  	NoteTypeEpochReport     = "epochreport"
    15  	NoteTypeCEXProblems     = "cexproblems"
    16  )
    17  
    18  type runStatsNote struct {
    19  	db.Notification
    20  
    21  	Host      string    `json:"host"`
    22  	BaseID    uint32    `json:"baseID"`
    23  	QuoteID   uint32    `json:"quoteID"`
    24  	StartTime int64     `json:"startTime"`
    25  	Stats     *RunStats `json:"stats"`
    26  }
    27  
    28  func newRunStatsNote(host string, baseID, quoteID uint32, stats *RunStats) *runStatsNote {
    29  	return &runStatsNote{
    30  		Notification: db.NewNotification(NoteTypeRunStats, "", "", "", db.Data),
    31  		Host:         host,
    32  		BaseID:       baseID,
    33  		QuoteID:      quoteID,
    34  		Stats:        stats,
    35  	}
    36  }
    37  
    38  type runEventNote struct {
    39  	db.Notification
    40  
    41  	Host      string             `json:"host"`
    42  	BaseID    uint32             `json:"baseID"`
    43  	QuoteID   uint32             `json:"quoteID"`
    44  	StartTime int64              `json:"startTime"`
    45  	Event     *MarketMakingEvent `json:"event"`
    46  }
    47  
    48  func newRunEventNote(host string, baseID, quoteID uint32, startTime int64, event *MarketMakingEvent) *runEventNote {
    49  	return &runEventNote{
    50  		Notification: db.NewNotification(NoteTypeRunEvent, "", "", "", db.Data),
    51  		Host:         host,
    52  		BaseID:       baseID,
    53  		QuoteID:      quoteID,
    54  		StartTime:    startTime,
    55  		Event:        event,
    56  	}
    57  }
    58  
    59  type cexNotification struct {
    60  	db.Notification
    61  	CEXName string      `json:"cexName"`
    62  	Note    interface{} `json:"note"`
    63  }
    64  
    65  const (
    66  	TopicBalanceUpdate = "BalanceUpdate"
    67  )
    68  
    69  func newCexUpdateNote(cexName string, topic db.Topic, note interface{}) *cexNotification {
    70  	return &cexNotification{
    71  		Notification: db.NewNotification(NoteTypeCEXNotification, topic, "", "", db.Data),
    72  		CEXName:      cexName,
    73  		Note:         note,
    74  	}
    75  }
    76  
    77  type botProblemsNotification struct {
    78  	db.Notification
    79  	Host    string       `json:"host"`
    80  	BaseID  uint32       `json:"baseID"`
    81  	QuoteID uint32       `json:"quoteID"`
    82  	Report  *EpochReport `json:"report"`
    83  }
    84  
    85  func newEpochReportNote(host string, baseID, quoteID uint32, report *EpochReport) *botProblemsNotification {
    86  	return &botProblemsNotification{
    87  		Notification: db.NewNotification(NoteTypeEpochReport, "", "", "", db.Data),
    88  		Host:         host,
    89  		BaseID:       baseID,
    90  		QuoteID:      quoteID,
    91  		Report:       report,
    92  	}
    93  }
    94  
    95  type cexProblemsNotification struct {
    96  	db.Notification
    97  	Host     string       `json:"host"`
    98  	BaseID   uint32       `json:"baseID"`
    99  	QuoteID  uint32       `json:"quoteID"`
   100  	Problems *CEXProblems `json:"problems"`
   101  }
   102  
   103  func newCexProblemsNote(host string, baseID, quoteID uint32, problems *CEXProblems) *cexProblemsNotification {
   104  	return &cexProblemsNotification{
   105  		Notification: db.NewNotification(NoteTypeCEXProblems, "", "", "", db.Data),
   106  		Host:         host,
   107  		BaseID:       baseID,
   108  		QuoteID:      quoteID,
   109  		Problems:     problems,
   110  	}
   111  }