Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

market,dex: trade suspension #287

Merged
merged 3 commits into from
May 14, 2020
Merged

market,dex: trade suspension #287

merged 3 commits into from
May 14, 2020

Commits on May 14, 2020

  1. Configuration menu
    Copy the full SHA
    30fec9c View commit details
    Browse the repository at this point in the history
  2. market,dex,admin,db,book,msgjson: Suspend support, clean Market stop

    Refactor epochPump (into epump.go) for suspend support.
    
    Add Market.Suspend and Market.Running.
    
    When persistBook is false, in-memory and persistent books are purged.
    Add the PurgeBook method to Market to do this. PurgeBook calls the new
    OrderArchiver.FlushBook method, clears the in-memory book, and unlocks
    all coins. TODO: unlock just the book orders, not possible epoch orders.
    
    Run shutdown sequence is now meticulous.
    
    Use internal notifyChan with lifetime of Run, and async subscriber
    broadcasts via the closure goroutine inside Run.
    
    db: add OrderArchiver.FlushBook
    
    Add the FlushBook method to the pg.Archiver type.  It changes all orders
    for a market that have status booked to status revoked, and it creates
    and stores the server-generated pseudocancel orders. It does this all in
    a single db transaction.  This is similar to calling RevokeOrder
    individually on all booked orders.
    
    The new PurgeBook query template is added to do the bulk book-revoked
    status change for a market.
    
    coinlock: Add UnlockAll to CoinLocker interface.
    
    book: add Clear method to Book
    
    market: rework bookUpdateSignal -> updateAction+sigData
    
    Remove bookUpdateSignal, which combined data used for many different
    signals, and create updateSignal with action and data fields. Receivers
    will type cast data into one of several sigData types that contain only
    the data that is relevant to the action at hand.
    
    msgjson, market: add TradeSuspension message
    
    (*BookRouter).runBook now sends msgjson.TradeSuspension for
    msgjson.SuspensionRoute when the market sends a sigDataSuspend
    on the order feed.  (*Market).Run sends this signal when cycleEpoch hits
    the target suspend epoch index.
    
    market,dex: SuspendMarket methods for OrderRouter and DEX mgr
    
    Add (*OrderRouter).SuspendMarket, called from the DEX manager in the new
    server/dex.(*DEX) SuspendMarket method.
    
    server/admin: suspend and market info routes
    
    msgjson: suspend data in config
    
    server/dex: on suspend update config resp and send TradeSuspension
    
    market: Add Status type and (*Market).Status
    
    dex: add MarketStatus and MarketStatuses methods for admin API
    
    admin: add /markets
    
    The markets route summarizes configured markets.  e.g.
    
    $   dexadm markets
    {
        "btc_ltc": {
            "running": true,
            "epochlen": 6000,
            "activeepoch": 264872312,
            "startepoch": 264872312
        },
        "dcr_btc": {
            "running": true,
            "epochlen": 7000,
            "activeepoch": 227033410,
            "startepoch": 227033410
        }
    }
    
    $   dexadm market/dcr_btc/suspend
    {
        "market": "dcr_btc",
        "finalepoch": 227033424,
        "supendtime": "2020-05-11T21:52:55Z"
    }
    
    $   dexadm markets{
        "btc_ltc": {
            "running": true,
            "epochlen": 6000,
            "activeepoch": 264872328,
            "startepoch": 264872328
        },
        "dcr_btc": {
            "running": true,
            "epochlen": 7000,
            "activeepoch": 227033424,
            "startepoch": 227033424,
            "finalepoch": 227033424,
            "persistbook": true
        }
    }
    
    $   dexadm markets
    {
        "btc_ltc": {
            "running": true,
            "epochlen": 6000,
            "activeepoch": 264872329,
            "startepoch": 264872329
        },
        "dcr_btc": {
            "running": false,
            "epochlen": 7000,
            "activeepoch": 0,
            "startepoch": 0,
            "finalepoch": 227033424,
            "persistbook": true
        }
    }
    chappjc committed May 14, 2020
    Configuration menu
    Copy the full SHA
    4e189cd View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a609a4d View commit details
    Browse the repository at this point in the history