id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
141,700
decred/dcrdata
exchanges/exchanges.go
wsFailed
func (xc *CommonExchange) wsFailed() bool { xc.wsMtx.RLock() defer xc.wsMtx.RUnlock() return xc.wsSync.fail.After(xc.wsSync.update) }
go
func (xc *CommonExchange) wsFailed() bool { xc.wsMtx.RLock() defer xc.wsMtx.RUnlock() return xc.wsSync.fail.After(xc.wsSync.update) }
[ "func", "(", "xc", "*", "CommonExchange", ")", "wsFailed", "(", ")", "bool", "{", "xc", ".", "wsMtx", ".", "RLock", "(", ")", "\n", "defer", "xc", ".", "wsMtx", ".", "RUnlock", "(", ")", "\n", "return", "xc", ".", "wsSync", ".", "fail", ".", "Aft...
// Checks whether the websocket is in a failed state.
[ "Checks", "whether", "the", "websocket", "is", "in", "a", "failed", "state", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L601-L605
141,701
decred/dcrdata
exchanges/exchanges.go
wsErrorCount
func (xc *CommonExchange) wsErrorCount() int { xc.wsMtx.RLock() defer xc.wsMtx.RUnlock() return xc.wsSync.errCount }
go
func (xc *CommonExchange) wsErrorCount() int { xc.wsMtx.RLock() defer xc.wsMtx.RUnlock() return xc.wsSync.errCount }
[ "func", "(", "xc", "*", "CommonExchange", ")", "wsErrorCount", "(", ")", "int", "{", "xc", ".", "wsMtx", ".", "RLock", "(", ")", "\n", "defer", "xc", ".", "wsMtx", ".", "RUnlock", "(", ")", "\n", "return", "xc", ".", "wsSync", ".", "errCount", "\n"...
// The count of errors logged since the last success-triggered reset.
[ "The", "count", "of", "errors", "logged", "since", "the", "last", "success", "-", "triggered", "reset", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L608-L612
141,702
decred/dcrdata
exchanges/exchanges.go
newCommonExchange
func newCommonExchange(token string, client *http.Client, reqs requests, channels *BotChannels) *CommonExchange { var tZero time.Time return &CommonExchange{ token: token, client: client, channels: channels, currentState: new(ExchangeState), lastUpdate: tZero, lastFail: tZero, la...
go
func newCommonExchange(token string, client *http.Client, reqs requests, channels *BotChannels) *CommonExchange { var tZero time.Time return &CommonExchange{ token: token, client: client, channels: channels, currentState: new(ExchangeState), lastUpdate: tZero, lastFail: tZero, la...
[ "func", "newCommonExchange", "(", "token", "string", ",", "client", "*", "http", ".", "Client", ",", "reqs", "requests", ",", "channels", "*", "BotChannels", ")", "*", "CommonExchange", "{", "var", "tZero", "time", ".", "Time", "\n", "return", "&", "Common...
// Used to initialize the embedding exchanges.
[ "Used", "to", "initialize", "the", "embedding", "exchanges", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L615-L628
141,703
decred/dcrdata
exchanges/exchanges.go
NewCoinbase
func NewCoinbase(client *http.Client, channels *BotChannels) (coinbase Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, CoinbaseURLs.Price, nil) if err != nil { return } coinbase = &CoinbaseExchange{ CommonExchange: newCommonExchange(Coinbase, client, reqs, channel...
go
func NewCoinbase(client *http.Client, channels *BotChannels) (coinbase Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, CoinbaseURLs.Price, nil) if err != nil { return } coinbase = &CoinbaseExchange{ CommonExchange: newCommonExchange(Coinbase, client, reqs, channel...
[ "func", "NewCoinbase", "(", "client", "*", "http", ".", "Client", ",", "channels", "*", "BotChannels", ")", "(", "coinbase", "Exchange", ",", "err", "error", ")", "{", "reqs", ":=", "newRequests", "(", ")", "\n", "reqs", ".", "price", ",", "err", "=", ...
// NewCoinbase constructs a CoinbaseExchange.
[ "NewCoinbase", "constructs", "a", "CoinbaseExchange", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L636-L646
141,704
decred/dcrdata
exchanges/exchanges.go
Refresh
func (coinbase *CoinbaseExchange) Refresh() { coinbase.LogRequest() response := new(CoinbaseResponse) err := coinbase.fetch(coinbase.requests.price, response) if err != nil { coinbase.fail("Fetch", err) return } indices := make(FiatIndices) for code, floatStr := range response.Data.Rates { price, err := s...
go
func (coinbase *CoinbaseExchange) Refresh() { coinbase.LogRequest() response := new(CoinbaseResponse) err := coinbase.fetch(coinbase.requests.price, response) if err != nil { coinbase.fail("Fetch", err) return } indices := make(FiatIndices) for code, floatStr := range response.Data.Rates { price, err := s...
[ "func", "(", "coinbase", "*", "CoinbaseExchange", ")", "Refresh", "(", ")", "{", "coinbase", ".", "LogRequest", "(", ")", "\n", "response", ":=", "new", "(", "CoinbaseResponse", ")", "\n", "err", ":=", "coinbase", ".", "fetch", "(", "coinbase", ".", "req...
// Refresh retrieves and parses API data from Coinbase.
[ "Refresh", "retrieves", "and", "parses", "API", "data", "from", "Coinbase", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L660-L679
141,705
decred/dcrdata
exchanges/exchanges.go
NewCoindesk
func NewCoindesk(client *http.Client, channels *BotChannels) (coindesk Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, CoindeskURLs.Price, nil) if err != nil { return } coindesk = &CoindeskExchange{ CommonExchange: newCommonExchange(Coindesk, client, reqs, channel...
go
func NewCoindesk(client *http.Client, channels *BotChannels) (coindesk Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, CoindeskURLs.Price, nil) if err != nil { return } coindesk = &CoindeskExchange{ CommonExchange: newCommonExchange(Coindesk, client, reqs, channel...
[ "func", "NewCoindesk", "(", "client", "*", "http", ".", "Client", ",", "channels", "*", "BotChannels", ")", "(", "coindesk", "Exchange", ",", "err", "error", ")", "{", "reqs", ":=", "newRequests", "(", ")", "\n", "reqs", ".", "price", ",", "err", "=", ...
// NewCoindesk constructs a CoindeskExchange.
[ "NewCoindesk", "constructs", "a", "CoindeskExchange", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L688-L698
141,706
decred/dcrdata
exchanges/exchanges.go
Refresh
func (coindesk *CoindeskExchange) Refresh() { coindesk.LogRequest() response := new(CoindeskResponse) err := coindesk.fetch(coindesk.requests.price, response) if err != nil { coindesk.fail("Fetch", err) return } indices := make(FiatIndices) for code, bpi := range response.Bpi { indices[code] = bpi.RateFlo...
go
func (coindesk *CoindeskExchange) Refresh() { coindesk.LogRequest() response := new(CoindeskResponse) err := coindesk.fetch(coindesk.requests.price, response) if err != nil { coindesk.fail("Fetch", err) return } indices := make(FiatIndices) for code, bpi := range response.Bpi { indices[code] = bpi.RateFlo...
[ "func", "(", "coindesk", "*", "CoindeskExchange", ")", "Refresh", "(", ")", "{", "coindesk", ".", "LogRequest", "(", ")", "\n", "response", ":=", "new", "(", "CoindeskResponse", ")", "\n", "err", ":=", "coindesk", ".", "fetch", "(", "coindesk", ".", "req...
// Refresh retrieves and parses API data from Coindesk.
[ "Refresh", "retrieves", "and", "parses", "API", "data", "from", "Coindesk", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L725-L739
141,707
decred/dcrdata
exchanges/exchanges.go
NewBinance
func NewBinance(client *http.Client, channels *BotChannels) (binance Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, BinanceURLs.Price, nil) if err != nil { return } reqs.depth, err = http.NewRequest(http.MethodGet, BinanceURLs.Depth, nil) if err != nil { return...
go
func NewBinance(client *http.Client, channels *BotChannels) (binance Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, BinanceURLs.Price, nil) if err != nil { return } reqs.depth, err = http.NewRequest(http.MethodGet, BinanceURLs.Depth, nil) if err != nil { return...
[ "func", "NewBinance", "(", "client", "*", "http", ".", "Client", ",", "channels", "*", "BotChannels", ")", "(", "binance", "Exchange", ",", "err", "error", ")", "{", "reqs", ":=", "newRequests", "(", ")", "\n", "reqs", ".", "price", ",", "err", "=", ...
// NewBinance constructs a BinanceExchange.
[ "NewBinance", "constructs", "a", "BinanceExchange", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L747-L769
141,708
decred/dcrdata
exchanges/exchanges.go
Refresh
func (binance *BinanceExchange) Refresh() { binance.LogRequest() priceResponse := new(BinancePriceResponse) err := binance.fetch(binance.requests.price, priceResponse) if err != nil { binance.fail("Fetch price", err) return } price, err := strconv.ParseFloat(priceResponse.LastPrice, 64) if err != nil { bin...
go
func (binance *BinanceExchange) Refresh() { binance.LogRequest() priceResponse := new(BinancePriceResponse) err := binance.fetch(binance.requests.price, priceResponse) if err != nil { binance.fail("Fetch price", err) return } price, err := strconv.ParseFloat(priceResponse.LastPrice, 64) if err != nil { bin...
[ "func", "(", "binance", "*", "BinanceExchange", ")", "Refresh", "(", ")", "{", "binance", ".", "LogRequest", "(", ")", "\n", "priceResponse", ":=", "new", "(", "BinancePriceResponse", ")", "\n", "err", ":=", "binance", ".", "fetch", "(", "binance", ".", ...
// Refresh retrieves and parses API data from Binance.
[ "Refresh", "retrieves", "and", "parses", "API", "data", "from", "Binance", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L936-L1005
141,709
decred/dcrdata
exchanges/exchanges.go
NewBittrex
func NewBittrex(client *http.Client, channels *BotChannels) (bittrex Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, BittrexURLs.Price, nil) if err != nil { return } reqs.depth, err = http.NewRequest(http.MethodGet, BittrexURLs.Depth, nil) if err != nil { return...
go
func NewBittrex(client *http.Client, channels *BotChannels) (bittrex Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, BittrexURLs.Price, nil) if err != nil { return } reqs.depth, err = http.NewRequest(http.MethodGet, BittrexURLs.Depth, nil) if err != nil { return...
[ "func", "NewBittrex", "(", "client", "*", "http", ".", "Client", ",", "channels", "*", "BotChannels", ")", "(", "bittrex", "Exchange", ",", "err", "error", ")", "{", "reqs", ":=", "newRequests", "(", ")", "\n", "reqs", ".", "price", ",", "err", "=", ...
// NewBittrex constructs a BittrexExchange.
[ "NewBittrex", "constructs", "a", "BittrexExchange", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1014-L1038
141,710
decred/dcrdata
exchanges/exchanges.go
makePts
func (pts BittrexDepthArray) makePts() []DepthPoint { depth := make([]DepthPoint, 0, len(pts)) for _, pt := range pts { depth = append(depth, DepthPoint{ Quantity: pt.Quantity, Price: pt.Rate, }) } return depth }
go
func (pts BittrexDepthArray) makePts() []DepthPoint { depth := make([]DepthPoint, 0, len(pts)) for _, pt := range pts { depth = append(depth, DepthPoint{ Quantity: pt.Quantity, Price: pt.Rate, }) } return depth }
[ "func", "(", "pts", "BittrexDepthArray", ")", "makePts", "(", ")", "[", "]", "DepthPoint", "{", "depth", ":=", "make", "(", "[", "]", "DepthPoint", ",", "0", ",", "len", "(", "pts", ")", ")", "\n", "for", "_", ",", "pt", ":=", "range", "pts", "{"...
// Translate the bittrex list to DepthPoints.
[ "Translate", "the", "bittrex", "list", "to", "DepthPoints", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1080-L1089
141,711
decred/dcrdata
exchanges/exchanges.go
translate
func (r *BittrexDepthResponse) translate() *DepthData { if r == nil { return nil } if !r.Success { log.Errorf("Bittrex depth result error: %s", r.Message) return nil } depth := new(DepthData) depth.Time = time.Now().Unix() depth.Asks = r.Result.Sell.makePts() depth.Bids = r.Result.Buy.makePts() return de...
go
func (r *BittrexDepthResponse) translate() *DepthData { if r == nil { return nil } if !r.Success { log.Errorf("Bittrex depth result error: %s", r.Message) return nil } depth := new(DepthData) depth.Time = time.Now().Unix() depth.Asks = r.Result.Sell.makePts() depth.Bids = r.Result.Buy.makePts() return de...
[ "func", "(", "r", "*", "BittrexDepthResponse", ")", "translate", "(", ")", "*", "DepthData", "{", "if", "r", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "!", "r", ".", "Success", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "r",...
// Translate the Bittrex response to DepthData.
[ "Translate", "the", "Bittrex", "response", "to", "DepthData", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1099-L1112
141,712
decred/dcrdata
exchanges/exchanges.go
Refresh
func (bittrex *BittrexExchange) Refresh() { bittrex.LogRequest() priceResponse := new(BittrexPriceResponse) err := bittrex.fetch(bittrex.requests.price, priceResponse) if err != nil { bittrex.fail("Fetch", err) return } if !priceResponse.Success { bittrex.fail("Unsuccessful resquest", err) return } if l...
go
func (bittrex *BittrexExchange) Refresh() { bittrex.LogRequest() priceResponse := new(BittrexPriceResponse) err := bittrex.fetch(bittrex.requests.price, priceResponse) if err != nil { bittrex.fail("Fetch", err) return } if !priceResponse.Success { bittrex.fail("Unsuccessful resquest", err) return } if l...
[ "func", "(", "bittrex", "*", "BittrexExchange", ")", "Refresh", "(", ")", "{", "bittrex", ".", "LogRequest", "(", ")", "\n", "priceResponse", ":=", "new", "(", "BittrexPriceResponse", ")", "\n", "err", ":=", "bittrex", ".", "fetch", "(", "bittrex", ".", ...
// Refresh retrieves and parses API data from Bittrex. // Bittrex provides timestamps in a string format that is not quite RFC 3339.
[ "Refresh", "retrieves", "and", "parses", "API", "data", "from", "Bittrex", ".", "Bittrex", "provides", "timestamps", "in", "a", "string", "format", "that", "is", "not", "quite", "RFC", "3339", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1159-L1221
141,713
decred/dcrdata
exchanges/exchanges.go
NewDragonEx
func NewDragonEx(client *http.Client, channels *BotChannels) (dragonex Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, DragonExURLs.Price, nil) if err != nil { return } // Dragonex has separate endpoints for buy and sell, so the requests are // stored as fields of...
go
func NewDragonEx(client *http.Client, channels *BotChannels) (dragonex Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, DragonExURLs.Price, nil) if err != nil { return } // Dragonex has separate endpoints for buy and sell, so the requests are // stored as fields of...
[ "func", "NewDragonEx", "(", "client", "*", "http", ".", "Client", ",", "channels", "*", "BotChannels", ")", "(", "dragonex", "Exchange", ",", "err", "error", ")", "{", "reqs", ":=", "newRequests", "(", ")", "\n", "reqs", ".", "price", ",", "err", "=", ...
// NewDragonEx constructs a DragonExchange.
[ "NewDragonEx", "constructs", "a", "DragonExchange", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1232-L1266
141,714
decred/dcrdata
exchanges/exchanges.go
NewHuobi
func NewHuobi(client *http.Client, channels *BotChannels) (huobi Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, HuobiURLs.Price, nil) if err != nil { return } reqs.price.Header.Add("Content-Type", "application/x-www-form-urlencoded") reqs.depth, err = http.NewReq...
go
func NewHuobi(client *http.Client, channels *BotChannels) (huobi Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, HuobiURLs.Price, nil) if err != nil { return } reqs.price.Header.Add("Content-Type", "application/x-www-form-urlencoded") reqs.depth, err = http.NewReq...
[ "func", "NewHuobi", "(", "client", "*", "http", ".", "Client", ",", "channels", "*", "BotChannels", ")", "(", "huobi", "Exchange", ",", "err", "error", ")", "{", "reqs", ":=", "newRequests", "(", ")", "\n", "reqs", ".", "price", ",", "err", "=", "htt...
// NewHuobi constructs a HuobiExchange.
[ "NewHuobi", "constructs", "a", "HuobiExchange", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1589-L1615
141,715
decred/dcrdata
exchanges/exchanges.go
Refresh
func (huobi *HuobiExchange) Refresh() { huobi.LogRequest() priceResponse := new(HuobiPriceResponse) err := huobi.fetch(huobi.requests.price, priceResponse) if err != nil { huobi.fail("Fetch", err) return } if priceResponse.Status != huobi.Ok { huobi.fail("Status not ok", fmt.Errorf("Expected status %s. Rece...
go
func (huobi *HuobiExchange) Refresh() { huobi.LogRequest() priceResponse := new(HuobiPriceResponse) err := huobi.fetch(huobi.requests.price, priceResponse) if err != nil { huobi.fail("Fetch", err) return } if priceResponse.Status != huobi.Ok { huobi.fail("Status not ok", fmt.Errorf("Expected status %s. Rece...
[ "func", "(", "huobi", "*", "HuobiExchange", ")", "Refresh", "(", ")", "{", "huobi", ".", "LogRequest", "(", ")", "\n", "priceResponse", ":=", "new", "(", "HuobiPriceResponse", ")", "\n", "err", ":=", "huobi", ".", "fetch", "(", "huobi", ".", "requests", ...
// Refresh retrieves and parses API data from Huobi.
[ "Refresh", "retrieves", "and", "parses", "API", "data", "from", "Huobi", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1713-L1777
141,716
decred/dcrdata
exchanges/exchanges.go
NewPoloniex
func NewPoloniex(client *http.Client, channels *BotChannels) (poloniex Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, PoloniexURLs.Price, nil) if err != nil { return } reqs.depth, err = http.NewRequest(http.MethodGet, PoloniexURLs.Depth, nil) if err != nil { re...
go
func NewPoloniex(client *http.Client, channels *BotChannels) (poloniex Exchange, err error) { reqs := newRequests() reqs.price, err = http.NewRequest(http.MethodGet, PoloniexURLs.Price, nil) if err != nil { return } reqs.depth, err = http.NewRequest(http.MethodGet, PoloniexURLs.Depth, nil) if err != nil { re...
[ "func", "NewPoloniex", "(", "client", "*", "http", ".", "Client", ",", "channels", "*", "BotChannels", ")", "(", "poloniex", "Exchange", ",", "err", "error", ")", "{", "reqs", ":=", "newRequests", "(", ")", "\n", "reqs", ".", "price", ",", "err", "=", ...
// NewPoloniex constructs a PoloniexExchange.
[ "NewPoloniex", "constructs", "a", "PoloniexExchange", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1799-L1832
141,717
decred/dcrdata
exchanges/exchanges.go
processWsOrderbook
func (poloniex *PoloniexExchange) processWsOrderbook(sequenceID int64, responseList []interface{}) { subList, ok := responseList[0].([]interface{}) if !ok { poloniex.setWsFail(fmt.Errorf("Failed to parse 0th element of poloniex response array")) return } if len(subList) < 2 { poloniex.setWsFail(fmt.Errorf("Un...
go
func (poloniex *PoloniexExchange) processWsOrderbook(sequenceID int64, responseList []interface{}) { subList, ok := responseList[0].([]interface{}) if !ok { poloniex.setWsFail(fmt.Errorf("Failed to parse 0th element of poloniex response array")) return } if len(subList) < 2 { poloniex.setWsFail(fmt.Errorf("Un...
[ "func", "(", "poloniex", "*", "PoloniexExchange", ")", "processWsOrderbook", "(", "sequenceID", "int64", ",", "responseList", "[", "]", "interface", "{", "}", ")", "{", "subList", ",", "ok", ":=", "responseList", "[", "0", "]", ".", "(", "[", "]", "inter...
// This initial websocket message is a full orderbook.
[ "This", "initial", "websocket", "message", "is", "a", "full", "orderbook", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L1994-L2044
141,718
decred/dcrdata
exchanges/exchanges.go
mergePoloniexDepthUpdates
func mergePoloniexDepthUpdates(target, source poloniexOrders) { for bin, pt := range source { if pt.volume == 0 { delete(source, bin) delete(target, bin) continue } target[bin] = pt } }
go
func mergePoloniexDepthUpdates(target, source poloniexOrders) { for bin, pt := range source { if pt.volume == 0 { delete(source, bin) delete(target, bin) continue } target[bin] = pt } }
[ "func", "mergePoloniexDepthUpdates", "(", "target", ",", "source", "poloniexOrders", ")", "{", "for", "bin", ",", "pt", ":=", "range", "source", "{", "if", "pt", ".", "volume", "==", "0", "{", "delete", "(", "source", ",", "bin", ")", "\n", "delete", "...
// A helper for merging a source map into a target map. Poloniex order in the // source map with volume 0 will trigger a deletion from the target map.
[ "A", "helper", "for", "merging", "a", "source", "map", "into", "a", "target", "map", ".", "Poloniex", "order", "in", "the", "source", "map", "with", "volume", "0", "will", "trigger", "a", "deletion", "from", "the", "target", "map", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L2048-L2057
141,719
decred/dcrdata
exchanges/exchanges.go
accumulateOrders
func (poloniex *PoloniexExchange) accumulateOrders(sequenceID int64, asks, buys poloniexOrders) { poloniex.orderMtx.Lock() defer poloniex.orderMtx.Unlock() poloniex.orderSeq++ if sequenceID != poloniex.orderSeq { poloniex.setWsFail(fmt.Errorf("poloniex sequence id failure. expected %d, received %d", poloniex.orde...
go
func (poloniex *PoloniexExchange) accumulateOrders(sequenceID int64, asks, buys poloniexOrders) { poloniex.orderMtx.Lock() defer poloniex.orderMtx.Unlock() poloniex.orderSeq++ if sequenceID != poloniex.orderSeq { poloniex.setWsFail(fmt.Errorf("poloniex sequence id failure. expected %d, received %d", poloniex.orde...
[ "func", "(", "poloniex", "*", "PoloniexExchange", ")", "accumulateOrders", "(", "sequenceID", "int64", ",", "asks", ",", "buys", "poloniexOrders", ")", "{", "poloniex", ".", "orderMtx", ".", "Lock", "(", ")", "\n", "defer", "poloniex", ".", "orderMtx", ".", ...
// Merge order updates under a write lock.
[ "Merge", "order", "updates", "under", "a", "write", "lock", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L2060-L2070
141,720
decred/dcrdata
exchanges/exchanges.go
firstCode
func firstCode(responseList []interface{}) string { firstElement, ok := responseList[0].([]interface{}) if !ok { log.Errorf("parse failure in poloniex websocket message") return "" } if len(firstElement) < 1 { log.Errorf("unexpected number of parameters in poloniex websocket message") return "" } updateTy...
go
func firstCode(responseList []interface{}) string { firstElement, ok := responseList[0].([]interface{}) if !ok { log.Errorf("parse failure in poloniex websocket message") return "" } if len(firstElement) < 1 { log.Errorf("unexpected number of parameters in poloniex websocket message") return "" } updateTy...
[ "func", "firstCode", "(", "responseList", "[", "]", "interface", "{", "}", ")", "string", "{", "firstElement", ",", "ok", ":=", "responseList", "[", "0", "]", ".", "(", "[", "]", "interface", "{", "}", ")", "\n", "if", "!", "ok", "{", "log", ".", ...
// Poloniex has a string code in the result array indicating what type of // message it is.
[ "Poloniex", "has", "a", "string", "code", "in", "the", "result", "array", "indicating", "what", "type", "of", "message", "it", "is", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L2084-L2100
141,721
decred/dcrdata
exchanges/exchanges.go
processPoloniexOrderbookUpdate
func processPoloniexOrderbookUpdate(updateParams []interface{}) (*poloniexOrder, int, error) { floatDir, ok := updateParams[1].(float64) if !ok { return nil, -1, fmt.Errorf("failed to type convert poloniex orderbook update direction") } direction := int(floatDir) priceStr, ok := updateParams[2].(string) if !ok ...
go
func processPoloniexOrderbookUpdate(updateParams []interface{}) (*poloniexOrder, int, error) { floatDir, ok := updateParams[1].(float64) if !ok { return nil, -1, fmt.Errorf("failed to type convert poloniex orderbook update direction") } direction := int(floatDir) priceStr, ok := updateParams[2].(string) if !ok ...
[ "func", "processPoloniexOrderbookUpdate", "(", "updateParams", "[", "]", "interface", "{", "}", ")", "(", "*", "poloniexOrder", ",", "int", ",", "error", ")", "{", "floatDir", ",", "ok", ":=", "updateParams", "[", "1", "]", ".", "(", "float64", ")", "\n"...
// For Poloniex message "o", an update to the orderbook.
[ "For", "Poloniex", "message", "o", "an", "update", "to", "the", "orderbook", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L2103-L2129
141,722
decred/dcrdata
exchanges/exchanges.go
processTrade
func (poloniex *PoloniexExchange) processTrade(tradeParams []interface{}) (*poloniexOrder, int, error) { if len(tradeParams) != 6 { return nil, -1, fmt.Errorf("Not enough parameters in poloniex trade notification. given: %d", len(tradeParams)) } floatDir, ok := tradeParams[2].(float64) if !ok { return nil, -1, ...
go
func (poloniex *PoloniexExchange) processTrade(tradeParams []interface{}) (*poloniexOrder, int, error) { if len(tradeParams) != 6 { return nil, -1, fmt.Errorf("Not enough parameters in poloniex trade notification. given: %d", len(tradeParams)) } floatDir, ok := tradeParams[2].(float64) if !ok { return nil, -1, ...
[ "func", "(", "poloniex", "*", "PoloniexExchange", ")", "processTrade", "(", "tradeParams", "[", "]", "interface", "{", "}", ")", "(", "*", "poloniexOrder", ",", "int", ",", "error", ")", "{", "if", "len", "(", "tradeParams", ")", "!=", "6", "{", "retur...
// For Poloniex message "t", a trade. This seems to be used rarely and // sporadically, but it is used. For the BTC_DCR endpoint, almost all updates // are of the "o" type, an orderbook update. The docs are unclear about whether a trade updates the // order book, but testing seems to indicate that a "t" message is for ...
[ "For", "Poloniex", "message", "t", "a", "trade", ".", "This", "seems", "to", "be", "used", "rarely", "and", "sporadically", "but", "it", "is", "used", ".", "For", "the", "BTC_DCR", "endpoint", "almost", "all", "updates", "are", "of", "the", "o", "type", ...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L2136-L2166
141,723
decred/dcrdata
exchanges/exchanges.go
poloniexBinKeys
func poloniexBinKeys(book poloniexOrders) []int64 { keys := make([]int64, 0, len(book)) for k := range book { keys = append(keys, k) } return keys }
go
func poloniexBinKeys(book poloniexOrders) []int64 { keys := make([]int64, 0, len(book)) for k := range book { keys = append(keys, k) } return keys }
[ "func", "poloniexBinKeys", "(", "book", "poloniexOrders", ")", "[", "]", "int64", "{", "keys", ":=", "make", "(", "[", "]", "int64", ",", "0", ",", "len", "(", "book", ")", ")", "\n", "for", "k", ":=", "range", "book", "{", "keys", "=", "append", ...
// Pull out the int64 bin keys from the map.
[ "Pull", "out", "the", "int64", "bin", "keys", "from", "the", "map", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L2280-L2286
141,724
decred/dcrdata
exchanges/exchanges.go
wsDepths
func (poloniex *PoloniexExchange) wsDepths() *DepthData { poloniex.orderMtx.RLock() defer poloniex.orderMtx.RUnlock() askKeys := poloniexBinKeys(poloniex.asks) sort.Slice(askKeys, func(i, j int) bool { return askKeys[i] < askKeys[j] }) buyKeys := poloniexBinKeys(poloniex.buys) sort.Slice(buyKeys, func(i, j int...
go
func (poloniex *PoloniexExchange) wsDepths() *DepthData { poloniex.orderMtx.RLock() defer poloniex.orderMtx.RUnlock() askKeys := poloniexBinKeys(poloniex.asks) sort.Slice(askKeys, func(i, j int) bool { return askKeys[i] < askKeys[j] }) buyKeys := poloniexBinKeys(poloniex.buys) sort.Slice(buyKeys, func(i, j int...
[ "func", "(", "poloniex", "*", "PoloniexExchange", ")", "wsDepths", "(", ")", "*", "DepthData", "{", "poloniex", ".", "orderMtx", ".", "RLock", "(", ")", "\n", "defer", "poloniex", ".", "orderMtx", ".", "RUnlock", "(", ")", "\n", "askKeys", ":=", "polonie...
// Convert the intermediate orderbook to a DepthData.
[ "Convert", "the", "intermediate", "orderbook", "to", "a", "DepthData", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L2289-L2321
141,725
decred/dcrdata
exchanges/exchanges.go
connectWs
func (poloniex *PoloniexExchange) connectWs() { poloniex.connectWebsocket(poloniex.processWsMessage, &socketConfig{ address: PoloniexURLs.Websocket, }) poloniex.wsSend(poloniexOrderbookSubscription) }
go
func (poloniex *PoloniexExchange) connectWs() { poloniex.connectWebsocket(poloniex.processWsMessage, &socketConfig{ address: PoloniexURLs.Websocket, }) poloniex.wsSend(poloniexOrderbookSubscription) }
[ "func", "(", "poloniex", "*", "PoloniexExchange", ")", "connectWs", "(", ")", "{", "poloniex", ".", "connectWebsocket", "(", "poloniex", ".", "processWsMessage", ",", "&", "socketConfig", "{", "address", ":", "PoloniexURLs", ".", "Websocket", ",", "}", ")", ...
// Create a websocket connection and send the orderbook subscription.
[ "Create", "a", "websocket", "connection", "and", "send", "the", "orderbook", "subscription", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/exchanges/exchanges.go#L2324-L2329
141,726
decred/dcrdata
db/cache/charts.go
ParseZoom
func ParseZoom(zoom string) ZoomLevel { switch ZoomLevel(zoom) { case BlockZoom: return BlockZoom case WindowZoom: return WindowZoom } return DefaultZoomLevel }
go
func ParseZoom(zoom string) ZoomLevel { switch ZoomLevel(zoom) { case BlockZoom: return BlockZoom case WindowZoom: return WindowZoom } return DefaultZoomLevel }
[ "func", "ParseZoom", "(", "zoom", "string", ")", "ZoomLevel", "{", "switch", "ZoomLevel", "(", "zoom", ")", "{", "case", "BlockZoom", ":", "return", "BlockZoom", "\n", "case", "WindowZoom", ":", "return", "WindowZoom", "\n", "}", "\n", "return", "DefaultZoom...
// ParseZoom will return the matching zoom level, else the default zoom.
[ "ParseZoom", "will", "return", "the", "matching", "zoom", "level", "else", "the", "default", "zoom", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L52-L60
141,727
decred/dcrdata
db/cache/charts.go
Snip
func (set *zoomSet) Snip(length int) { set.Height = set.Height.snip(length) set.Time = set.Time.snip(length) set.PoolSize = set.PoolSize.snip(length) set.PoolValue = set.PoolValue.snip(length) set.BlockSize = set.BlockSize.snip(length) set.TxCount = set.TxCount.snip(length) set.NewAtoms = set.NewAtoms.snip(lengt...
go
func (set *zoomSet) Snip(length int) { set.Height = set.Height.snip(length) set.Time = set.Time.snip(length) set.PoolSize = set.PoolSize.snip(length) set.PoolValue = set.PoolValue.snip(length) set.BlockSize = set.BlockSize.snip(length) set.TxCount = set.TxCount.snip(length) set.NewAtoms = set.NewAtoms.snip(lengt...
[ "func", "(", "set", "*", "zoomSet", ")", "Snip", "(", "length", "int", ")", "{", "set", ".", "Height", "=", "set", ".", "Height", ".", "snip", "(", "length", ")", "\n", "set", ".", "Time", "=", "set", ".", "Time", ".", "snip", "(", "length", ")...
// Snip truncates the zoomSet to a provided length.
[ "Snip", "truncates", "the", "zoomSet", "to", "a", "provided", "length", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L213-L223
141,728
decred/dcrdata
db/cache/charts.go
newBlockSet
func newBlockSet(size int) *zoomSet { return &zoomSet{ Time: newChartUints(size), PoolSize: newChartUints(size), PoolValue: newChartFloats(size), BlockSize: newChartUints(size), TxCount: newChartUints(size), NewAtoms: newChartUints(size), Chainwork: newChartUints(size), Fees: newChartUint...
go
func newBlockSet(size int) *zoomSet { return &zoomSet{ Time: newChartUints(size), PoolSize: newChartUints(size), PoolValue: newChartFloats(size), BlockSize: newChartUints(size), TxCount: newChartUints(size), NewAtoms: newChartUints(size), Chainwork: newChartUints(size), Fees: newChartUint...
[ "func", "newBlockSet", "(", "size", "int", ")", "*", "zoomSet", "{", "return", "&", "zoomSet", "{", "Time", ":", "newChartUints", "(", "size", ")", ",", "PoolSize", ":", "newChartUints", "(", "size", ")", ",", "PoolValue", ":", "newChartFloats", "(", "si...
// Constructor for a sized zoomSet for blocks, which has has no Height slice // since the height is implicit for block-binned data.
[ "Constructor", "for", "a", "sized", "zoomSet", "for", "blocks", "which", "has", "has", "no", "Height", "slice", "since", "the", "height", "is", "implicit", "for", "block", "-", "binned", "data", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L227-L238
141,729
decred/dcrdata
db/cache/charts.go
newDaySet
func newDaySet(size int) *zoomSet { set := newBlockSet(size) set.Height = newChartUints(size) return set }
go
func newDaySet(size int) *zoomSet { set := newBlockSet(size) set.Height = newChartUints(size) return set }
[ "func", "newDaySet", "(", "size", "int", ")", "*", "zoomSet", "{", "set", ":=", "newBlockSet", "(", "size", ")", "\n", "set", ".", "Height", "=", "newChartUints", "(", "size", ")", "\n", "return", "set", "\n", "}" ]
// Constructor for a sized zoomSet for day-binned data.
[ "Constructor", "for", "a", "sized", "zoomSet", "for", "day", "-", "binned", "data", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L241-L245
141,730
decred/dcrdata
db/cache/charts.go
Snip
func (set *windowSet) Snip(length int) { set.Time = set.Time.snip(length) set.PowDiff = set.PowDiff.snip(length) set.TicketPrice = set.TicketPrice.snip(length) }
go
func (set *windowSet) Snip(length int) { set.Time = set.Time.snip(length) set.PowDiff = set.PowDiff.snip(length) set.TicketPrice = set.TicketPrice.snip(length) }
[ "func", "(", "set", "*", "windowSet", ")", "Snip", "(", "length", "int", ")", "{", "set", ".", "Time", "=", "set", ".", "Time", ".", "snip", "(", "length", ")", "\n", "set", ".", "PowDiff", "=", "set", ".", "PowDiff", ".", "snip", "(", "length", ...
// Snip truncates the windowSet to a provided length.
[ "Snip", "truncates", "the", "windowSet", "to", "a", "provided", "length", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L257-L261
141,731
decred/dcrdata
db/cache/charts.go
newWindowSet
func newWindowSet(size int) *windowSet { return &windowSet{ Time: newChartUints(size), PowDiff: newChartFloats(size), TicketPrice: newChartUints(size), } }
go
func newWindowSet(size int) *windowSet { return &windowSet{ Time: newChartUints(size), PowDiff: newChartFloats(size), TicketPrice: newChartUints(size), } }
[ "func", "newWindowSet", "(", "size", "int", ")", "*", "windowSet", "{", "return", "&", "windowSet", "{", "Time", ":", "newChartUints", "(", "size", ")", ",", "PowDiff", ":", "newChartFloats", "(", "size", ")", ",", "TicketPrice", ":", "newChartUints", "(",...
// Constructor for a sized windowSet.
[ "Constructor", "for", "a", "sized", "windowSet", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L264-L270
141,732
decred/dcrdata
db/cache/charts.go
ValidateLengths
func ValidateLengths(lens ...lengther) (int, error) { lenLen := len(lens) if lenLen == 0 { return 0, nil } firstLen := lens[0].Length() shortest := firstLen for i, l := range lens[1:lenLen] { dLen := l.Length() if dLen < firstLen { log.Warnf("charts.ValidateLengths: dataset at index %d has mismatched len...
go
func ValidateLengths(lens ...lengther) (int, error) { lenLen := len(lens) if lenLen == 0 { return 0, nil } firstLen := lens[0].Length() shortest := firstLen for i, l := range lens[1:lenLen] { dLen := l.Length() if dLen < firstLen { log.Warnf("charts.ValidateLengths: dataset at index %d has mismatched len...
[ "func", "ValidateLengths", "(", "lens", "...", "lengther", ")", "(", "int", ",", "error", ")", "{", "lenLen", ":=", "len", "(", "lens", ")", "\n", "if", "lenLen", "==", "0", "{", "return", "0", ",", "nil", "\n", "}", "\n", "firstLen", ":=", "lens",...
// Check that the length of all arguments is equal.
[ "Check", "that", "the", "length", "of", "all", "arguments", "is", "equal", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L331-L351
141,733
decred/dcrdata
db/cache/charts.go
midnight
func midnight(t uint64) (mid uint64) { if t > 0 { mid = t - t%aDay } return }
go
func midnight(t uint64) (mid uint64) { if t > 0 { mid = t - t%aDay } return }
[ "func", "midnight", "(", "t", "uint64", ")", "(", "mid", "uint64", ")", "{", "if", "t", ">", "0", "{", "mid", "=", "t", "-", "t", "%", "aDay", "\n", "}", "\n", "return", "\n", "}" ]
// Reduce the timestamp to the previous midnight.
[ "Reduce", "the", "timestamp", "to", "the", "previous", "midnight", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L354-L359
141,734
decred/dcrdata
db/cache/charts.go
ReorgHandler
func (charts *ChartData) ReorgHandler(wg *sync.WaitGroup, c chan *txhelpers.ReorgData) { defer func() { wg.Done() }() for { select { case data, ok := <-c: if !ok { return } commonAncestorHeight := uint64(data.NewChainHeight) - uint64(len(data.NewChain)) charts.mtx.Lock() defer charts.mtx.Unl...
go
func (charts *ChartData) ReorgHandler(wg *sync.WaitGroup, c chan *txhelpers.ReorgData) { defer func() { wg.Done() }() for { select { case data, ok := <-c: if !ok { return } commonAncestorHeight := uint64(data.NewChainHeight) - uint64(len(data.NewChain)) charts.mtx.Lock() defer charts.mtx.Unl...
[ "func", "(", "charts", "*", "ChartData", ")", "ReorgHandler", "(", "wg", "*", "sync", ".", "WaitGroup", ",", "c", "chan", "*", "txhelpers", ".", "ReorgData", ")", "{", "defer", "func", "(", ")", "{", "wg", ".", "Done", "(", ")", "\n", "}", "(", "...
// ReorgHandler handles the charts cache data reorganization.
[ "ReorgHandler", "handles", "the", "charts", "cache", "data", "reorganization", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L458-L486
141,735
decred/dcrdata
db/cache/charts.go
Load
func (charts *ChartData) Load(cacheDumpPath string) { t := time.Now() if err := charts.readCacheFile(cacheDumpPath); err != nil { log.Debugf("Cache dump data loading failed: %v", err) } // Bring the charts up to date. charts.Update() log.Debugf("Completed the initial chart load in %d s", time.Since(t).Second...
go
func (charts *ChartData) Load(cacheDumpPath string) { t := time.Now() if err := charts.readCacheFile(cacheDumpPath); err != nil { log.Debugf("Cache dump data loading failed: %v", err) } // Bring the charts up to date. charts.Update() log.Debugf("Completed the initial chart load in %d s", time.Since(t).Second...
[ "func", "(", "charts", "*", "ChartData", ")", "Load", "(", "cacheDumpPath", "string", ")", "{", "t", ":=", "time", ".", "Now", "(", ")", "\n\n", "if", "err", ":=", "charts", ".", "readCacheFile", "(", "cacheDumpPath", ")", ";", "err", "!=", "nil", "{...
// Load loads chart data from the gob file at the specified path and performs an // update.
[ "Load", "loads", "chart", "data", "from", "the", "gob", "file", "at", "the", "specified", "path", "and", "performs", "an", "update", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L569-L580
141,736
decred/dcrdata
db/cache/charts.go
Dump
func (charts *ChartData) Dump(dumpPath string) { err := charts.writeCacheFile(dumpPath) if err != nil { log.Errorf("ChartData.writeCacheFile failed: %v", err) } else { log.Debug("Dumping the charts cache data was successful") } }
go
func (charts *ChartData) Dump(dumpPath string) { err := charts.writeCacheFile(dumpPath) if err != nil { log.Errorf("ChartData.writeCacheFile failed: %v", err) } else { log.Debug("Dumping the charts cache data was successful") } }
[ "func", "(", "charts", "*", "ChartData", ")", "Dump", "(", "dumpPath", "string", ")", "{", "err", ":=", "charts", ".", "writeCacheFile", "(", "dumpPath", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "err", "...
// Dump dumps a ChartGobject to a gob file at the given path.
[ "Dump", "dumps", "a", "ChartGobject", "to", "a", "gob", "file", "at", "the", "given", "path", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L583-L590
141,737
decred/dcrdata
db/cache/charts.go
FeesTip
func (charts *ChartData) FeesTip() int32 { charts.mtx.RLock() defer charts.mtx.RUnlock() return int32(len(charts.Blocks.Fees)) - 1 }
go
func (charts *ChartData) FeesTip() int32 { charts.mtx.RLock() defer charts.mtx.RUnlock() return int32(len(charts.Blocks.Fees)) - 1 }
[ "func", "(", "charts", "*", "ChartData", ")", "FeesTip", "(", ")", "int32", "{", "charts", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "charts", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "int32", "(", "len", "(", "charts", ".", ...
// FeesTip is the height of the Fees data.
[ "FeesTip", "is", "the", "height", "of", "the", "Fees", "data", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L649-L653
141,738
decred/dcrdata
db/cache/charts.go
NewAtomsTip
func (charts *ChartData) NewAtomsTip() int32 { charts.mtx.RLock() defer charts.mtx.RUnlock() return int32(len(charts.Blocks.NewAtoms)) - 1 }
go
func (charts *ChartData) NewAtomsTip() int32 { charts.mtx.RLock() defer charts.mtx.RUnlock() return int32(len(charts.Blocks.NewAtoms)) - 1 }
[ "func", "(", "charts", "*", "ChartData", ")", "NewAtomsTip", "(", ")", "int32", "{", "charts", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "charts", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "int32", "(", "len", "(", "charts", "....
// NewAtomsTip is the height of the NewAtoms data.
[ "NewAtomsTip", "is", "the", "height", "of", "the", "NewAtoms", "data", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L656-L660
141,739
decred/dcrdata
db/cache/charts.go
TicketPriceTip
func (charts *ChartData) TicketPriceTip() int32 { charts.mtx.RLock() defer charts.mtx.RUnlock() return int32(len(charts.Windows.TicketPrice))*charts.DiffInterval - 1 }
go
func (charts *ChartData) TicketPriceTip() int32 { charts.mtx.RLock() defer charts.mtx.RUnlock() return int32(len(charts.Windows.TicketPrice))*charts.DiffInterval - 1 }
[ "func", "(", "charts", "*", "ChartData", ")", "TicketPriceTip", "(", ")", "int32", "{", "charts", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "charts", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "int32", "(", "len", "(", "charts", ...
// TicketPriceTip is the height of the TicketPrice data.
[ "TicketPriceTip", "is", "the", "height", "of", "the", "TicketPrice", "data", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L663-L667
141,740
decred/dcrdata
db/cache/charts.go
PoolSizeTip
func (charts *ChartData) PoolSizeTip() int32 { charts.mtx.RLock() defer charts.mtx.RUnlock() return int32(len(charts.Blocks.PoolSize)) - 1 }
go
func (charts *ChartData) PoolSizeTip() int32 { charts.mtx.RLock() defer charts.mtx.RUnlock() return int32(len(charts.Blocks.PoolSize)) - 1 }
[ "func", "(", "charts", "*", "ChartData", ")", "PoolSizeTip", "(", ")", "int32", "{", "charts", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "charts", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "int32", "(", "len", "(", "charts", "....
// PoolSizeTip is the height of the PoolSize data.
[ "PoolSizeTip", "is", "the", "height", "of", "the", "PoolSize", "data", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L670-L674
141,741
decred/dcrdata
db/cache/charts.go
NewChartData
func NewChartData(height uint32, genesis time.Time, chainParams *chaincfg.Params, ctx context.Context) *ChartData { // Start datasets at 25% larger than height. This matches golangs default // capacity size increase for slice lengths > 1024 // https://github.com/golang/go/blob/87e48c5afdcf5e01bb2b7f51b7643e8901f4b7f...
go
func NewChartData(height uint32, genesis time.Time, chainParams *chaincfg.Params, ctx context.Context) *ChartData { // Start datasets at 25% larger than height. This matches golangs default // capacity size increase for slice lengths > 1024 // https://github.com/golang/go/blob/87e48c5afdcf5e01bb2b7f51b7643e8901f4b7f...
[ "func", "NewChartData", "(", "height", "uint32", ",", "genesis", "time", ".", "Time", ",", "chainParams", "*", "chaincfg", ".", "Params", ",", "ctx", "context", ".", "Context", ")", "*", "ChartData", "{", "// Start datasets at 25% larger than height. This matches go...
// NewChartData constructs a new ChartData.
[ "NewChartData", "constructs", "a", "new", "ChartData", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L712-L729
141,742
decred/dcrdata
db/cache/charts.go
getCache
func (charts *ChartData) getCache(chartID string, zoom ZoomLevel) (data *cachedChart, found bool, cacheID uint64) { // Ignore zero length since bestHeight would just be set to zero anyway. ck := cacheKey(chartID, zoom) charts.cacheMtx.RLock() defer charts.cacheMtx.RUnlock() cacheID = charts.cacheID(zoom) data, fo...
go
func (charts *ChartData) getCache(chartID string, zoom ZoomLevel) (data *cachedChart, found bool, cacheID uint64) { // Ignore zero length since bestHeight would just be set to zero anyway. ck := cacheKey(chartID, zoom) charts.cacheMtx.RLock() defer charts.cacheMtx.RUnlock() cacheID = charts.cacheID(zoom) data, fo...
[ "func", "(", "charts", "*", "ChartData", ")", "getCache", "(", "chartID", "string", ",", "zoom", "ZoomLevel", ")", "(", "data", "*", "cachedChart", ",", "found", "bool", ",", "cacheID", "uint64", ")", "{", "// Ignore zero length since bestHeight would just be set ...
// Grab the cached data, if it exists. The cacheID is returned as a convenience.
[ "Grab", "the", "cached", "data", "if", "it", "exists", ".", "The", "cacheID", "is", "returned", "as", "a", "convenience", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L751-L759
141,743
decred/dcrdata
db/cache/charts.go
cacheChart
func (charts *ChartData) cacheChart(chartID string, zoom ZoomLevel, data []byte) { ck := cacheKey(chartID, zoom) charts.cacheMtx.Lock() defer charts.cacheMtx.Unlock() // Using the current best cacheID. This leaves open the small possibility that // the cacheID is wrong, if the cacheID has been updated between the ...
go
func (charts *ChartData) cacheChart(chartID string, zoom ZoomLevel, data []byte) { ck := cacheKey(chartID, zoom) charts.cacheMtx.Lock() defer charts.cacheMtx.Unlock() // Using the current best cacheID. This leaves open the small possibility that // the cacheID is wrong, if the cacheID has been updated between the ...
[ "func", "(", "charts", "*", "ChartData", ")", "cacheChart", "(", "chartID", "string", ",", "zoom", "ZoomLevel", ",", "data", "[", "]", "byte", ")", "{", "ck", ":=", "cacheKey", "(", "chartID", ",", "zoom", ")", "\n", "charts", ".", "cacheMtx", ".", "...
// Store the chart associated with the provided type and ZoomLevel.
[ "Store", "the", "chart", "associated", "with", "the", "provided", "type", "and", "ZoomLevel", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L762-L773
141,744
decred/dcrdata
db/cache/charts.go
Chart
func (charts *ChartData) Chart(chartID, zoomString string) ([]byte, error) { zoom := ParseZoom(zoomString) cache, found, cacheID := charts.getCache(chartID, zoom) if found && cache.cacheID == cacheID { return cache.data, nil } maker, hasMaker := chartMakers[chartID] if !hasMaker { return nil, UnknownChartErr ...
go
func (charts *ChartData) Chart(chartID, zoomString string) ([]byte, error) { zoom := ParseZoom(zoomString) cache, found, cacheID := charts.getCache(chartID, zoom) if found && cache.cacheID == cacheID { return cache.data, nil } maker, hasMaker := chartMakers[chartID] if !hasMaker { return nil, UnknownChartErr ...
[ "func", "(", "charts", "*", "ChartData", ")", "Chart", "(", "chartID", ",", "zoomString", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "zoom", ":=", "ParseZoom", "(", "zoomString", ")", "\n", "cache", ",", "found", ",", "cacheID", ":...
// Chart will return a JSON-encoded chartResponse of the provided type // and ZoomLevel.
[ "Chart", "will", "return", "a", "JSON", "-", "encoded", "chartResponse", "of", "the", "provided", "type", "and", "ZoomLevel", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L796-L816
141,745
decred/dcrdata
db/cache/charts.go
encode
func (charts *ChartData) encode(sets ...lengther) ([]byte, error) { if len(sets) == 0 { return nil, fmt.Errorf("encode called without arguments") } smaller := sets[0].Length() for _, x := range sets { l := x.Length() if l < smaller { smaller = l } } response := make(chartResponse) for i := range sets ...
go
func (charts *ChartData) encode(sets ...lengther) ([]byte, error) { if len(sets) == 0 { return nil, fmt.Errorf("encode called without arguments") } smaller := sets[0].Length() for _, x := range sets { l := x.Length() if l < smaller { smaller = l } } response := make(chartResponse) for i := range sets ...
[ "func", "(", "charts", "*", "ChartData", ")", "encode", "(", "sets", "...", "lengther", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "sets", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\...
// Encode the slices. The set lengths are truncated to the smallest of the // arguments.
[ "Encode", "the", "slices", ".", "The", "set", "lengths", "are", "truncated", "to", "the", "smallest", "of", "the", "arguments", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L823-L846
141,746
decred/dcrdata
db/cache/charts.go
accumulate
func accumulate(data ChartUints) ChartUints { d := make(ChartUints, 0, len(data)) var accumulator uint64 for _, v := range data { accumulator += v d = append(d, accumulator) } return d }
go
func accumulate(data ChartUints) ChartUints { d := make(ChartUints, 0, len(data)) var accumulator uint64 for _, v := range data { accumulator += v d = append(d, accumulator) } return d }
[ "func", "accumulate", "(", "data", "ChartUints", ")", "ChartUints", "{", "d", ":=", "make", "(", "ChartUints", ",", "0", ",", "len", "(", "data", ")", ")", "\n", "var", "accumulator", "uint64", "\n", "for", "_", ",", "v", ":=", "range", "data", "{", ...
// Each point is translated to the sum of all points before and itself.
[ "Each", "point", "is", "translated", "to", "the", "sum", "of", "all", "points", "before", "and", "itself", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L849-L857
141,747
decred/dcrdata
db/cache/charts.go
btw
func btw(data ChartUints) ChartUints { d := make(ChartUints, 0, len(data)) dataLen := len(data) if dataLen == 0 { return d } d = append(d, 0) last := data[0] for _, v := range data[1:] { d = append(d, v-last) last = v } return d }
go
func btw(data ChartUints) ChartUints { d := make(ChartUints, 0, len(data)) dataLen := len(data) if dataLen == 0 { return d } d = append(d, 0) last := data[0] for _, v := range data[1:] { d = append(d, v-last) last = v } return d }
[ "func", "btw", "(", "data", "ChartUints", ")", "ChartUints", "{", "d", ":=", "make", "(", "ChartUints", ",", "0", ",", "len", "(", "data", ")", ")", "\n", "dataLen", ":=", "len", "(", "data", ")", "\n", "if", "dataLen", "==", "0", "{", "return", ...
// Translate the uints to a slice of the differences between each. The provided // data is assumed to be monotonically increasing. The first element is always // 0 to keep the data length unchanged.
[ "Translate", "the", "uints", "to", "a", "slice", "of", "the", "differences", "between", "each", ".", "The", "provided", "data", "is", "assumed", "to", "be", "monotonically", "increasing", ".", "The", "first", "element", "is", "always", "0", "to", "keep", "...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L862-L875
141,748
decred/dcrdata
db/cache/charts.go
hashrate
func hashrate(time, chainwork ChartUints) (ChartUints, ChartUints) { hrLen := len(chainwork) - HashrateAvgLength if hrLen <= 0 { return newChartUints(0), newChartUints(0) } t := make(ChartUints, 0, hrLen) y := make(ChartUints, 0, hrLen) var rotator [HashrateAvgLength]uint64 for i, work := range chainwork { i...
go
func hashrate(time, chainwork ChartUints) (ChartUints, ChartUints) { hrLen := len(chainwork) - HashrateAvgLength if hrLen <= 0 { return newChartUints(0), newChartUints(0) } t := make(ChartUints, 0, hrLen) y := make(ChartUints, 0, hrLen) var rotator [HashrateAvgLength]uint64 for i, work := range chainwork { i...
[ "func", "hashrate", "(", "time", ",", "chainwork", "ChartUints", ")", "(", "ChartUints", ",", "ChartUints", ")", "{", "hrLen", ":=", "len", "(", "chainwork", ")", "-", "HashrateAvgLength", "\n", "if", "hrLen", "<=", "0", "{", "return", "newChartUints", "("...
// hashrate converts the provided chainwork data to hashrate data. Since // hashrates are averaged over HashrateAvgLength blocks, the returned slice // is HashrateAvgLength shorter than the provided chainwork. A time slice is // required as well, and a truncated time slice with the same length as the // hashrate slice ...
[ "hashrate", "converts", "the", "provided", "chainwork", "data", "to", "hashrate", "data", ".", "Since", "hashrates", "are", "averaged", "over", "HashrateAvgLength", "blocks", "the", "returned", "slice", "is", "HashrateAvgLength", "shorter", "than", "the", "provided"...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/charts.go#L932-L953
141,749
decred/dcrdata
db/dcrpg/internal/addrstmts.go
formatGroupingQuery
func formatGroupingQuery(mainQuery, group, column string) string { if group == "all" { return fmt.Sprintf(mainQuery, column) } subQuery := fmt.Sprintf("date_trunc('%s', %s)", group, column) return fmt.Sprintf(mainQuery, subQuery) }
go
func formatGroupingQuery(mainQuery, group, column string) string { if group == "all" { return fmt.Sprintf(mainQuery, column) } subQuery := fmt.Sprintf("date_trunc('%s', %s)", group, column) return fmt.Sprintf(mainQuery, subQuery) }
[ "func", "formatGroupingQuery", "(", "mainQuery", ",", "group", ",", "column", "string", ")", "string", "{", "if", "group", "==", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "mainQuery", ",", "column", ")", "\n", "}", "\n", "subQuery", ":=", ...
// Since date_trunc function doesn't have an option to group by "all" grouping, // formatGroupingQuery removes the date_trunc from the sql query as its not applicable.
[ "Since", "date_trunc", "function", "doesn", "t", "have", "an", "option", "to", "group", "by", "all", "grouping", "formatGroupingQuery", "removes", "the", "date_trunc", "from", "the", "sql", "query", "as", "its", "not", "applicable", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/internal/addrstmts.go#L380-L386
141,750
decred/dcrdata
db/cache/addresscache.go
NewBlockID
func NewBlockID(hash *chainhash.Hash, height int64) *BlockID { return &BlockID{ Hash: *hash, Height: height, } }
go
func NewBlockID(hash *chainhash.Hash, height int64) *BlockID { return &BlockID{ Hash: *hash, Height: height, } }
[ "func", "NewBlockID", "(", "hash", "*", "chainhash", ".", "Hash", ",", "height", "int64", ")", "*", "BlockID", "{", "return", "&", "BlockID", "{", "Hash", ":", "*", "hash", ",", "Height", ":", "height", ",", "}", "\n", "}" ]
// NewBlockID constructs a new BlockID.
[ "NewBlockID", "constructs", "a", "new", "BlockID", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L398-L403
141,751
decred/dcrdata
db/cache/addresscache.go
BlockHash
func (d *AddressCacheItem) BlockHash() chainhash.Hash { d.mtx.RLock() defer d.mtx.RUnlock() return d.hash }
go
func (d *AddressCacheItem) BlockHash() chainhash.Hash { d.mtx.RLock() defer d.mtx.RUnlock() return d.hash }
[ "func", "(", "d", "*", "AddressCacheItem", ")", "BlockHash", "(", ")", "chainhash", ".", "Hash", "{", "d", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "hash", "\n", "}" ]
// BlockHash is a thread-safe accessor for the block hash.
[ "BlockHash", "is", "a", "thread", "-", "safe", "accessor", "for", "the", "block", "hash", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L411-L415
141,752
decred/dcrdata
db/cache/addresscache.go
BlockHeight
func (d *AddressCacheItem) BlockHeight() int64 { d.mtx.RLock() defer d.mtx.RUnlock() return d.height }
go
func (d *AddressCacheItem) BlockHeight() int64 { d.mtx.RLock() defer d.mtx.RUnlock() return d.height }
[ "func", "(", "d", "*", "AddressCacheItem", ")", "BlockHeight", "(", ")", "int64", "{", "d", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "d", ".", "height", "\n", "}" ]
// BlockHeight is a thread-safe accessor for the block height.
[ "BlockHeight", "is", "a", "thread", "-", "safe", "accessor", "for", "the", "block", "height", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L418-L422
141,753
decred/dcrdata
db/cache/addresscache.go
HistoryChart
func (d *AddressCacheItem) HistoryChart(addrChart dbtypes.HistoryChart, chartGrouping dbtypes.TimeBasedGrouping) (*dbtypes.ChartsData, *BlockID) { d.mtx.RLock() defer d.mtx.RUnlock() if int(chartGrouping) >= dbtypes.NumIntervals { log.Errorf("Invalid chart grouping: %v", chartGrouping) return nil, nil } var ...
go
func (d *AddressCacheItem) HistoryChart(addrChart dbtypes.HistoryChart, chartGrouping dbtypes.TimeBasedGrouping) (*dbtypes.ChartsData, *BlockID) { d.mtx.RLock() defer d.mtx.RUnlock() if int(chartGrouping) >= dbtypes.NumIntervals { log.Errorf("Invalid chart grouping: %v", chartGrouping) return nil, nil } var ...
[ "func", "(", "d", "*", "AddressCacheItem", ")", "HistoryChart", "(", "addrChart", "dbtypes", ".", "HistoryChart", ",", "chartGrouping", "dbtypes", ".", "TimeBasedGrouping", ")", "(", "*", "dbtypes", ".", "ChartsData", ",", "*", "BlockID", ")", "{", "d", ".",...
// HistoryChart is a thread-safe accessor for the TxHistory.
[ "HistoryChart", "is", "a", "thread", "-", "safe", "accessor", "for", "the", "TxHistory", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L445-L466
141,754
decred/dcrdata
db/cache/addresscache.go
setBlock
func (d *AddressCacheItem) setBlock(block BlockID) { if block.Hash == d.hash { return } d.hash = block.Hash d.height = block.Height d.utxos = nil d.history.Clear() d.balance = nil d.rows = nil }
go
func (d *AddressCacheItem) setBlock(block BlockID) { if block.Hash == d.hash { return } d.hash = block.Hash d.height = block.Height d.utxos = nil d.history.Clear() d.balance = nil d.rows = nil }
[ "func", "(", "d", "*", "AddressCacheItem", ")", "setBlock", "(", "block", "BlockID", ")", "{", "if", "block", ".", "Hash", "==", "d", ".", "hash", "{", "return", "\n", "}", "\n", "d", ".", "hash", "=", "block", ".", "Hash", "\n", "d", ".", "heigh...
// setBlock ensures that the AddressCacheItem pertains to the given BlockID, // clearing any cached data if the previously set block is not equal to the // given block.
[ "setBlock", "ensures", "that", "the", "AddressCacheItem", "pertains", "to", "the", "given", "BlockID", "clearing", "any", "cached", "data", "if", "the", "previously", "set", "block", "is", "not", "equal", "to", "the", "given", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L551-L561
141,755
decred/dcrdata
db/cache/addresscache.go
SetRows
func (d *AddressCacheItem) SetRows(block BlockID, rows []dbtypes.AddressRowCompact) { d.mtx.Lock() defer d.mtx.Unlock() d.setBlock(block) d.rows = rows }
go
func (d *AddressCacheItem) SetRows(block BlockID, rows []dbtypes.AddressRowCompact) { d.mtx.Lock() defer d.mtx.Unlock() d.setBlock(block) d.rows = rows }
[ "func", "(", "d", "*", "AddressCacheItem", ")", "SetRows", "(", "block", "BlockID", ",", "rows", "[", "]", "dbtypes", ".", "AddressRowCompact", ")", "{", "d", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "mtx", ".", "Unlock", "(", ")...
// SetRows updates the cache item for the given non-merged AddressRow slice // valid at the given BlockID.
[ "SetRows", "updates", "the", "cache", "item", "for", "the", "given", "non", "-", "merged", "AddressRow", "slice", "valid", "at", "the", "given", "BlockID", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L565-L570
141,756
decred/dcrdata
db/cache/addresscache.go
SetUTXOs
func (d *AddressCacheItem) SetUTXOs(block BlockID, utxos []apitypes.AddressTxnOutput) { d.mtx.Lock() defer d.mtx.Unlock() d.setBlock(block) d.utxos = utxos }
go
func (d *AddressCacheItem) SetUTXOs(block BlockID, utxos []apitypes.AddressTxnOutput) { d.mtx.Lock() defer d.mtx.Unlock() d.setBlock(block) d.utxos = utxos }
[ "func", "(", "d", "*", "AddressCacheItem", ")", "SetUTXOs", "(", "block", "BlockID", ",", "utxos", "[", "]", "apitypes", ".", "AddressTxnOutput", ")", "{", "d", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "mtx", ".", "Unlock", "(", ...
// SetUTXOs updates the cache item for the given AddressTxnOutput slice valid at // the given BlockID.
[ "SetUTXOs", "updates", "the", "cache", "item", "for", "the", "given", "AddressTxnOutput", "slice", "valid", "at", "the", "given", "BlockID", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L574-L579
141,757
decred/dcrdata
db/cache/addresscache.go
SetBalance
func (d *AddressCacheItem) SetBalance(block BlockID, balance *dbtypes.AddressBalance) { d.mtx.Lock() defer d.mtx.Unlock() d.setBlock(block) d.balance = balance }
go
func (d *AddressCacheItem) SetBalance(block BlockID, balance *dbtypes.AddressBalance) { d.mtx.Lock() defer d.mtx.Unlock() d.setBlock(block) d.balance = balance }
[ "func", "(", "d", "*", "AddressCacheItem", ")", "SetBalance", "(", "block", "BlockID", ",", "balance", "*", "dbtypes", ".", "AddressBalance", ")", "{", "d", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "mtx", ".", "Unlock", "(", ")", ...
// SetBalance updates the cache item for the given AddressBalance valid at the // given BlockID.
[ "SetBalance", "updates", "the", "cache", "item", "for", "the", "given", "AddressBalance", "valid", "at", "the", "given", "BlockID", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L583-L588
141,758
decred/dcrdata
db/cache/addresscache.go
NewAddressCache
func NewAddressCache(rowCapacity int) *AddressCache { if rowCapacity < 0 { rowCapacity = 0 } ac := &AddressCache{ a: make(map[string]*AddressCacheItem), cap: rowCapacity, capAddr: addressCapacity, } defer func() { go ac.Reporter() }() return ac }
go
func NewAddressCache(rowCapacity int) *AddressCache { if rowCapacity < 0 { rowCapacity = 0 } ac := &AddressCache{ a: make(map[string]*AddressCacheItem), cap: rowCapacity, capAddr: addressCapacity, } defer func() { go ac.Reporter() }() return ac }
[ "func", "NewAddressCache", "(", "rowCapacity", "int", ")", "*", "AddressCache", "{", "if", "rowCapacity", "<", "0", "{", "rowCapacity", "=", "0", "\n", "}", "\n", "ac", ":=", "&", "AddressCache", "{", "a", ":", "make", "(", "map", "[", "string", "]", ...
// NewAddressCache constructs an AddressCache with capacity for the specified // number of address rows.
[ "NewAddressCache", "constructs", "an", "AddressCache", "with", "capacity", "for", "the", "specified", "number", "of", "address", "rows", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L693-L704
141,759
decred/dcrdata
db/cache/addresscache.go
Reporter
func (ac *AddressCache) Reporter() { var lastBH, lastBM, lastRH, lastRM, lastUH, lastUM, lastHH, lastHM int ticker := time.NewTicker(4 * time.Second) for range ticker.C { balHits, balMisses := ac.BalanceStats() rowHits, rowMisses := ac.RowStats() utxoHits, utxoMisses := ac.UtxoStats() histHits, histMisses :=...
go
func (ac *AddressCache) Reporter() { var lastBH, lastBM, lastRH, lastRM, lastUH, lastUM, lastHH, lastHM int ticker := time.NewTicker(4 * time.Second) for range ticker.C { balHits, balMisses := ac.BalanceStats() rowHits, rowMisses := ac.RowStats() utxoHits, utxoMisses := ac.UtxoStats() histHits, histMisses :=...
[ "func", "(", "ac", "*", "AddressCache", ")", "Reporter", "(", ")", "{", "var", "lastBH", ",", "lastBM", ",", "lastRH", ",", "lastRM", ",", "lastUH", ",", "lastUM", ",", "lastHH", ",", "lastHM", "int", "\n", "ticker", ":=", "time", ".", "NewTicker", "...
// Reporter prints the number of cached addresses, rows, and utxos, as well as a // table of cache hits and misses.
[ "Reporter", "prints", "the", "number", "of", "cached", "addresses", "rows", "and", "utxos", "as", "well", "as", "a", "table", "of", "cache", "hits", "and", "misses", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L728-L758
141,760
decred/dcrdata
db/cache/addresscache.go
addressCacheItem
func (ac *AddressCache) addressCacheItem(addr string) *AddressCacheItem { ac.mtx.RLock() defer ac.mtx.RUnlock() return ac.a[addr] }
go
func (ac *AddressCache) addressCacheItem(addr string) *AddressCacheItem { ac.mtx.RLock() defer ac.mtx.RUnlock() return ac.a[addr] }
[ "func", "(", "ac", "*", "AddressCache", ")", "addressCacheItem", "(", "addr", "string", ")", "*", "AddressCacheItem", "{", "ac", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "ac", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "ac", ".",...
// addressCacheItem safely accesses any AddressCacheItem for the given address.
[ "addressCacheItem", "safely", "accesses", "any", "AddressCacheItem", "for", "the", "given", "address", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L761-L765
141,761
decred/dcrdata
db/cache/addresscache.go
ClearAll
func (ac *AddressCache) ClearAll() (numCleared int) { ac.mtx.Lock() defer ac.mtx.Unlock() numCleared = len(ac.a) ac.a = make(map[string]*AddressCacheItem) return }
go
func (ac *AddressCache) ClearAll() (numCleared int) { ac.mtx.Lock() defer ac.mtx.Unlock() numCleared = len(ac.a) ac.a = make(map[string]*AddressCacheItem) return }
[ "func", "(", "ac", "*", "AddressCache", ")", "ClearAll", "(", ")", "(", "numCleared", "int", ")", "{", "ac", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ac", ".", "mtx", ".", "Unlock", "(", ")", "\n", "numCleared", "=", "len", "(", "ac", ...
// ClearAll resets AddressCache, purging all cached data.
[ "ClearAll", "resets", "AddressCache", "purging", "all", "cached", "data", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L768-L774
141,762
decred/dcrdata
db/cache/addresscache.go
Clear
func (ac *AddressCache) Clear(addrs []string) (numCleared int) { if addrs == nil { return ac.ClearAll() } if len(addrs) == 0 { return } ac.mtx.Lock() defer ac.mtx.Unlock() for i := range addrs { delete(ac.a, addrs[i]) numCleared++ } return }
go
func (ac *AddressCache) Clear(addrs []string) (numCleared int) { if addrs == nil { return ac.ClearAll() } if len(addrs) == 0 { return } ac.mtx.Lock() defer ac.mtx.Unlock() for i := range addrs { delete(ac.a, addrs[i]) numCleared++ } return }
[ "func", "(", "ac", "*", "AddressCache", ")", "Clear", "(", "addrs", "[", "]", "string", ")", "(", "numCleared", "int", ")", "{", "if", "addrs", "==", "nil", "{", "return", "ac", ".", "ClearAll", "(", ")", "\n", "}", "\n", "if", "len", "(", "addrs...
// Clear purging cached data for the given addresses. If addrs is nil, all data // are cleared. If addresses is non-nil empty slice, no data are cleard.
[ "Clear", "purging", "cached", "data", "for", "the", "given", "addresses", ".", "If", "addrs", "is", "nil", "all", "data", "are", "cleared", ".", "If", "addresses", "is", "non", "-", "nil", "empty", "slice", "no", "data", "are", "cleard", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L778-L792
141,763
decred/dcrdata
db/cache/addresscache.go
Balance
func (ac *AddressCache) Balance(addr string) (*dbtypes.AddressBalance, *BlockID) { aci := ac.addressCacheItem(addr) if aci == nil { ac.cacheMetrics.BalanceMiss() return nil, nil } ac.cacheMetrics.BalanceHit() return aci.Balance() }
go
func (ac *AddressCache) Balance(addr string) (*dbtypes.AddressBalance, *BlockID) { aci := ac.addressCacheItem(addr) if aci == nil { ac.cacheMetrics.BalanceMiss() return nil, nil } ac.cacheMetrics.BalanceHit() return aci.Balance() }
[ "func", "(", "ac", "*", "AddressCache", ")", "Balance", "(", "addr", "string", ")", "(", "*", "dbtypes", ".", "AddressBalance", ",", "*", "BlockID", ")", "{", "aci", ":=", "ac", ".", "addressCacheItem", "(", "addr", ")", "\n", "if", "aci", "==", "nil...
// Balance attempts to retrieve an AddressBalance for the given address. The // BlockID for the block at which the cached data is valid is also returned. In // the event of a cache miss, both returned pointers will be nil.
[ "Balance", "attempts", "to", "retrieve", "an", "AddressBalance", "for", "the", "given", "address", ".", "The", "BlockID", "for", "the", "block", "at", "which", "the", "cached", "data", "is", "valid", "is", "also", "returned", ".", "In", "the", "event", "of...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L797-L805
141,764
decred/dcrdata
db/cache/addresscache.go
HistoryChart
func (ac *AddressCache) HistoryChart(addr string, addrChart dbtypes.HistoryChart, chartGrouping dbtypes.TimeBasedGrouping) (*dbtypes.ChartsData, *BlockID) { aci := ac.addressCacheItem(addr) if aci == nil { ac.cacheMetrics.HistoryMiss() return nil, nil } cd, blockID := aci.HistoryChart(addrChart, chartGrouping...
go
func (ac *AddressCache) HistoryChart(addr string, addrChart dbtypes.HistoryChart, chartGrouping dbtypes.TimeBasedGrouping) (*dbtypes.ChartsData, *BlockID) { aci := ac.addressCacheItem(addr) if aci == nil { ac.cacheMetrics.HistoryMiss() return nil, nil } cd, blockID := aci.HistoryChart(addrChart, chartGrouping...
[ "func", "(", "ac", "*", "AddressCache", ")", "HistoryChart", "(", "addr", "string", ",", "addrChart", "dbtypes", ".", "HistoryChart", ",", "chartGrouping", "dbtypes", ".", "TimeBasedGrouping", ")", "(", "*", "dbtypes", ".", "ChartsData", ",", "*", "BlockID", ...
// HistoryChart attempts to retrieve ChartsData for the given address, chart // type, and grouping inverval. The BlockID for the block at which the cached // data is valid is also returned. In the event of a cache miss, both returned // pointers will be nil.
[ "HistoryChart", "attempts", "to", "retrieve", "ChartsData", "for", "the", "given", "address", "chart", "type", "and", "grouping", "inverval", ".", "The", "BlockID", "for", "the", "block", "at", "which", "the", "cached", "data", "is", "valid", "is", "also", "...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L824-L840
141,765
decred/dcrdata
db/cache/addresscache.go
Length
func (ac *AddressCache) Length() (numAddrs, numTxns, numUTXOs int) { ac.mtx.RLock() defer ac.mtx.RUnlock() return ac.length() }
go
func (ac *AddressCache) Length() (numAddrs, numTxns, numUTXOs int) { ac.mtx.RLock() defer ac.mtx.RUnlock() return ac.length() }
[ "func", "(", "ac", "*", "AddressCache", ")", "Length", "(", ")", "(", "numAddrs", ",", "numTxns", ",", "numUTXOs", "int", ")", "{", "ac", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "ac", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return...
// Length returns the total number of address rows and UTXOs stored in cache.
[ "Length", "returns", "the", "total", "number", "of", "address", "rows", "and", "UTXOs", "stored", "in", "cache", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L948-L952
141,766
decred/dcrdata
db/cache/addresscache.go
NumAddresses
func (ac *AddressCache) NumAddresses() int { ac.mtx.RLock() defer ac.mtx.RUnlock() return len(ac.a) }
go
func (ac *AddressCache) NumAddresses() int { ac.mtx.RLock() defer ac.mtx.RUnlock() return len(ac.a) }
[ "func", "(", "ac", "*", "AddressCache", ")", "NumAddresses", "(", ")", "int", "{", "ac", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "ac", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "len", "(", "ac", ".", "a", ")", "\n", "}" ]
// NumAddresses returns the total number of addresses in the cache.
[ "NumAddresses", "returns", "the", "total", "number", "of", "addresses", "in", "the", "cache", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L955-L959
141,767
decred/dcrdata
db/cache/addresscache.go
StoreRows
func (ac *AddressCache) StoreRows(addr string, rows []*dbtypes.AddressRow, block *BlockID) bool { if block == nil || ac.cap < 1 || ac.capAddr < 1 { return false } rowsCompact := []dbtypes.AddressRowCompact{} if rows != nil { rowsCompact = dbtypes.CompactRows(rows) } // respect cache capacity return ac.Stor...
go
func (ac *AddressCache) StoreRows(addr string, rows []*dbtypes.AddressRow, block *BlockID) bool { if block == nil || ac.cap < 1 || ac.capAddr < 1 { return false } rowsCompact := []dbtypes.AddressRowCompact{} if rows != nil { rowsCompact = dbtypes.CompactRows(rows) } // respect cache capacity return ac.Stor...
[ "func", "(", "ac", "*", "AddressCache", ")", "StoreRows", "(", "addr", "string", ",", "rows", "[", "]", "*", "dbtypes", ".", "AddressRow", ",", "block", "*", "BlockID", ")", "bool", "{", "if", "block", "==", "nil", "||", "ac", ".", "cap", "<", "1",...
// StoreRows stores the non-merged AddressRow slice for the given address in // cache. The current best block data is required to determine cache freshness.
[ "StoreRows", "stores", "the", "non", "-", "merged", "AddressRow", "slice", "for", "the", "given", "address", "in", "cache", ".", "The", "current", "best", "block", "data", "is", "required", "to", "determine", "cache", "freshness", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L1071-L1083
141,768
decred/dcrdata
db/cache/addresscache.go
StoreHistoryChart
func (ac *AddressCache) StoreHistoryChart(addr string, addrChart dbtypes.HistoryChart, chartGrouping dbtypes.TimeBasedGrouping, cd *dbtypes.ChartsData, block *BlockID) bool { if block == nil || ac.cap < 1 || ac.capAddr < 1 { return false } if int(chartGrouping) >= dbtypes.NumIntervals { log.Errorf("Invalid cha...
go
func (ac *AddressCache) StoreHistoryChart(addr string, addrChart dbtypes.HistoryChart, chartGrouping dbtypes.TimeBasedGrouping, cd *dbtypes.ChartsData, block *BlockID) bool { if block == nil || ac.cap < 1 || ac.capAddr < 1 { return false } if int(chartGrouping) >= dbtypes.NumIntervals { log.Errorf("Invalid cha...
[ "func", "(", "ac", "*", "AddressCache", ")", "StoreHistoryChart", "(", "addr", "string", ",", "addrChart", "dbtypes", ".", "HistoryChart", ",", "chartGrouping", "dbtypes", ".", "TimeBasedGrouping", ",", "cd", "*", "dbtypes", ".", "ChartsData", ",", "block", "*...
// StoreHistoryChart stores the charts data for the given address in cache. The // current best block data is required to determine cache freshness.
[ "StoreHistoryChart", "stores", "the", "charts", "data", "for", "the", "given", "address", "in", "cache", ".", "The", "current", "best", "block", "data", "is", "required", "to", "determine", "cache", "freshness", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L1087-L1130
141,769
decred/dcrdata
db/cache/addresscache.go
StoreRowsCompact
func (ac *AddressCache) StoreRowsCompact(addr string, rows []dbtypes.AddressRowCompact, block *BlockID) bool { if block == nil || ac.cap < 1 || ac.capAddr < 1 { return false } ac.mtx.Lock() defer ac.mtx.Unlock() if rows == nil { rows = []dbtypes.AddressRowCompact{} } // respect cache capacity return ac.s...
go
func (ac *AddressCache) StoreRowsCompact(addr string, rows []dbtypes.AddressRowCompact, block *BlockID) bool { if block == nil || ac.cap < 1 || ac.capAddr < 1 { return false } ac.mtx.Lock() defer ac.mtx.Unlock() if rows == nil { rows = []dbtypes.AddressRowCompact{} } // respect cache capacity return ac.s...
[ "func", "(", "ac", "*", "AddressCache", ")", "StoreRowsCompact", "(", "addr", "string", ",", "rows", "[", "]", "dbtypes", ".", "AddressRowCompact", ",", "block", "*", "BlockID", ")", "bool", "{", "if", "block", "==", "nil", "||", "ac", ".", "cap", "<",...
// StoreRowsCompact stores the non-merged AddressRow slice for the given address // in cache. The current best block data is required to determine cache // freshness.
[ "StoreRowsCompact", "stores", "the", "non", "-", "merged", "AddressRow", "slice", "for", "the", "given", "address", "in", "cache", ".", "The", "current", "best", "block", "data", "is", "required", "to", "determine", "cache", "freshness", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L1135-L1149
141,770
decred/dcrdata
db/cache/addresscache.go
StoreBalance
func (ac *AddressCache) StoreBalance(addr string, balance *dbtypes.AddressBalance, block *BlockID) bool { if ac.cap < 1 || ac.capAddr < 1 { return false } ac.mtx.Lock() defer ac.mtx.Unlock() aci := ac.a[addr] if block != nil && balance == nil { balance = &dbtypes.AddressBalance{ Address: addr, } } i...
go
func (ac *AddressCache) StoreBalance(addr string, balance *dbtypes.AddressBalance, block *BlockID) bool { if ac.cap < 1 || ac.capAddr < 1 { return false } ac.mtx.Lock() defer ac.mtx.Unlock() aci := ac.a[addr] if block != nil && balance == nil { balance = &dbtypes.AddressBalance{ Address: addr, } } i...
[ "func", "(", "ac", "*", "AddressCache", ")", "StoreBalance", "(", "addr", "string", ",", "balance", "*", "dbtypes", ".", "AddressBalance", ",", "block", "*", "BlockID", ")", "bool", "{", "if", "ac", ".", "cap", "<", "1", "||", "ac", ".", "capAddr", "...
// StoreBalance stores the AddressBalance for the given address in cache. The // current best block data is required to determine cache freshness.
[ "StoreBalance", "stores", "the", "AddressBalance", "for", "the", "given", "address", "in", "cache", ".", "The", "current", "best", "block", "data", "is", "required", "to", "determine", "cache", "freshness", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L1153-L1181
141,771
decred/dcrdata
db/cache/addresscache.go
StoreUTXOs
func (ac *AddressCache) StoreUTXOs(addr string, utxos []apitypes.AddressTxnOutput, block *BlockID) bool { if ac.cap < 1 || ac.capAddr < 1 { return false } // Only allow storing maxUTXOsPerAddr. if len(utxos) > maxUTXOsPerAddr && addr != ac.ProjectAddress { return false } ac.mtx.Lock() defer ac.mtx.Unlock()...
go
func (ac *AddressCache) StoreUTXOs(addr string, utxos []apitypes.AddressTxnOutput, block *BlockID) bool { if ac.cap < 1 || ac.capAddr < 1 { return false } // Only allow storing maxUTXOsPerAddr. if len(utxos) > maxUTXOsPerAddr && addr != ac.ProjectAddress { return false } ac.mtx.Lock() defer ac.mtx.Unlock()...
[ "func", "(", "ac", "*", "AddressCache", ")", "StoreUTXOs", "(", "addr", "string", ",", "utxos", "[", "]", "apitypes", ".", "AddressTxnOutput", ",", "block", "*", "BlockID", ")", "bool", "{", "if", "ac", ".", "cap", "<", "1", "||", "ac", ".", "capAddr...
// StoreUTXOs stores the AddressTxnOutput slice for the given address in cache. // The current best block data is required to determine cache freshness.
[ "StoreUTXOs", "stores", "the", "AddressTxnOutput", "slice", "for", "the", "given", "address", "in", "cache", ".", "The", "current", "best", "block", "data", "is", "required", "to", "determine", "cache", "freshness", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/cache/addresscache.go#L1185-L1216
141,772
decred/dcrdata
api/insight/converter.go
TxConverter
func (iapi *InsightApi) TxConverter(txs []*dcrjson.TxRawResult) ([]apitypes.InsightTx, error) { return iapi.DcrToInsightTxns(txs, false, false, false) }
go
func (iapi *InsightApi) TxConverter(txs []*dcrjson.TxRawResult) ([]apitypes.InsightTx, error) { return iapi.DcrToInsightTxns(txs, false, false, false) }
[ "func", "(", "iapi", "*", "InsightApi", ")", "TxConverter", "(", "txs", "[", "]", "*", "dcrjson", ".", "TxRawResult", ")", "(", "[", "]", "apitypes", ".", "InsightTx", ",", "error", ")", "{", "return", "iapi", ".", "DcrToInsightTxns", "(", "txs", ",", ...
// TxConverter converts dcrd-tx to insight tx
[ "TxConverter", "converts", "dcrd", "-", "tx", "to", "insight", "tx" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/converter.go#L15-L17
141,773
decred/dcrdata
api/insight/converter.go
DcrToInsightBlock
func (iapi *InsightApi) DcrToInsightBlock(inBlocks []*dcrjson.GetBlockVerboseResult) ([]*apitypes.InsightBlockResult, error) { RewardAtBlock := func(blocknum int64, voters uint16) float64 { subsidyCache := blockchain.NewSubsidyCache(0, iapi.params) work := blockchain.CalcBlockWorkSubsidy(subsidyCache, blocknum, vo...
go
func (iapi *InsightApi) DcrToInsightBlock(inBlocks []*dcrjson.GetBlockVerboseResult) ([]*apitypes.InsightBlockResult, error) { RewardAtBlock := func(blocknum int64, voters uint16) float64 { subsidyCache := blockchain.NewSubsidyCache(0, iapi.params) work := blockchain.CalcBlockWorkSubsidy(subsidyCache, blocknum, vo...
[ "func", "(", "iapi", "*", "InsightApi", ")", "DcrToInsightBlock", "(", "inBlocks", "[", "]", "*", "dcrjson", ".", "GetBlockVerboseResult", ")", "(", "[", "]", "*", "apitypes", ".", "InsightBlockResult", ",", "error", ")", "{", "RewardAtBlock", ":=", "func", ...
// DcrToInsightBlock converts a dcrjson.GetBlockVerboseResult to Insight block.
[ "DcrToInsightBlock", "converts", "a", "dcrjson", ".", "GetBlockVerboseResult", "to", "Insight", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/converter.go#L143-L174
141,774
decred/dcrdata
notification/ntfnchans.go
MakeNtfnChans
func MakeNtfnChans() { // If we're monitoring for blocks OR collecting block data, these channels // are necessary to handle new block notifications. Otherwise, leave them // as nil so that both a send (below) blocks and a receive (in // blockConnectedHandler) block. default case makes non-blocking below. // quit ...
go
func MakeNtfnChans() { // If we're monitoring for blocks OR collecting block data, these channels // are necessary to handle new block notifications. Otherwise, leave them // as nil so that both a send (below) blocks and a receive (in // blockConnectedHandler) block. default case makes non-blocking below. // quit ...
[ "func", "MakeNtfnChans", "(", ")", "{", "// If we're monitoring for blocks OR collecting block data, these channels", "// are necessary to handle new block notifications. Otherwise, leave them", "// as nil so that both a send (below) blocks and a receive (in", "// blockConnectedHandler) block. defau...
// MakeNtfnChans create notification channels based on config
[ "MakeNtfnChans", "create", "notification", "channels", "based", "on", "config" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/notification/ntfnchans.go#L52-L91
141,775
decred/dcrdata
notification/ntfnchans.go
CloseNtfnChans
func CloseNtfnChans() { if NtfnChans.ConnectChan != nil { close(NtfnChans.ConnectChan) } if NtfnChans.ConnectChanWiredDB != nil { close(NtfnChans.ConnectChanWiredDB) } if NtfnChans.ConnectChanStakeDB != nil { close(NtfnChans.ConnectChanStakeDB) } if NtfnChans.ConnectChanDcrpgDB != nil { close(NtfnChans.C...
go
func CloseNtfnChans() { if NtfnChans.ConnectChan != nil { close(NtfnChans.ConnectChan) } if NtfnChans.ConnectChanWiredDB != nil { close(NtfnChans.ConnectChanWiredDB) } if NtfnChans.ConnectChanStakeDB != nil { close(NtfnChans.ConnectChanStakeDB) } if NtfnChans.ConnectChanDcrpgDB != nil { close(NtfnChans.C...
[ "func", "CloseNtfnChans", "(", ")", "{", "if", "NtfnChans", ".", "ConnectChan", "!=", "nil", "{", "close", "(", "NtfnChans", ".", "ConnectChan", ")", "\n", "}", "\n", "if", "NtfnChans", ".", "ConnectChanWiredDB", "!=", "nil", "{", "close", "(", "NtfnChans"...
// CloseNtfnChans close all notification channels
[ "CloseNtfnChans", "close", "all", "notification", "channels" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/notification/ntfnchans.go#L94-L149
141,776
decred/dcrdata
db/dcrpg/upgrades_legacy.go
String
func (v CompatibilityAction) String() string { actions := map[CompatibilityAction]string{ compatRebuild: "rebuild", compatUpgrade: "upgrade", compatReindex: "reindex", compatOK: "ok", } if actionStr, ok := actions[v]; ok { return actionStr } return "unknown" }
go
func (v CompatibilityAction) String() string { actions := map[CompatibilityAction]string{ compatRebuild: "rebuild", compatUpgrade: "upgrade", compatReindex: "reindex", compatOK: "ok", } if actionStr, ok := actions[v]; ok { return actionStr } return "unknown" }
[ "func", "(", "v", "CompatibilityAction", ")", "String", "(", ")", "string", "{", "actions", ":=", "map", "[", "CompatibilityAction", "]", "string", "{", "compatRebuild", ":", "\"", "\"", ",", "compatUpgrade", ":", "\"", "\"", ",", "compatReindex", ":", "\"...
// String implements Stringer for CompatibilityAction.
[ "String", "implements", "Stringer", "for", "CompatibilityAction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L93-L104
141,777
decred/dcrdata
db/dcrpg/upgrades_legacy.go
NewTableVersion
func NewTableVersion(major, minor, patch uint32) TableVersion { return TableVersion{major, minor, patch} }
go
func NewTableVersion(major, minor, patch uint32) TableVersion { return TableVersion{major, minor, patch} }
[ "func", "NewTableVersion", "(", "major", ",", "minor", ",", "patch", "uint32", ")", "TableVersion", "{", "return", "TableVersion", "{", "major", ",", "minor", ",", "patch", "}", "\n", "}" ]
// NewTableVersion returns a new TableVersion with the version major.minor.patch
[ "NewTableVersion", "returns", "a", "new", "TableVersion", "with", "the", "version", "major", ".", "minor", ".", "patch" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L107-L109
141,778
decred/dcrdata
db/dcrpg/upgrades_legacy.go
CreateTablesLegacy
func CreateTablesLegacy(db *sql.DB) error { var err error for tableName, createCommand := range createLegacyTableStatements { var exists bool exists, err = TableExists(db, tableName) if err != nil { return err } tableVersion, ok := requiredVersions[tableName] if !ok { return fmt.Errorf("no version ...
go
func CreateTablesLegacy(db *sql.DB) error { var err error for tableName, createCommand := range createLegacyTableStatements { var exists bool exists, err = TableExists(db, tableName) if err != nil { return err } tableVersion, ok := requiredVersions[tableName] if !ok { return fmt.Errorf("no version ...
[ "func", "CreateTablesLegacy", "(", "db", "*", "sql", ".", "DB", ")", "error", "{", "var", "err", "error", "\n", "for", "tableName", ",", "createCommand", ":=", "range", "createLegacyTableStatements", "{", "var", "exists", "bool", "\n", "exists", ",", "err", ...
// CreateTablesLegacy creates all tables required by dcrdata if they do not // already exist.
[ "CreateTablesLegacy", "creates", "all", "tables", "required", "by", "dcrdata", "if", "they", "do", "not", "already", "exist", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L142-L173
141,779
decred/dcrdata
db/dcrpg/upgrades_legacy.go
TableUpgradesRequired
func TableUpgradesRequired(versions map[string]TableVersion) []TableUpgrade { var tableUpgrades []TableUpgrade for t := range createLegacyTableStatements { var ok bool var req, act TableVersion if req, ok = requiredVersions[t]; !ok { log.Errorf("required version unknown for table %s", t) tableUpgrades = a...
go
func TableUpgradesRequired(versions map[string]TableVersion) []TableUpgrade { var tableUpgrades []TableUpgrade for t := range createLegacyTableStatements { var ok bool var req, act TableVersion if req, ok = requiredVersions[t]; !ok { log.Errorf("required version unknown for table %s", t) tableUpgrades = a...
[ "func", "TableUpgradesRequired", "(", "versions", "map", "[", "string", "]", "TableVersion", ")", "[", "]", "TableUpgrade", "{", "var", "tableUpgrades", "[", "]", "TableUpgrade", "\n", "for", "t", ":=", "range", "createLegacyTableStatements", "{", "var", "ok", ...
// TableUpgradesRequired builds a list of table upgrade information for each // of the supported auxiliary db tables. The upgrade information includes the // table name, its current & required table versions and the action to be taken // after comparing the current & required versions.
[ "TableUpgradesRequired", "builds", "a", "list", "of", "table", "upgrade", "information", "for", "each", "of", "the", "supported", "auxiliary", "db", "tables", ".", "The", "upgrade", "information", "includes", "the", "table", "name", "its", "current", "&", "requi...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L215-L246
141,780
decred/dcrdata
db/dcrpg/upgrades_legacy.go
TableVersions
func TableVersions(db *sql.DB) map[string]TableVersion { versions := map[string]TableVersion{} for tableName := range createLegacyTableStatements { // Retrieve the table description. var desc string err := db.QueryRow(`select obj_description($1::regclass);`, tableName).Scan(&desc) if err != nil { log.Error...
go
func TableVersions(db *sql.DB) map[string]TableVersion { versions := map[string]TableVersion{} for tableName := range createLegacyTableStatements { // Retrieve the table description. var desc string err := db.QueryRow(`select obj_description($1::regclass);`, tableName).Scan(&desc) if err != nil { log.Error...
[ "func", "TableVersions", "(", "db", "*", "sql", ".", "DB", ")", "map", "[", "string", "]", "TableVersion", "{", "versions", ":=", "map", "[", "string", "]", "TableVersion", "{", "}", "\n", "for", "tableName", ":=", "range", "createLegacyTableStatements", "...
// TableVersions retrieve and maps the tables names in the auxiliary db to their // current table versions.
[ "TableVersions", "retrieve", "and", "maps", "the", "tables", "names", "in", "the", "auxiliary", "db", "to", "their", "current", "table", "versions", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L250-L272
141,781
decred/dcrdata
db/dcrpg/upgrades_legacy.go
VersionCheck
func (pgb *ChainDB) VersionCheck(client BlockGetter) error { vers := TableVersions(pgb.db) for tab, ver := range vers { log.Debugf("Table %s: v%s", tab, ver) } var needsUpgrade []TableUpgrade tableUpgrades := TableUpgradesRequired(vers) for _, val := range tableUpgrades { switch val.UpgradeType { case com...
go
func (pgb *ChainDB) VersionCheck(client BlockGetter) error { vers := TableVersions(pgb.db) for tab, ver := range vers { log.Debugf("Table %s: v%s", tab, ver) } var needsUpgrade []TableUpgrade tableUpgrades := TableUpgradesRequired(vers) for _, val := range tableUpgrades { switch val.UpgradeType { case com...
[ "func", "(", "pgb", "*", "ChainDB", ")", "VersionCheck", "(", "client", "BlockGetter", ")", "error", "{", "vers", ":=", "TableVersions", "(", "pgb", ".", "db", ")", "\n", "for", "tab", ",", "ver", ":=", "range", "vers", "{", "log", ".", "Debugf", "("...
// VersionCheck checks the current version of all known tables and notifies when // an upgrade is required. If there is no automatic upgrade supported, an error // is returned when any table is not of the correct version. An RPC client is // passed to implement the supported upgrades if need be.
[ "VersionCheck", "checks", "the", "current", "version", "of", "all", "known", "tables", "and", "notifies", "when", "an", "upgrade", "is", "required", ".", "If", "there", "is", "no", "automatic", "upgrade", "supported", "an", "error", "is", "returned", "when", ...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L328-L364
141,782
decred/dcrdata
db/dcrpg/upgrades_legacy.go
initiatePgUpgrade
func (pgb *ChainDB) initiatePgUpgrade(client BlockGetter, theseUpgrades []TableUpgradeType) (bool, error) { for it := range theseUpgrades { upgradeSuccess, err := pgb.handleUpgrades(client, theseUpgrades[it].upgradeType) if err != nil || !upgradeSuccess { return false, fmt.Errorf("failed to upgrade %s table to ...
go
func (pgb *ChainDB) initiatePgUpgrade(client BlockGetter, theseUpgrades []TableUpgradeType) (bool, error) { for it := range theseUpgrades { upgradeSuccess, err := pgb.handleUpgrades(client, theseUpgrades[it].upgradeType) if err != nil || !upgradeSuccess { return false, fmt.Errorf("failed to upgrade %s table to ...
[ "func", "(", "pgb", "*", "ChainDB", ")", "initiatePgUpgrade", "(", "client", "BlockGetter", ",", "theseUpgrades", "[", "]", "TableUpgradeType", ")", "(", "bool", ",", "error", ")", "{", "for", "it", ":=", "range", "theseUpgrades", "{", "upgradeSuccess", ",",...
// initiatePgUpgrade starts the specific auxiliary database.
[ "initiatePgUpgrade", "starts", "the", "specific", "auxiliary", "database", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L724-L738
141,783
decred/dcrdata
db/dcrpg/upgrades_legacy.go
dropBlockTimeIndexes
func (pgb *ChainDB) dropBlockTimeIndexes() { log.Info("Dropping block time indexes") err := DeindexBlockTimeOnTableAddress(pgb.db) if err != nil { log.Warnf("DeindexBlockTimeOnTableAddress failed: error: %v", err) } }
go
func (pgb *ChainDB) dropBlockTimeIndexes() { log.Info("Dropping block time indexes") err := DeindexBlockTimeOnTableAddress(pgb.db) if err != nil { log.Warnf("DeindexBlockTimeOnTableAddress failed: error: %v", err) } }
[ "func", "(", "pgb", "*", "ChainDB", ")", "dropBlockTimeIndexes", "(", ")", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "err", ":=", "DeindexBlockTimeOnTableAddress", "(", "pgb", ".", "db", ")", "\n", "if", "err", "!=", "nil", "{", "log", "."...
// dropBlockTimeIndexes drops all indexes that are likely to slow down the db // upgrade.
[ "dropBlockTimeIndexes", "drops", "all", "indexes", "that", "are", "likely", "to", "slow", "down", "the", "db", "upgrade", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1097-L1103
141,784
decred/dcrdata
db/dcrpg/upgrades_legacy.go
createBlockTimeIndexes
func (pgb *ChainDB) createBlockTimeIndexes() { log.Info("Creating the dropped block time indexes") err := IndexBlockTimeOnTableAddress(pgb.db) if err != nil { log.Warnf("IndexBlockTimeOnTableAddress failed: error: %v", err) } }
go
func (pgb *ChainDB) createBlockTimeIndexes() { log.Info("Creating the dropped block time indexes") err := IndexBlockTimeOnTableAddress(pgb.db) if err != nil { log.Warnf("IndexBlockTimeOnTableAddress failed: error: %v", err) } }
[ "func", "(", "pgb", "*", "ChainDB", ")", "createBlockTimeIndexes", "(", ")", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "err", ":=", "IndexBlockTimeOnTableAddress", "(", "pgb", ".", "db", ")", "\n", "if", "err", "!=", "nil", "{", "log", "."...
// CreateBlockTimeIndexes creates back all the dropped indexes.
[ "CreateBlockTimeIndexes", "creates", "back", "all", "the", "dropped", "indexes", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1106-L1112
141,785
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAllVotesMainchain
func updateAllVotesMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateVotesMainchainAll, "failed to update votes and mainchain status") }
go
func updateAllVotesMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateVotesMainchainAll, "failed to update votes and mainchain status") }
[ "func", "updateAllVotesMainchain", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateVotesMainchainAll", ",", "\"", "\"", ")", "\n", "}" ]
// updateAllVotesMainchain sets is_mainchain for all votes according to their // containing block.
[ "updateAllVotesMainchain", "sets", "is_mainchain", "for", "all", "votes", "according", "to", "their", "containing", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1360-L1363
141,786
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAllTicketsMainchain
func updateAllTicketsMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateTicketsMainchainAll, "failed to update tickets and mainchain status") }
go
func updateAllTicketsMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateTicketsMainchainAll, "failed to update tickets and mainchain status") }
[ "func", "updateAllTicketsMainchain", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateTicketsMainchainAll", ",", "\"", "\"", ")", "\n", "}" ]
// updateAllTicketsMainchain sets is_mainchain for all tickets according to // their containing block.
[ "updateAllTicketsMainchain", "sets", "is_mainchain", "for", "all", "tickets", "according", "to", "their", "containing", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1367-L1370
141,787
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAllTxnsValidMainchain
func updateAllTxnsValidMainchain(db *sql.DB) (rowsUpdated int64, err error) { rowsUpdated, err = sqlExec(db, internal.UpdateRegularTxnsValidAll, "failed to update regular transactions' validity status") if err != nil { return } return sqlExec(db, internal.UpdateTxnsMainchainAll, "failed to update all transact...
go
func updateAllTxnsValidMainchain(db *sql.DB) (rowsUpdated int64, err error) { rowsUpdated, err = sqlExec(db, internal.UpdateRegularTxnsValidAll, "failed to update regular transactions' validity status") if err != nil { return } return sqlExec(db, internal.UpdateTxnsMainchainAll, "failed to update all transact...
[ "func", "updateAllTxnsValidMainchain", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "rowsUpdated", ",", "err", "=", "sqlExec", "(", "db", ",", "internal", ".", "UpdateRegularTxnsValidAll", ",", "\"", "\...
// updateAllTxnsValidMainchain sets is_mainchain and is_valid for all // transactions according to their containing block.
[ "updateAllTxnsValidMainchain", "sets", "is_mainchain", "and", "is_valid", "for", "all", "transactions", "according", "to", "their", "containing", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1374-L1382
141,788
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAllAddressesValidMainchain
func updateAllAddressesValidMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateValidMainchainFromTransactions, "failed to update addresses rows valid_mainchain status") }
go
func updateAllAddressesValidMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateValidMainchainFromTransactions, "failed to update addresses rows valid_mainchain status") }
[ "func", "updateAllAddressesValidMainchain", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateValidMainchainFromTransactions", ",", "\"", "\"", ")", ...
// updateAllAddressesValidMainchain sets valid_mainchain for all addresses table // rows according to their corresponding transaction.
[ "updateAllAddressesValidMainchain", "sets", "valid_mainchain", "for", "all", "addresses", "table", "rows", "according", "to", "their", "corresponding", "transaction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1386-L1389
141,789
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAddressesValidMainchainPatch
func updateAddressesValidMainchainPatch(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateAddressesGloballyInvalid, "failed to update addresses rows valid_mainchain status") }
go
func updateAddressesValidMainchainPatch(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateAddressesGloballyInvalid, "failed to update addresses rows valid_mainchain status") }
[ "func", "updateAddressesValidMainchainPatch", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateAddressesGloballyInvalid", ",", "\"", "\"", ")", "\n...
// updateAddressesValidMainchainPatch selectively sets valid_mainchain for // addresses table rows that are set incorrectly according to their // corresponding transaction.
[ "updateAddressesValidMainchainPatch", "selectively", "sets", "valid_mainchain", "for", "addresses", "table", "rows", "that", "are", "set", "incorrectly", "according", "to", "their", "corresponding", "transaction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1394-L1397
141,790
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAddressesMatchingTxHashPatch
func updateAddressesMatchingTxHashPatch(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateAddressesFundingMatchingHash, "failed to update addresses rows matching_tx_hash") }
go
func updateAddressesMatchingTxHashPatch(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateAddressesFundingMatchingHash, "failed to update addresses rows matching_tx_hash") }
[ "func", "updateAddressesMatchingTxHashPatch", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateAddressesFundingMatchingHash", ",", "\"", "\"", ")", ...
// updateAddressesMatchingTxHashPatch selectively sets matching_tx_hash for // addresses table rows that are set incorrectly according to their // corresponding transaction.
[ "updateAddressesMatchingTxHashPatch", "selectively", "sets", "matching_tx_hash", "for", "addresses", "table", "rows", "that", "are", "set", "incorrectly", "according", "to", "their", "corresponding", "transaction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1402-L1405
141,791
decred/dcrdata
db/dcrpg/upgrades_legacy.go
handleBlocksTableMainchainUpgrade
func (pgb *ChainDB) handleBlocksTableMainchainUpgrade(bestBlock string) (int64, error) { // Start at best block, upgrade, and move to previous block. Stop after // genesis, which previous block hash is the zero hash. var blocksUpdated int64 previousHash, thisBlockHash := bestBlock, bestBlock for !bytes.Equal(zeroH...
go
func (pgb *ChainDB) handleBlocksTableMainchainUpgrade(bestBlock string) (int64, error) { // Start at best block, upgrade, and move to previous block. Stop after // genesis, which previous block hash is the zero hash. var blocksUpdated int64 previousHash, thisBlockHash := bestBlock, bestBlock for !bytes.Equal(zeroH...
[ "func", "(", "pgb", "*", "ChainDB", ")", "handleBlocksTableMainchainUpgrade", "(", "bestBlock", "string", ")", "(", "int64", ",", "error", ")", "{", "// Start at best block, upgrade, and move to previous block. Stop after", "// genesis, which previous block hash is the zero hash....
// handleBlocksTableMainchainUpgrade sets is_mainchain=true for all blocks in // the main chain, starting with the best block and working back to genesis.
[ "handleBlocksTableMainchainUpgrade", "sets", "is_mainchain", "=", "true", "for", "all", "blocks", "in", "the", "main", "chain", "starting", "with", "the", "best", "block", "and", "working", "back", "to", "genesis", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1409-L1438
141,792
decred/dcrdata
db/dcrpg/upgrades_legacy.go
handlevinsTableCoinSupplyUpgrade
func (pgb *ChainDB) handlevinsTableCoinSupplyUpgrade(msgBlock *wire.MsgBlock) (int64, error) { var isValid bool var rowsUpdated int64 var err = pgb.db.QueryRow(`SELECT is_valid, is_mainchain FROM blocks WHERE hash = $1 ;`, msgBlock.BlockHash().String()).Scan(&isValid) if err != nil { return 0, err } // isMa...
go
func (pgb *ChainDB) handlevinsTableCoinSupplyUpgrade(msgBlock *wire.MsgBlock) (int64, error) { var isValid bool var rowsUpdated int64 var err = pgb.db.QueryRow(`SELECT is_valid, is_mainchain FROM blocks WHERE hash = $1 ;`, msgBlock.BlockHash().String()).Scan(&isValid) if err != nil { return 0, err } // isMa...
[ "func", "(", "pgb", "*", "ChainDB", ")", "handlevinsTableCoinSupplyUpgrade", "(", "msgBlock", "*", "wire", ".", "MsgBlock", ")", "(", "int64", ",", "error", ")", "{", "var", "isValid", "bool", "\n", "var", "rowsUpdated", "int64", "\n\n", "var", "err", "=",...
// handlevinsTableCoinSupplyUpgrade implements the upgrade to the new newly added columns // in the vins table. The new columns are mainly used for the coin supply chart. // If all the new columns are not added, quit the db upgrade.
[ "handlevinsTableCoinSupplyUpgrade", "implements", "the", "upgrade", "to", "the", "new", "newly", "added", "columns", "in", "the", "vins", "table", ".", "The", "new", "columns", "are", "mainly", "used", "for", "the", "coin", "supply", "chart", ".", "If", "all",...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1450-L1485
141,793
decred/dcrdata
db/dcrpg/upgrades_legacy.go
handleAgendasTableUpgrade
func (pgb *ChainDB) handleAgendasTableUpgrade(msgBlock *wire.MsgBlock) (int64, error) { // neither isValid or isMainchain are important dbTxns, _, _ := dbtypes.ExtractBlockTransactions(msgBlock, wire.TxTreeStake, pgb.chainParams, true, false) var rowsUpdated int64 for i, tx := range dbTxns { if tx.TxType != in...
go
func (pgb *ChainDB) handleAgendasTableUpgrade(msgBlock *wire.MsgBlock) (int64, error) { // neither isValid or isMainchain are important dbTxns, _, _ := dbtypes.ExtractBlockTransactions(msgBlock, wire.TxTreeStake, pgb.chainParams, true, false) var rowsUpdated int64 for i, tx := range dbTxns { if tx.TxType != in...
[ "func", "(", "pgb", "*", "ChainDB", ")", "handleAgendasTableUpgrade", "(", "msgBlock", "*", "wire", ".", "MsgBlock", ")", "(", "int64", ",", "error", ")", "{", "// neither isValid or isMainchain are important", "dbTxns", ",", "_", ",", "_", ":=", "dbtypes", "....
// handleAgendasTableUpgrade implements the upgrade to the newly added agenda table.
[ "handleAgendasTableUpgrade", "implements", "the", "upgrade", "to", "the", "newly", "added", "agenda", "table", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1488-L1531
141,794
decred/dcrdata
db/dcrpg/upgrades_legacy.go
handleAgendaAndAgendaVotesTablesUpgrade
func (pgb *ChainDB) handleAgendaAndAgendaVotesTablesUpgrade(msgBlock *wire.MsgBlock) (int64, error) { // neither isValid or isMainchain are important dbTxns, _, _ := dbtypes.ExtractBlockTransactions(msgBlock, wire.TxTreeStake, pgb.chainParams, true, false) var rowsUpdated int64 query := `UPDATE votes SET block_t...
go
func (pgb *ChainDB) handleAgendaAndAgendaVotesTablesUpgrade(msgBlock *wire.MsgBlock) (int64, error) { // neither isValid or isMainchain are important dbTxns, _, _ := dbtypes.ExtractBlockTransactions(msgBlock, wire.TxTreeStake, pgb.chainParams, true, false) var rowsUpdated int64 query := `UPDATE votes SET block_t...
[ "func", "(", "pgb", "*", "ChainDB", ")", "handleAgendaAndAgendaVotesTablesUpgrade", "(", "msgBlock", "*", "wire", ".", "MsgBlock", ")", "(", "int64", ",", "error", ")", "{", "// neither isValid or isMainchain are important", "dbTxns", ",", "_", ",", "_", ":=", "...
// handleAgendaAndAgendaVotesTableUpgrade restructures the agendas table, creates // a new agenda_votes table and adds a new block time column to votes table.
[ "handleAgendaAndAgendaVotesTableUpgrade", "restructures", "the", "agendas", "table", "creates", "a", "new", "agenda_votes", "table", "and", "adds", "a", "new", "block", "time", "column", "to", "votes", "table", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1535-L1590
141,795
decred/dcrdata
db/dcrpg/upgrades_legacy.go
haveEmptyAgendasTable
func haveEmptyAgendasTable(db *sql.DB) (bool, error) { var isExists int var err = db.QueryRow(`SELECT COUNT(*) FROM agendas;`).Scan(&isExists) if err != nil { return false, err } if isExists != 0 { return false, nil } return true, nil }
go
func haveEmptyAgendasTable(db *sql.DB) (bool, error) { var isExists int var err = db.QueryRow(`SELECT COUNT(*) FROM agendas;`).Scan(&isExists) if err != nil { return false, err } if isExists != 0 { return false, nil } return true, nil }
[ "func", "haveEmptyAgendasTable", "(", "db", "*", "sql", ".", "DB", ")", "(", "bool", ",", "error", ")", "{", "var", "isExists", "int", "\n", "var", "err", "=", "db", ".", "QueryRow", "(", "`SELECT COUNT(*) FROM agendas;`", ")", ".", "Scan", "(", "&", "...
// haveEmptyAgendasTable checks if the agendas table is empty. If the agenda // table exists bool false is returned otherwise bool true is returned. // If the table is not empty then this upgrade doesn't proceed.
[ "haveEmptyAgendasTable", "checks", "if", "the", "agendas", "table", "is", "empty", ".", "If", "the", "agenda", "table", "exists", "bool", "false", "is", "returned", "otherwise", "bool", "true", "is", "returned", ".", "If", "the", "table", "is", "not", "empty...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1595-L1607
141,796
decred/dcrdata
db/dcrpg/upgrades_legacy.go
versionAllTables
func versionAllTables(db *sql.DB, version TableVersion) error { for tableName := range createLegacyTableStatements { _, err := db.Exec(fmt.Sprintf(`COMMENT ON TABLE %s IS 'v%s';`, tableName, version)) if err != nil { return err } log.Infof("Modified the %v table version to %v", tableName, version) } r...
go
func versionAllTables(db *sql.DB, version TableVersion) error { for tableName := range createLegacyTableStatements { _, err := db.Exec(fmt.Sprintf(`COMMENT ON TABLE %s IS 'v%s';`, tableName, version)) if err != nil { return err } log.Infof("Modified the %v table version to %v", tableName, version) } r...
[ "func", "versionAllTables", "(", "db", "*", "sql", ".", "DB", ",", "version", "TableVersion", ")", "error", "{", "for", "tableName", ":=", "range", "createLegacyTableStatements", "{", "_", ",", "err", ":=", "db", ".", "Exec", "(", "fmt", ".", "Sprintf", ...
// versionAllTables comments the tables with the upgraded table version.
[ "versionAllTables", "comments", "the", "tables", "with", "the", "upgraded", "table", "version", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1865-L1876
141,797
decred/dcrdata
db/dcrpg/upgrades_legacy.go
verifyChainWork
func verifyChainWork(client BlockGetter, db *sql.DB) (int64, error) { // Count rows with missing chainWork. var count int64 countRow := db.QueryRow(`SELECT COUNT(hash) FROM blocks WHERE chainwork = '0';`) err := countRow.Scan(&count) if err != nil { log.Error("Failed to count null chainwork columns: %v", err) ...
go
func verifyChainWork(client BlockGetter, db *sql.DB) (int64, error) { // Count rows with missing chainWork. var count int64 countRow := db.QueryRow(`SELECT COUNT(hash) FROM blocks WHERE chainwork = '0';`) err := countRow.Scan(&count) if err != nil { log.Error("Failed to count null chainwork columns: %v", err) ...
[ "func", "verifyChainWork", "(", "client", "BlockGetter", ",", "db", "*", "sql", ".", "DB", ")", "(", "int64", ",", "error", ")", "{", "// Count rows with missing chainWork.", "var", "count", "int64", "\n", "countRow", ":=", "db", ".", "QueryRow", "(", "`SELE...
// verifyChainWork fetches and inserts missing chainwork values. // This addresses a table update done at DB version 3.7.0.
[ "verifyChainWork", "fetches", "and", "inserts", "missing", "chainwork", "values", ".", "This", "addresses", "a", "table", "update", "done", "at", "DB", "version", "3", ".", "7", ".", "0", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1880-L1959
141,798
decred/dcrdata
gov/politeia/types/types.go
VotesStatuses
func VotesStatuses() map[VoteStatusType]string { m := make(map[VoteStatusType]string) for k, val := range ShorterDesc { if k == piapi.PropVoteStatusInvalid || k == piapi.PropVoteStatusDoesntExist { continue } m[VoteStatusType(k)] = val } return m }
go
func VotesStatuses() map[VoteStatusType]string { m := make(map[VoteStatusType]string) for k, val := range ShorterDesc { if k == piapi.PropVoteStatusInvalid || k == piapi.PropVoteStatusDoesntExist { continue } m[VoteStatusType(k)] = val } return m }
[ "func", "VotesStatuses", "(", ")", "map", "[", "VoteStatusType", "]", "string", "{", "m", ":=", "make", "(", "map", "[", "VoteStatusType", "]", "string", ")", "\n", "for", "k", ",", "val", ":=", "range", "ShorterDesc", "{", "if", "k", "==", "piapi", ...
// VotesStatuses returns the ShorterDesc map contents exclusive of Invalid and // Doesn't exist statuses.
[ "VotesStatuses", "returns", "the", "ShorterDesc", "map", "contents", "exclusive", "of", "Invalid", "and", "Doesn", "t", "exist", "statuses", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/types/types.go#L181-L191
141,799
decred/dcrdata
gov/politeia/types/types.go
IsEqual
func (a *ProposalInfo) IsEqual(b *ProposalInfo) bool { if a.CensorshipRecord != b.CensorshipRecord || a.Name != b.Name || a.State != b.State || a.NumComments != b.NumComments || a.StatusChangeMsg != b.StatusChangeMsg || a.Status != b.Status || a.Timestamp != b.Timestamp || a.Token != b.Token || a.CensoredDate !=...
go
func (a *ProposalInfo) IsEqual(b *ProposalInfo) bool { if a.CensorshipRecord != b.CensorshipRecord || a.Name != b.Name || a.State != b.State || a.NumComments != b.NumComments || a.StatusChangeMsg != b.StatusChangeMsg || a.Status != b.Status || a.Timestamp != b.Timestamp || a.Token != b.Token || a.CensoredDate !=...
[ "func", "(", "a", "*", "ProposalInfo", ")", "IsEqual", "(", "b", "*", "ProposalInfo", ")", "bool", "{", "if", "a", ".", "CensorshipRecord", "!=", "b", ".", "CensorshipRecord", "||", "a", ".", "Name", "!=", "b", ".", "Name", "||", "a", ".", "State", ...
// IsEqual compares CensorshipRecord, Name, State, NumComments, StatusChangeMsg, // Timestamp, CensoredDate, AbandonedDate, PublishedDate, Token, VoteStatus, // TotalVotes and count of VoteResults between the two ProposalsInfo structs passed.
[ "IsEqual", "compares", "CensorshipRecord", "Name", "State", "NumComments", "StatusChangeMsg", "Timestamp", "CensoredDate", "AbandonedDate", "PublishedDate", "Token", "VoteStatus", "TotalVotes", "and", "count", "of", "VoteResults", "between", "the", "two", "ProposalsInfo", ...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/types/types.go#L196-L206