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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,100 | decred/dcrdata | middleware/apimiddleware.go | GetTpCtx | func GetTpCtx(r *http.Request) string {
tp, ok := r.Context().Value(ctxTp).(string)
if !ok {
apiLog.Trace("ticket pool interval not set")
return ""
}
return tp
} | go | func GetTpCtx(r *http.Request) string {
tp, ok := r.Context().Value(ctxTp).(string)
if !ok {
apiLog.Trace("ticket pool interval not set")
return ""
}
return tp
} | [
"func",
"GetTpCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"tp",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxTp",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"apiLog",
".",
"Trace",
... | // GetTpCtx retrieves the ctxTp data from the request context.
// If the value is not set, an empty string is returned. | [
"GetTpCtx",
"retrieves",
"the",
"ctxTp",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"the",
"value",
"is",
"not",
"set",
"an",
"empty",
"string",
"is",
"returned",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L143-L150 |
20,101 | decred/dcrdata | middleware/apimiddleware.go | GetProposalTokenCtx | func GetProposalTokenCtx(r *http.Request) string {
tp, ok := r.Context().Value(ctxProposalToken).(string)
if !ok {
apiLog.Trace("proposal token hash not set")
return ""
}
return tp
} | go | func GetProposalTokenCtx(r *http.Request) string {
tp, ok := r.Context().Value(ctxProposalToken).(string)
if !ok {
apiLog.Trace("proposal token hash not set")
return ""
}
return tp
} | [
"func",
"GetProposalTokenCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"tp",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxProposalToken",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"apiLog... | // GetProposalTokenCtx retrieves the ctxProposalToken data from the request context.
// If the value is not set, an empty string is returned. | [
"GetProposalTokenCtx",
"retrieves",
"the",
"ctxProposalToken",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"the",
"value",
"is",
"not",
"set",
"an",
"empty",
"string",
"is",
"returned",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L154-L161 |
20,102 | decred/dcrdata | middleware/apimiddleware.go | GetRawHexTx | func GetRawHexTx(r *http.Request) (string, error) {
rawHexTx, ok := r.Context().Value(ctxRawHexTx).(string)
if !ok {
apiLog.Trace("hex transaction id not set")
return "", fmt.Errorf("hex transaction id not set")
}
msgtx := wire.NewMsgTx()
err := msgtx.Deserialize(hex.NewDecoder(strings.NewReader(rawHexTx)))
... | go | func GetRawHexTx(r *http.Request) (string, error) {
rawHexTx, ok := r.Context().Value(ctxRawHexTx).(string)
if !ok {
apiLog.Trace("hex transaction id not set")
return "", fmt.Errorf("hex transaction id not set")
}
msgtx := wire.NewMsgTx()
err := msgtx.Deserialize(hex.NewDecoder(strings.NewReader(rawHexTx)))
... | [
"func",
"GetRawHexTx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"string",
",",
"error",
")",
"{",
"rawHexTx",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxRawHexTx",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",... | // GetRawHexTx retrieves the ctxRawHexTx data from the request context. If not
// set, the return value is an empty string. | [
"GetRawHexTx",
"retrieves",
"the",
"ctxRawHexTx",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L165-L178 |
20,103 | decred/dcrdata | middleware/apimiddleware.go | PostBroadcastTxCtx | func PostBroadcastTxCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var req apitypes.InsightRawTx
body, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
writeHTMLBadRequest(w, fmt.Sprintf("Error reading JSON message: %v", err))
retu... | go | func PostBroadcastTxCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var req apitypes.InsightRawTx
body, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
writeHTMLBadRequest(w, fmt.Sprintf("Error reading JSON message: %v", err))
retu... | [
"func",
"PostBroadcastTxCtx",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"var",
"re... | // PostBroadcastTxCtx is middleware that checks for parameters given in POST
// request body of the broadcast transaction endpoint. | [
"PostBroadcastTxCtx",
"is",
"middleware",
"that",
"checks",
"for",
"parameters",
"given",
"in",
"POST",
"request",
"body",
"of",
"the",
"broadcast",
"transaction",
"endpoint",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L182-L208 |
20,104 | decred/dcrdata | middleware/apimiddleware.go | GetTxIDCtx | func GetTxIDCtx(r *http.Request) (*chainhash.Hash, error) {
hashStr, ok := r.Context().Value(ctxTxHash).(string)
if !ok {
apiLog.Trace("txid not set")
return nil, fmt.Errorf("txid not set")
}
hash, err := chainhash.NewHashFromStr(hashStr)
if err != nil {
apiLog.Trace("invalid hash '%s': %v", hashStr, err)
... | go | func GetTxIDCtx(r *http.Request) (*chainhash.Hash, error) {
hashStr, ok := r.Context().Value(ctxTxHash).(string)
if !ok {
apiLog.Trace("txid not set")
return nil, fmt.Errorf("txid not set")
}
hash, err := chainhash.NewHashFromStr(hashStr)
if err != nil {
apiLog.Trace("invalid hash '%s': %v", hashStr, err)
... | [
"func",
"GetTxIDCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"chainhash",
".",
"Hash",
",",
"error",
")",
"{",
"hashStr",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxTxHash",
")",
".",
"(",
"string",
")",... | // GetTxIDCtx retrieves the ctxTxHash data from the request context. If not set,
// the return value is an empty string. | [
"GetTxIDCtx",
"retrieves",
"the",
"ctxTxHash",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L212-L225 |
20,105 | decred/dcrdata | middleware/apimiddleware.go | GetTxnsCtx | func GetTxnsCtx(r *http.Request) ([]*chainhash.Hash, error) {
hashStrs, ok := r.Context().Value(ctxTxns).([]string)
if !ok || len(hashStrs) == 0 {
apiLog.Trace("ctxTxns not set")
return nil, fmt.Errorf("ctxTxns not set")
}
var hashes []*chainhash.Hash
for _, hashStr := range hashStrs {
hash, err := chainhas... | go | func GetTxnsCtx(r *http.Request) ([]*chainhash.Hash, error) {
hashStrs, ok := r.Context().Value(ctxTxns).([]string)
if !ok || len(hashStrs) == 0 {
apiLog.Trace("ctxTxns not set")
return nil, fmt.Errorf("ctxTxns not set")
}
var hashes []*chainhash.Hash
for _, hashStr := range hashStrs {
hash, err := chainhas... | [
"func",
"GetTxnsCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"[",
"]",
"*",
"chainhash",
".",
"Hash",
",",
"error",
")",
"{",
"hashStrs",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxTxns",
")",
".",
"(",
"["... | // GetTxnsCtx retrieves the ctxTxns data from the request context. If not set,
// the return value is an empty string slice. | [
"GetTxnsCtx",
"retrieves",
"the",
"ctxTxns",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
"slice",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L229-L247 |
20,106 | decred/dcrdata | middleware/apimiddleware.go | PostTxnsCtx | func PostTxnsCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
req := apitypes.Txns{}
body, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
apiLog.Debugf("No/invalid txns: %v", err)
http.Error(w, "error reading JSON message", http.St... | go | func PostTxnsCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
req := apitypes.Txns{}
body, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
apiLog.Debugf("No/invalid txns: %v", err)
http.Error(w, "error reading JSON message", http.St... | [
"func",
"PostTxnsCtx",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"req",
":=",
"a... | // PostTxnsCtx extract transaction IDs from the POST body | [
"PostTxnsCtx",
"extract",
"transaction",
"IDs",
"from",
"the",
"POST",
"body"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L257-L278 |
20,107 | decred/dcrdata | middleware/apimiddleware.go | ValidateTxnsPostCtx | func ValidateTxnsPostCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
contentLengthString := r.Header.Get("Content-Length")
contentLength, err := strconv.Atoi(contentLengthString)
if err != nil {
http.Error(w, "Unable to parse Content-Length", http.S... | go | func ValidateTxnsPostCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
contentLengthString := r.Header.Get("Content-Length")
contentLength, err := strconv.Atoi(contentLengthString)
if err != nil {
http.Error(w, "Unable to parse Content-Length", http.S... | [
"func",
"ValidateTxnsPostCtx",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"contentLen... | // ValidateTxnsPostCtx will confirm Post content length is valid. | [
"ValidateTxnsPostCtx",
"will",
"confirm",
"Post",
"content",
"length",
"is",
"valid",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L281-L297 |
20,108 | decred/dcrdata | middleware/apimiddleware.go | GetBlockHashCtx | func GetBlockHashCtx(r *http.Request) (string, error) {
hash, ok := r.Context().Value(ctxBlockHash).(string)
if !ok {
apiLog.Trace("block hash not set")
return "", fmt.Errorf("block hash not set")
}
if _, err := chainhash.NewHashFromStr(hash); err != nil {
apiLog.Trace("invalid hash '%s': %v", hash, err)
re... | go | func GetBlockHashCtx(r *http.Request) (string, error) {
hash, ok := r.Context().Value(ctxBlockHash).(string)
if !ok {
apiLog.Trace("block hash not set")
return "", fmt.Errorf("block hash not set")
}
if _, err := chainhash.NewHashFromStr(hash); err != nil {
apiLog.Trace("invalid hash '%s': %v", hash, err)
re... | [
"func",
"GetBlockHashCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"string",
",",
"error",
")",
"{",
"hash",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxBlockHash",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!"... | // GetBlockHashCtx retrieves the ctxBlockHash data from the request context. If
// not set, the return value is an empty string. | [
"GetBlockHashCtx",
"retrieves",
"the",
"ctxBlockHash",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L301-L313 |
20,109 | decred/dcrdata | middleware/apimiddleware.go | GetAddressCtx | func GetAddressCtx(r *http.Request, activeNetParams *chaincfg.Params, maxAddrs int) ([]string, error) {
addressStr, ok := r.Context().Value(CtxAddress).(string)
if !ok || len(addressStr) == 0 {
apiLog.Trace("address not set")
return nil, fmt.Errorf("address not set")
}
addressStrs := strings.Split(addressStr, "... | go | func GetAddressCtx(r *http.Request, activeNetParams *chaincfg.Params, maxAddrs int) ([]string, error) {
addressStr, ok := r.Context().Value(CtxAddress).(string)
if !ok || len(addressStr) == 0 {
apiLog.Trace("address not set")
return nil, fmt.Errorf("address not set")
}
addressStrs := strings.Split(addressStr, "... | [
"func",
"GetAddressCtx",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"activeNetParams",
"*",
"chaincfg",
".",
"Params",
",",
"maxAddrs",
"int",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"addressStr",
",",
"ok",
":=",
"r",
".",
"Context",
... | // GetAddressCtx retrieves the CtxAddress data from the request context. If not
// set, the return value is an empty string. The CtxAddress string data may be a
// comma-separated list of addresses, subject to the provided maximum number of
// addresses allowed. Duplicate addresses are removed, but the limit is enforce... | [
"GetAddressCtx",
"retrieves",
"the",
"CtxAddress",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
".",
"The",
"CtxAddress",
"string",
"data",
"may",
"be",
"a",
"comma",
"-",
"s... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L320-L357 |
20,110 | decred/dcrdata | middleware/apimiddleware.go | GetChartTypeCtx | func GetChartTypeCtx(r *http.Request) string {
chartType, ok := r.Context().Value(ctxChartType).(string)
if !ok {
apiLog.Trace("chart type not set")
return ""
}
return chartType
} | go | func GetChartTypeCtx(r *http.Request) string {
chartType, ok := r.Context().Value(ctxChartType).(string)
if !ok {
apiLog.Trace("chart type not set")
return ""
}
return chartType
} | [
"func",
"GetChartTypeCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"chartType",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxChartType",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"apiLog"... | // GetChartTypeCtx retrieves the ctxChart data from the request context.
// If not set, the return value is an empty string. | [
"GetChartTypeCtx",
"retrieves",
"the",
"ctxChart",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L361-L368 |
20,111 | decred/dcrdata | middleware/apimiddleware.go | GetChartGroupingCtx | func GetChartGroupingCtx(r *http.Request) string {
chartType, ok := r.Context().Value(ctxChartGrouping).(string)
if !ok {
apiLog.Trace("chart grouping not set")
return ""
}
return chartType
} | go | func GetChartGroupingCtx(r *http.Request) string {
chartType, ok := r.Context().Value(ctxChartGrouping).(string)
if !ok {
apiLog.Trace("chart grouping not set")
return ""
}
return chartType
} | [
"func",
"GetChartGroupingCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"chartType",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxChartGrouping",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
... | // GetChartGroupingCtx retrieves the ctxChart data from the request context.
// If not set, the return value is an empty string. | [
"GetChartGroupingCtx",
"retrieves",
"the",
"ctxChart",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L372-L379 |
20,112 | decred/dcrdata | middleware/apimiddleware.go | GetBlockDateCtx | func GetBlockDateCtx(r *http.Request) string {
blockDate, _ := r.Context().Value(CtxBlockDate).(string)
return blockDate
} | go | func GetBlockDateCtx(r *http.Request) string {
blockDate, _ := r.Context().Value(CtxBlockDate).(string)
return blockDate
} | [
"func",
"GetBlockDateCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"blockDate",
",",
"_",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"CtxBlockDate",
")",
".",
"(",
"string",
")",
"\n",
"return",
"blockDate",
"\n",
"}"
... | // GetBlockDateCtx retrieves the ctxBlockDate data from the request context. If
// not set, the return value is an empty string. | [
"GetBlockDateCtx",
"retrieves",
"the",
"ctxBlockDate",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L416-L419 |
20,113 | decred/dcrdata | middleware/apimiddleware.go | GetBlockIndexCtx | func GetBlockIndexCtx(r *http.Request) int {
idx, ok := r.Context().Value(ctxBlockIndex).(int)
if !ok {
apiLog.Warn("block index not set or is not an int")
return -1
}
return idx
} | go | func GetBlockIndexCtx(r *http.Request) int {
idx, ok := r.Context().Value(ctxBlockIndex).(int)
if !ok {
apiLog.Warn("block index not set or is not an int")
return -1
}
return idx
} | [
"func",
"GetBlockIndexCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"int",
"{",
"idx",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxBlockIndex",
")",
".",
"(",
"int",
")",
"\n",
"if",
"!",
"ok",
"{",
"apiLog",
".",
... | // GetBlockIndexCtx retrieves the ctxBlockIndex data from the request context.
// If not set, the return -1. | [
"GetBlockIndexCtx",
"retrieves",
"the",
"ctxBlockIndex",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"-",
"1",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L423-L430 |
20,114 | decred/dcrdata | middleware/apimiddleware.go | apiDocs | func apiDocs(mux *chi.Mux) func(next http.Handler) http.Handler {
var buf bytes.Buffer
json.Indent(&buf, []byte(docgen.JSONRoutesDoc(mux)), "", "\t")
docs := buf.String()
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValu... | go | func apiDocs(mux *chi.Mux) func(next http.Handler) http.Handler {
var buf bytes.Buffer
json.Indent(&buf, []byte(docgen.JSONRoutesDoc(mux)), "", "\t")
docs := buf.String()
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValu... | [
"func",
"apiDocs",
"(",
"mux",
"*",
"chi",
".",
"Mux",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"json",
".",
"Indent",
"(",
"&",
"buf",
",",
"[",
"]",
"byte",
... | // apiDocs generates a middleware with a "docs" in the context containing a map
// of the routers handlers, etc. | [
"apiDocs",
"generates",
"a",
"middleware",
"with",
"a",
"docs",
"in",
"the",
"context",
"containing",
"a",
"map",
"of",
"the",
"routers",
"handlers",
"etc",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L632-L642 |
20,115 | decred/dcrdata | middleware/apimiddleware.go | GetAgendaIdCtx | func GetAgendaIdCtx(r *http.Request) string {
agendaId, ok := r.Context().Value(ctxAgendaId).(string)
if !ok {
apiLog.Error("agendaId not parsed")
return ""
}
return agendaId
} | go | func GetAgendaIdCtx(r *http.Request) string {
agendaId, ok := r.Context().Value(ctxAgendaId).(string)
if !ok {
apiLog.Error("agendaId not parsed")
return ""
}
return agendaId
} | [
"func",
"GetAgendaIdCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"agendaId",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxAgendaId",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"apiLog",
... | // GetAgendaIdCtx retrieves the ctxAgendaId data from the request context.
// If not set, the return value is an empty string. | [
"GetAgendaIdCtx",
"retrieves",
"the",
"ctxAgendaId",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"an",
"empty",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L739-L746 |
20,116 | decred/dcrdata | middleware/apimiddleware.go | StatusInfoCtx | func StatusInfoCtx(r *http.Request, source DataSource) context.Context {
idx := int64(-1)
h, err := source.GetHeight()
if h >= 0 && err == nil {
idx = h
}
ctx := context.WithValue(r.Context(), ctxBlockIndex, int(idx)) // Must be int!
q := r.FormValue("q")
return context.WithValue(ctx, ctxGetStatus, q)
} | go | func StatusInfoCtx(r *http.Request, source DataSource) context.Context {
idx := int64(-1)
h, err := source.GetHeight()
if h >= 0 && err == nil {
idx = h
}
ctx := context.WithValue(r.Context(), ctxBlockIndex, int(idx)) // Must be int!
q := r.FormValue("q")
return context.WithValue(ctx, ctxGetStatus, q)
} | [
"func",
"StatusInfoCtx",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"source",
"DataSource",
")",
"context",
".",
"Context",
"{",
"idx",
":=",
"int64",
"(",
"-",
"1",
")",
"\n",
"h",
",",
"err",
":=",
"source",
".",
"GetHeight",
"(",
")",
"\n",
"if... | // StatusInfoCtx embeds the best block index and the POST form data for
// parameter "q" into a request context. | [
"StatusInfoCtx",
"embeds",
"the",
"best",
"block",
"index",
"and",
"the",
"POST",
"form",
"data",
"for",
"parameter",
"q",
"into",
"a",
"request",
"context",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L762-L772 |
20,117 | decred/dcrdata | middleware/apimiddleware.go | GetBlockHeightCtx | func GetBlockHeightCtx(r *http.Request, source DataSource) (int64, error) {
idxI, ok := r.Context().Value(ctxBlockIndex).(int)
idx := int64(idxI)
if !ok || idx < 0 {
hash, err := GetBlockHashCtx(r)
if err != nil {
return 0, err
}
idx, err = source.GetBlockHeight(hash)
if err != nil {
return 0, err
... | go | func GetBlockHeightCtx(r *http.Request, source DataSource) (int64, error) {
idxI, ok := r.Context().Value(ctxBlockIndex).(int)
idx := int64(idxI)
if !ok || idx < 0 {
hash, err := GetBlockHashCtx(r)
if err != nil {
return 0, err
}
idx, err = source.GetBlockHeight(hash)
if err != nil {
return 0, err
... | [
"func",
"GetBlockHeightCtx",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"source",
"DataSource",
")",
"(",
"int64",
",",
"error",
")",
"{",
"idxI",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxBlockIndex",
")",
".",
"(",
"... | // GetBlockHeightCtx returns the block height for the block index or hash
// specified on the URL path. | [
"GetBlockHeightCtx",
"returns",
"the",
"block",
"height",
"for",
"the",
"block",
"index",
"or",
"hash",
"specified",
"on",
"the",
"URL",
"path",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L818-L832 |
20,118 | decred/dcrdata | middleware/apimiddleware.go | RetrieveExchangeTokenCtx | func RetrieveExchangeTokenCtx(r *http.Request) string {
token, ok := r.Context().Value(ctxXcToken).(string)
if !ok {
apiLog.Error("non-string encountered in exchange token context")
return ""
}
return token
} | go | func RetrieveExchangeTokenCtx(r *http.Request) string {
token, ok := r.Context().Value(ctxXcToken).(string)
if !ok {
apiLog.Error("non-string encountered in exchange token context")
return ""
}
return token
} | [
"func",
"RetrieveExchangeTokenCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"token",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxXcToken",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"apiL... | // RetrieveExchangeTokenCtx tries to fetch the exchange token from the request
// context. | [
"RetrieveExchangeTokenCtx",
"tries",
"to",
"fetch",
"the",
"exchange",
"token",
"from",
"the",
"request",
"context",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L856-L863 |
20,119 | decred/dcrdata | middleware/apimiddleware.go | StickWidthContext | func StickWidthContext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
bin := chi.URLParam(r, "bin")
ctx := context.WithValue(r.Context(), ctxStickWidth, bin)
next.ServeHTTP(w, r.WithContext(ctx))
})
} | go | func StickWidthContext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
bin := chi.URLParam(r, "bin")
ctx := context.WithValue(r.Context(), ctxStickWidth, bin)
next.ServeHTTP(w, r.WithContext(ctx))
})
} | [
"func",
"StickWidthContext",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"bin",
":="... | // ExchangeTokenContext pulls the bin width from the URL. | [
"ExchangeTokenContext",
"pulls",
"the",
"bin",
"width",
"from",
"the",
"URL",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L866-L872 |
20,120 | decred/dcrdata | middleware/apimiddleware.go | RetrieveStickWidthCtx | func RetrieveStickWidthCtx(r *http.Request) string {
bin, ok := r.Context().Value(ctxStickWidth).(string)
if !ok {
apiLog.Error("non-string encountered in candlestick width context")
return ""
}
return bin
} | go | func RetrieveStickWidthCtx(r *http.Request) string {
bin, ok := r.Context().Value(ctxStickWidth).(string)
if !ok {
apiLog.Error("non-string encountered in candlestick width context")
return ""
}
return bin
} | [
"func",
"RetrieveStickWidthCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"bin",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxStickWidth",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"apiLog... | // RetrieveStickWidthCtx tries to fetch the candlestick width from the request
// context. | [
"RetrieveStickWidthCtx",
"tries",
"to",
"fetch",
"the",
"candlestick",
"width",
"from",
"the",
"request",
"context",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/middleware/apimiddleware.go#L876-L883 |
20,121 | decred/dcrdata | dcrrates/rateserver/tls.go | openRPCKeyPair | func openRPCKeyPair(cfg *config) (credentials.TransportCredentials, error) {
// Generate a new keypair when the key is missing.
_, e := os.Stat(cfg.KeyPath)
keyExists := !os.IsNotExist(e)
if !keyExists {
cert, err := generateRPCKeyPair(cfg.CertificatePath, cfg.KeyPath, cfg.AltDNSNames, certWriter{})
if err != n... | go | func openRPCKeyPair(cfg *config) (credentials.TransportCredentials, error) {
// Generate a new keypair when the key is missing.
_, e := os.Stat(cfg.KeyPath)
keyExists := !os.IsNotExist(e)
if !keyExists {
cert, err := generateRPCKeyPair(cfg.CertificatePath, cfg.KeyPath, cfg.AltDNSNames, certWriter{})
if err != n... | [
"func",
"openRPCKeyPair",
"(",
"cfg",
"*",
"config",
")",
"(",
"credentials",
".",
"TransportCredentials",
",",
"error",
")",
"{",
"// Generate a new keypair when the key is missing.",
"_",
",",
"e",
":=",
"os",
".",
"Stat",
"(",
"cfg",
".",
"KeyPath",
")",
"\... | // openRPCKeyPair creates or loads the RPC TLS keypair specified by the
// application config. | [
"openRPCKeyPair",
"creates",
"or",
"loads",
"the",
"RPC",
"TLS",
"keypair",
"specified",
"by",
"the",
"application",
"config",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/tls.go#L23-L58 |
20,122 | decred/dcrdata | pubsub/psclient/client.go | Subscribe | func (c *Client) Subscribe(event string) (*pstypes.WebSocketMessage, error) {
// Validate the event type.
_, _, ok := pstypes.ValidateSubscription(event)
if !ok {
return nil, fmt.Errorf("invalid subscription %s", event)
}
// Send the subscribe message.
msg := newSubscribeMsg(event)
_ = c.SetWriteDeadline(time... | go | func (c *Client) Subscribe(event string) (*pstypes.WebSocketMessage, error) {
// Validate the event type.
_, _, ok := pstypes.ValidateSubscription(event)
if !ok {
return nil, fmt.Errorf("invalid subscription %s", event)
}
// Send the subscribe message.
msg := newSubscribeMsg(event)
_ = c.SetWriteDeadline(time... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Subscribe",
"(",
"event",
"string",
")",
"(",
"*",
"pstypes",
".",
"WebSocketMessage",
",",
"error",
")",
"{",
"// Validate the event type.",
"_",
",",
"_",
",",
"ok",
":=",
"pstypes",
".",
"ValidateSubscription",
"("... | // Subscribe sends a subscribe type WebSocketMessage for the given event name
// after validating it. The response is returned. | [
"Subscribe",
"sends",
"a",
"subscribe",
"type",
"WebSocketMessage",
"for",
"the",
"given",
"event",
"name",
"after",
"validating",
"it",
".",
"The",
"response",
"is",
"returned",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/psclient/client.go#L52-L69 |
20,123 | decred/dcrdata | pubsub/psclient/client.go | ReceiveMsgTimeout | func (c *Client) ReceiveMsgTimeout(timeout time.Duration) (*pstypes.WebSocketMessage, error) {
_ = c.SetReadDeadline(time.Now().Add(timeout))
msg := new(pstypes.WebSocketMessage)
if err := websocket.JSON.Receive(c.Conn, &msg); err != nil {
return nil, err
}
return msg, nil
} | go | func (c *Client) ReceiveMsgTimeout(timeout time.Duration) (*pstypes.WebSocketMessage, error) {
_ = c.SetReadDeadline(time.Now().Add(timeout))
msg := new(pstypes.WebSocketMessage)
if err := websocket.JSON.Receive(c.Conn, &msg); err != nil {
return nil, err
}
return msg, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ReceiveMsgTimeout",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"pstypes",
".",
"WebSocketMessage",
",",
"error",
")",
"{",
"_",
"=",
"c",
".",
"SetReadDeadline",
"(",
"time",
".",
"Now",
"(",
")",
"... | // ReceiveMsgTimeout waits for the specified time Duration for a message,
// returned decoded into a WebSocketMessage. | [
"ReceiveMsgTimeout",
"waits",
"for",
"the",
"specified",
"time",
"Duration",
"for",
"a",
"message",
"returned",
"decoded",
"into",
"a",
"WebSocketMessage",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/psclient/client.go#L94-L101 |
20,124 | decred/dcrdata | pubsub/psclient/client.go | ReceiveMsg | func (c *Client) ReceiveMsg() (*pstypes.WebSocketMessage, error) {
return c.ReceiveMsgTimeout(c.ReadTimeout)
} | go | func (c *Client) ReceiveMsg() (*pstypes.WebSocketMessage, error) {
return c.ReceiveMsgTimeout(c.ReadTimeout)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ReceiveMsg",
"(",
")",
"(",
"*",
"pstypes",
".",
"WebSocketMessage",
",",
"error",
")",
"{",
"return",
"c",
".",
"ReceiveMsgTimeout",
"(",
"c",
".",
"ReadTimeout",
")",
"\n",
"}"
] | // ReceiveMsg waits for a message, returned decoded into a WebSocketMessage. The
// Client's configured ReadTimeout is used. | [
"ReceiveMsg",
"waits",
"for",
"a",
"message",
"returned",
"decoded",
"into",
"a",
"WebSocketMessage",
".",
"The",
"Client",
"s",
"configured",
"ReadTimeout",
"is",
"used",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/psclient/client.go#L105-L107 |
20,125 | decred/dcrdata | pubsub/psclient/client.go | ReceiveRaw | func (c *Client) ReceiveRaw() (message string, err error) {
_ = c.SetReadDeadline(time.Now().Add(c.ReadTimeout))
err = websocket.Message.Receive(c.Conn, &message)
return
} | go | func (c *Client) ReceiveRaw() (message string, err error) {
_ = c.SetReadDeadline(time.Now().Add(c.ReadTimeout))
err = websocket.Message.Receive(c.Conn, &message)
return
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ReceiveRaw",
"(",
")",
"(",
"message",
"string",
",",
"err",
"error",
")",
"{",
"_",
"=",
"c",
".",
"SetReadDeadline",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"c",
".",
"ReadTimeout",
")",
")",
... | // ReceiveRaw for a message, returned undecoded as a string. | [
"ReceiveRaw",
"for",
"a",
"message",
"returned",
"undecoded",
"as",
"a",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/psclient/client.go#L110-L114 |
20,126 | decred/dcrdata | pubsub/psclient/client.go | DecodeMsgString | func DecodeMsgString(msg *pstypes.WebSocketMessage) (string, error) {
s, err := DecodeMsg(msg)
if err != nil {
return "", err
}
str, ok := s.(string)
if !ok {
return "", fmt.Errorf("content of Message was not of type string")
}
return str, nil
} | go | func DecodeMsgString(msg *pstypes.WebSocketMessage) (string, error) {
s, err := DecodeMsg(msg)
if err != nil {
return "", err
}
str, ok := s.(string)
if !ok {
return "", fmt.Errorf("content of Message was not of type string")
}
return str, nil
} | [
"func",
"DecodeMsgString",
"(",
"msg",
"*",
"pstypes",
".",
"WebSocketMessage",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
",",
"err",
":=",
"DecodeMsg",
"(",
"msg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
... | // DecodeMsgString attempts to decode the Message content of the given
// WebSocketMessage as a string. | [
"DecodeMsgString",
"attempts",
"to",
"decode",
"the",
"Message",
"content",
"of",
"the",
"given",
"WebSocketMessage",
"as",
"a",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/psclient/client.go#L151-L161 |
20,127 | decred/dcrdata | rpcutils/prefetcher.go | Stop | func (p *BlockPrefetchClient) Stop() {
p.Lock()
close(p.retargetChan)
p.Unlock()
} | go | func (p *BlockPrefetchClient) Stop() {
p.Lock()
close(p.retargetChan)
p.Unlock()
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"Stop",
"(",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"close",
"(",
"p",
".",
"retargetChan",
")",
"\n",
"p",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Stop shuts down the fetcher goroutine. The BlockPrefetchClient may not be
// used after this. | [
"Stop",
"shuts",
"down",
"the",
"fetcher",
"goroutine",
".",
"The",
"BlockPrefetchClient",
"may",
"not",
"be",
"used",
"after",
"this",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L77-L81 |
20,128 | decred/dcrdata | rpcutils/prefetcher.go | Hits | func (p *BlockPrefetchClient) Hits() uint64 {
p.Lock()
defer p.Unlock()
return p.hits
} | go | func (p *BlockPrefetchClient) Hits() uint64 {
p.Lock()
defer p.Unlock()
return p.hits
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"Hits",
"(",
")",
"uint64",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"return",
"p",
".",
"hits",
"\n",
"}"
] | // Hits safely returns the number of prefetch hits. | [
"Hits",
"safely",
"returns",
"the",
"number",
"of",
"prefetch",
"hits",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L84-L88 |
20,129 | decred/dcrdata | rpcutils/prefetcher.go | Misses | func (p *BlockPrefetchClient) Misses() uint64 {
p.Lock()
defer p.Unlock()
return p.misses
} | go | func (p *BlockPrefetchClient) Misses() uint64 {
p.Lock()
defer p.Unlock()
return p.misses
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"Misses",
"(",
")",
"uint64",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"return",
"p",
".",
"misses",
"\n",
"}"
] | // Misses safely returns the number of prefetch misses. | [
"Misses",
"safely",
"returns",
"the",
"number",
"of",
"prefetch",
"misses",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L91-L95 |
20,130 | decred/dcrdata | rpcutils/prefetcher.go | GetBestBlock | func (p *BlockPrefetchClient) GetBestBlock() (*chainhash.Hash, int64, error) {
return p.f.GetBestBlock()
} | go | func (p *BlockPrefetchClient) GetBestBlock() (*chainhash.Hash, int64, error) {
return p.f.GetBestBlock()
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"GetBestBlock",
"(",
")",
"(",
"*",
"chainhash",
".",
"Hash",
",",
"int64",
",",
"error",
")",
"{",
"return",
"p",
".",
"f",
".",
"GetBestBlock",
"(",
")",
"\n",
"}"
] | // GetBestBlock is a passthrough to the client. It does not retarget the
// prefetch range since it does not request the actual block, just the hash and
// height of the best block. | [
"GetBestBlock",
"is",
"a",
"passthrough",
"to",
"the",
"client",
".",
"It",
"does",
"not",
"retarget",
"the",
"prefetch",
"range",
"since",
"it",
"does",
"not",
"request",
"the",
"actual",
"block",
"just",
"the",
"hash",
"and",
"height",
"of",
"the",
"best... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L100-L102 |
20,131 | decred/dcrdata | rpcutils/prefetcher.go | GetBlockData | func (p *BlockPrefetchClient) GetBlockData(hash *chainhash.Hash) (*wire.MsgBlock, *dcrjson.GetBlockHeaderVerboseResult, error) {
p.Lock()
retargetAndUnlock := func(nextHash string) {
p.retarget(nextHash)
p.Unlock()
}
// If the block is already fetched, and the current block, return it. Do not
// retarget.
i... | go | func (p *BlockPrefetchClient) GetBlockData(hash *chainhash.Hash) (*wire.MsgBlock, *dcrjson.GetBlockHeaderVerboseResult, error) {
p.Lock()
retargetAndUnlock := func(nextHash string) {
p.retarget(nextHash)
p.Unlock()
}
// If the block is already fetched, and the current block, return it. Do not
// retarget.
i... | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"GetBlockData",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"wire",
".",
"MsgBlock",
",",
"*",
"dcrjson",
".",
"GetBlockHeaderVerboseResult",
",",
"error",
")",
"{",
"p",
".",
"Lock",
"(",... | // GetBlockData attempts to get the specified block and retargets the prefetcher
// with the next block's hash. If the block was not already fetched, it is
// retrieved immediately and stored following retargeting. | [
"GetBlockData",
"attempts",
"to",
"get",
"the",
"specified",
"block",
"and",
"retargets",
"the",
"prefetcher",
"with",
"the",
"next",
"block",
"s",
"hash",
".",
"If",
"the",
"block",
"was",
"not",
"already",
"fetched",
"it",
"is",
"retrieved",
"immediately",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L107-L152 |
20,132 | decred/dcrdata | rpcutils/prefetcher.go | GetBlock | func (p *BlockPrefetchClient) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock, error) {
msgBlock, _, err := p.GetBlockData(hash)
return msgBlock, err
} | go | func (p *BlockPrefetchClient) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock, error) {
msgBlock, _, err := p.GetBlockData(hash)
return msgBlock, err
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"GetBlock",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"wire",
".",
"MsgBlock",
",",
"error",
")",
"{",
"msgBlock",
",",
"_",
",",
"err",
":=",
"p",
".",
"GetBlockData",
"(",
"hash",
... | // GetBlock retrieves the wire.MsgBlock for the block with the specified hash.
// See GetBlockData for details on how this interacts with the prefetcher. | [
"GetBlock",
"retrieves",
"the",
"wire",
".",
"MsgBlock",
"for",
"the",
"block",
"with",
"the",
"specified",
"hash",
".",
"See",
"GetBlockData",
"for",
"details",
"on",
"how",
"this",
"interacts",
"with",
"the",
"prefetcher",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L156-L159 |
20,133 | decred/dcrdata | rpcutils/prefetcher.go | GetBlockHeaderVerbose | func (p *BlockPrefetchClient) GetBlockHeaderVerbose(hash *chainhash.Hash) (*dcrjson.GetBlockHeaderVerboseResult, error) {
_, headerResult, err := p.GetBlockData(hash)
return headerResult, err
} | go | func (p *BlockPrefetchClient) GetBlockHeaderVerbose(hash *chainhash.Hash) (*dcrjson.GetBlockHeaderVerboseResult, error) {
_, headerResult, err := p.GetBlockData(hash)
return headerResult, err
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"GetBlockHeaderVerbose",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"dcrjson",
".",
"GetBlockHeaderVerboseResult",
",",
"error",
")",
"{",
"_",
",",
"headerResult",
",",
"err",
":=",
"p",
"... | // GetBlockHeaderVerbose retrieves the dcrjson.GetBlockHeaderVerboseResult for
// the block with the specified hash. See GetBlockData for details on how this
// interacts with the prefetcher | [
"GetBlockHeaderVerbose",
"retrieves",
"the",
"dcrjson",
".",
"GetBlockHeaderVerboseResult",
"for",
"the",
"block",
"with",
"the",
"specified",
"hash",
".",
"See",
"GetBlockData",
"for",
"details",
"on",
"how",
"this",
"interacts",
"with",
"the",
"prefetcher"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L164-L167 |
20,134 | decred/dcrdata | rpcutils/prefetcher.go | storeNext | func (p *BlockPrefetchClient) storeNext(msgBlock *wire.MsgBlock, headerResult *dcrjson.GetBlockHeaderVerboseResult) {
p.current = p.next
p.next = &blockData{
height: msgBlock.Header.Height,
hash: msgBlock.BlockHash(),
msgBlock: msgBlock,
headerResult: headerResult,
}
} | go | func (p *BlockPrefetchClient) storeNext(msgBlock *wire.MsgBlock, headerResult *dcrjson.GetBlockHeaderVerboseResult) {
p.current = p.next
p.next = &blockData{
height: msgBlock.Header.Height,
hash: msgBlock.BlockHash(),
msgBlock: msgBlock,
headerResult: headerResult,
}
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"storeNext",
"(",
"msgBlock",
"*",
"wire",
".",
"MsgBlock",
",",
"headerResult",
"*",
"dcrjson",
".",
"GetBlockHeaderVerboseResult",
")",
"{",
"p",
".",
"current",
"=",
"p",
".",
"next",
"\n",
"p",
".",
... | // storeNext stores the input data as the new "next" block. The existing "next"
// becomes "current". | [
"storeNext",
"stores",
"the",
"input",
"data",
"as",
"the",
"new",
"next",
"block",
".",
"The",
"existing",
"next",
"becomes",
"current",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L192-L200 |
20,135 | decred/dcrdata | rpcutils/prefetcher.go | RetrieveAndStoreNext | func (p *BlockPrefetchClient) RetrieveAndStoreNext(nextHash *chainhash.Hash) {
p.Lock()
defer p.Unlock()
// Fetch the next block, if needed.
if p.haveBlockHash(*nextHash) {
return
}
msgBlock, headerResult, _, err := p.retrieveBlockAndHeaderResult(nextHash)
if err != nil {
if strings.HasPrefix(err.Error(), ... | go | func (p *BlockPrefetchClient) RetrieveAndStoreNext(nextHash *chainhash.Hash) {
p.Lock()
defer p.Unlock()
// Fetch the next block, if needed.
if p.haveBlockHash(*nextHash) {
return
}
msgBlock, headerResult, _, err := p.retrieveBlockAndHeaderResult(nextHash)
if err != nil {
if strings.HasPrefix(err.Error(), ... | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"RetrieveAndStoreNext",
"(",
"nextHash",
"*",
"chainhash",
".",
"Hash",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"// Fetch the next block, if needed.",
"if",... | // RetrieveAndStoreNext retrieves the next block specified by the Hash, if it is
// not already the stored next block, and stores the block data. The existing
// "next" becomes "current". | [
"RetrieveAndStoreNext",
"retrieves",
"the",
"next",
"block",
"specified",
"by",
"the",
"Hash",
"if",
"it",
"is",
"not",
"already",
"the",
"stored",
"next",
"block",
"and",
"stores",
"the",
"block",
"data",
".",
"The",
"existing",
"next",
"becomes",
"current",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L220-L240 |
20,136 | decred/dcrdata | rpcutils/prefetcher.go | HaveBlockHeight | func (p *BlockPrefetchClient) HaveBlockHeight(height uint32) bool {
p.Lock()
defer p.Unlock()
return p.haveBlockHeight(height)
} | go | func (p *BlockPrefetchClient) HaveBlockHeight(height uint32) bool {
p.Lock()
defer p.Unlock()
return p.haveBlockHeight(height)
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"HaveBlockHeight",
"(",
"height",
"uint32",
")",
"bool",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"return",
"p",
".",
"haveBlockHeight",
"(",
"height",
")",
... | // HaveBlockHeight checks if the current or prefetched next block is for a block
// with the specified height. Use HaveBlockHash to be sure it is the desired
// block. | [
"HaveBlockHeight",
"checks",
"if",
"the",
"current",
"or",
"prefetched",
"next",
"block",
"is",
"for",
"a",
"block",
"with",
"the",
"specified",
"height",
".",
"Use",
"HaveBlockHash",
"to",
"be",
"sure",
"it",
"is",
"the",
"desired",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L257-L261 |
20,137 | decred/dcrdata | rpcutils/prefetcher.go | HaveBlockHash | func (p *BlockPrefetchClient) HaveBlockHash(hash chainhash.Hash) bool {
p.Lock()
defer p.Unlock()
return p.haveBlockHash(hash)
} | go | func (p *BlockPrefetchClient) HaveBlockHash(hash chainhash.Hash) bool {
p.Lock()
defer p.Unlock()
return p.haveBlockHash(hash)
} | [
"func",
"(",
"p",
"*",
"BlockPrefetchClient",
")",
"HaveBlockHash",
"(",
"hash",
"chainhash",
".",
"Hash",
")",
"bool",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n",
"return",
"p",
".",
"haveBlockHash",
"(",
"has... | // HaveBlockHash checks if the current or prefetched next block is for a block
// with the specified hash. | [
"HaveBlockHash",
"checks",
"if",
"the",
"current",
"or",
"prefetched",
"next",
"block",
"is",
"for",
"a",
"block",
"with",
"the",
"specified",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/prefetcher.go#L269-L273 |
20,138 | decred/dcrdata | gov/agendas/tracker.go | NewVoteTracker | func NewVoteTracker(params *chaincfg.Params, node VoteDataSource, counter voteCounter,
activeVersions map[uint32][]chaincfg.ConsensusDeployment) (*VoteTracker, error) {
var latestStakeVersion uint32
var starttime uint64
// Consensus deployments that share a stake version as the key should also
// have matching st... | go | func NewVoteTracker(params *chaincfg.Params, node VoteDataSource, counter voteCounter,
activeVersions map[uint32][]chaincfg.ConsensusDeployment) (*VoteTracker, error) {
var latestStakeVersion uint32
var starttime uint64
// Consensus deployments that share a stake version as the key should also
// have matching st... | [
"func",
"NewVoteTracker",
"(",
"params",
"*",
"chaincfg",
".",
"Params",
",",
"node",
"VoteDataSource",
",",
"counter",
"voteCounter",
",",
"activeVersions",
"map",
"[",
"uint32",
"]",
"[",
"]",
"chaincfg",
".",
"ConsensusDeployment",
")",
"(",
"*",
"VoteTrack... | // NewVoteTracker is a constructor for a VoteTracker. | [
"NewVoteTracker",
"is",
"a",
"constructor",
"for",
"a",
"VoteTracker",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L130-L181 |
20,139 | decred/dcrdata | gov/agendas/tracker.go | Refresh | func (tracker *VoteTracker) Refresh() {
voteInfo, err := tracker.refreshRCI()
if err != nil {
log.Errorf("VoteTracker.Refresh -> refreshRCI: %v")
return
}
blocksToAdd, stakeVersion, err := tracker.fetchBlocks(voteInfo)
if err != nil {
log.Errorf("VoteTracker.Refresh -> fetchBlocks: %v")
return
}
stakeInf... | go | func (tracker *VoteTracker) Refresh() {
voteInfo, err := tracker.refreshRCI()
if err != nil {
log.Errorf("VoteTracker.Refresh -> refreshRCI: %v")
return
}
blocksToAdd, stakeVersion, err := tracker.fetchBlocks(voteInfo)
if err != nil {
log.Errorf("VoteTracker.Refresh -> fetchBlocks: %v")
return
}
stakeInf... | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"Refresh",
"(",
")",
"{",
"voteInfo",
",",
"err",
":=",
"tracker",
".",
"refreshRCI",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
... | // Refresh refreshes node version and vote data. It can be called as a
// goroutine. All VoteTracker updating and mutex locking is handled within
// VoteTracker.update. | [
"Refresh",
"refreshes",
"node",
"version",
"and",
"vote",
"data",
".",
"It",
"can",
"be",
"called",
"as",
"a",
"goroutine",
".",
"All",
"VoteTracker",
"updating",
"and",
"mutex",
"locking",
"is",
"handled",
"within",
"VoteTracker",
".",
"update",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L186-L203 |
20,140 | decred/dcrdata | gov/agendas/tracker.go | Version | func (tracker *VoteTracker) Version() uint32 {
tracker.mtx.RLock()
defer tracker.mtx.RUnlock()
return tracker.version
} | go | func (tracker *VoteTracker) Version() uint32 {
tracker.mtx.RLock()
defer tracker.mtx.RUnlock()
return tracker.version
} | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"Version",
"(",
")",
"uint32",
"{",
"tracker",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"tracker",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"tracker",
".",
"version",
"\n",
"}"
] | // Version returns the current best known vote version.
// Since version could technically be updated without turning off dcrdata,
// the field must be protected. | [
"Version",
"returns",
"the",
"current",
"best",
"known",
"vote",
"version",
".",
"Since",
"version",
"could",
"technically",
"be",
"updated",
"without",
"turning",
"off",
"dcrdata",
"the",
"field",
"must",
"be",
"protected",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L208-L212 |
20,141 | decred/dcrdata | gov/agendas/tracker.go | refreshRCI | func (tracker *VoteTracker) refreshRCI() (*dcrjson.GetVoteInfoResult, error) {
oldVersion := tracker.Version()
v := oldVersion
var err error
var voteInfo, vinfo *dcrjson.GetVoteInfoResult
// Retrieves the voteinfo for the last stake version supported.
for {
vinfo, err = tracker.node.GetVoteInfo(v)
if err != ... | go | func (tracker *VoteTracker) refreshRCI() (*dcrjson.GetVoteInfoResult, error) {
oldVersion := tracker.Version()
v := oldVersion
var err error
var voteInfo, vinfo *dcrjson.GetVoteInfoResult
// Retrieves the voteinfo for the last stake version supported.
for {
vinfo, err = tracker.node.GetVoteInfo(v)
if err != ... | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"refreshRCI",
"(",
")",
"(",
"*",
"dcrjson",
".",
"GetVoteInfoResult",
",",
"error",
")",
"{",
"oldVersion",
":=",
"tracker",
".",
"Version",
"(",
")",
"\n",
"v",
":=",
"oldVersion",
"\n",
"var",
"err",
... | // Grab the getvoteinfo data. Do not update VoteTracker.voteInfo here, as it
// will be updated with other fields under mutex lock in VoteTracker.update. | [
"Grab",
"the",
"getvoteinfo",
"data",
".",
"Do",
"not",
"update",
"VoteTracker",
".",
"voteInfo",
"here",
"as",
"it",
"will",
"be",
"updated",
"with",
"other",
"fields",
"under",
"mutex",
"lock",
"in",
"VoteTracker",
".",
"update",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L216-L241 |
20,142 | decred/dcrdata | gov/agendas/tracker.go | fetchBlocks | func (tracker *VoteTracker) fetchBlocks(voteInfo *dcrjson.GetVoteInfoResult) ([]int32, uint32, error) {
blocksToRequest := 1
// If this isn't the next block, request them all again
if voteInfo.CurrentHeight < 0 || voteInfo.CurrentHeight != tracker.ringHeight+1 {
blocksToRequest = int(tracker.params.BlockUpgradeNum... | go | func (tracker *VoteTracker) fetchBlocks(voteInfo *dcrjson.GetVoteInfoResult) ([]int32, uint32, error) {
blocksToRequest := 1
// If this isn't the next block, request them all again
if voteInfo.CurrentHeight < 0 || voteInfo.CurrentHeight != tracker.ringHeight+1 {
blocksToRequest = int(tracker.params.BlockUpgradeNum... | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"fetchBlocks",
"(",
"voteInfo",
"*",
"dcrjson",
".",
"GetVoteInfoResult",
")",
"(",
"[",
"]",
"int32",
",",
"uint32",
",",
"error",
")",
"{",
"blocksToRequest",
":=",
"1",
"\n",
"// If this isn't the next block,... | // Grab the block versions for up to the last BlockUpgradeNumToCheck blocks.
// If the current block builds upon the last block, only request a single
// block's data. Otherwise, request all BlockUpgradeNumToCheck. | [
"Grab",
"the",
"block",
"versions",
"for",
"up",
"to",
"the",
"last",
"BlockUpgradeNumToCheck",
"blocks",
".",
"If",
"the",
"current",
"block",
"builds",
"upon",
"the",
"last",
"block",
"only",
"request",
"a",
"single",
"block",
"s",
"data",
".",
"Otherwise"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L251-L273 |
20,143 | decred/dcrdata | gov/agendas/tracker.go | refreshSVIs | func (tracker *VoteTracker) refreshSVIs(voteInfo *dcrjson.GetVoteInfoResult) (*dcrjson.GetStakeVersionInfoResult, error) {
blocksInCurrentRCI := rciBlocks(voteInfo)
svis := int32(blocksInCurrentRCI / tracker.params.StakeVersionInterval)
// blocksInCurrentSVI := int32(blocksInCurrentRCI % params.StakeVersionInterval)... | go | func (tracker *VoteTracker) refreshSVIs(voteInfo *dcrjson.GetVoteInfoResult) (*dcrjson.GetStakeVersionInfoResult, error) {
blocksInCurrentRCI := rciBlocks(voteInfo)
svis := int32(blocksInCurrentRCI / tracker.params.StakeVersionInterval)
// blocksInCurrentSVI := int32(blocksInCurrentRCI % params.StakeVersionInterval)... | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"refreshSVIs",
"(",
"voteInfo",
"*",
"dcrjson",
".",
"GetVoteInfoResult",
")",
"(",
"*",
"dcrjson",
".",
"GetStakeVersionInfoResult",
",",
"error",
")",
"{",
"blocksInCurrentRCI",
":=",
"rciBlocks",
"(",
"voteInfo... | // Get the info for the stake versions in the current rule change interval. | [
"Get",
"the",
"info",
"for",
"the",
"stake",
"versions",
"in",
"the",
"current",
"rule",
"change",
"interval",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L276-L288 |
20,144 | decred/dcrdata | gov/agendas/tracker.go | cachedCounts | func (tracker *VoteTracker) cachedCounts(agendaID string) *voteCount {
tracker.mtx.RLock()
defer tracker.mtx.RUnlock()
return tracker.countCache[agendaID]
} | go | func (tracker *VoteTracker) cachedCounts(agendaID string) *voteCount {
tracker.mtx.RLock()
defer tracker.mtx.RUnlock()
return tracker.countCache[agendaID]
} | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"cachedCounts",
"(",
"agendaID",
"string",
")",
"*",
"voteCount",
"{",
"tracker",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"tracker",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"trac... | // The cached voteCount for the given agenda, or nil if not found. | [
"The",
"cached",
"voteCount",
"for",
"the",
"given",
"agenda",
"or",
"nil",
"if",
"not",
"found",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L291-L295 |
20,145 | decred/dcrdata | gov/agendas/tracker.go | cacheVoteCounts | func (tracker *VoteTracker) cacheVoteCounts(agendaID string, counts *voteCount) {
tracker.mtx.Lock()
defer tracker.mtx.Unlock()
tracker.countCache[agendaID] = counts
} | go | func (tracker *VoteTracker) cacheVoteCounts(agendaID string, counts *voteCount) {
tracker.mtx.Lock()
defer tracker.mtx.Unlock()
tracker.countCache[agendaID] = counts
} | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"cacheVoteCounts",
"(",
"agendaID",
"string",
",",
"counts",
"*",
"voteCount",
")",
"{",
"tracker",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tracker",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",... | // Cache the voteCount for the given agenda. | [
"Cache",
"the",
"voteCount",
"for",
"the",
"given",
"agenda",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L298-L302 |
20,146 | decred/dcrdata | gov/agendas/tracker.go | update | func (tracker *VoteTracker) update(voteInfo *dcrjson.GetVoteInfoResult, blocks []int32,
stakeInfo *dcrjson.GetStakeVersionInfoResult, stakeVersion uint32) {
// Check if voteCounts are needed
for idx := range voteInfo.Agendas {
agenda := &voteInfo.Agendas[idx]
if agenda.Status != statusDefined && agenda.Status !=... | go | func (tracker *VoteTracker) update(voteInfo *dcrjson.GetVoteInfoResult, blocks []int32,
stakeInfo *dcrjson.GetStakeVersionInfoResult, stakeVersion uint32) {
// Check if voteCounts are needed
for idx := range voteInfo.Agendas {
agenda := &voteInfo.Agendas[idx]
if agenda.Status != statusDefined && agenda.Status !=... | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"update",
"(",
"voteInfo",
"*",
"dcrjson",
".",
"GetVoteInfoResult",
",",
"blocks",
"[",
"]",
"int32",
",",
"stakeInfo",
"*",
"dcrjson",
".",
"GetStakeVersionInfoResult",
",",
"stakeVersion",
"uint32",
")",
"{",... | // Once all resources have been retrieved from dcrd, update VoteTracker fields. | [
"Once",
"all",
"resources",
"have",
"been",
"retrieved",
"from",
"dcrd",
"update",
"VoteTracker",
"fields",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L305-L348 |
20,147 | decred/dcrdata | gov/agendas/tracker.go | Summary | func (tracker *VoteTracker) Summary() *VoteSummary {
tracker.mtx.RLock()
defer tracker.mtx.RUnlock()
return tracker.summary
} | go | func (tracker *VoteTracker) Summary() *VoteSummary {
tracker.mtx.RLock()
defer tracker.mtx.RUnlock()
return tracker.summary
} | [
"func",
"(",
"tracker",
"*",
"VoteTracker",
")",
"Summary",
"(",
")",
"*",
"VoteSummary",
"{",
"tracker",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"tracker",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"tracker",
".",
"summary",
"... | // Summary is a getter for the cached VoteSummary. The summary returned will
// never be modified by VoteTracker, so can be used read-only by any number
// of threads. | [
"Summary",
"is",
"a",
"getter",
"for",
"the",
"cached",
"VoteSummary",
".",
"The",
"summary",
"returned",
"will",
"never",
"be",
"modified",
"by",
"VoteTracker",
"so",
"can",
"be",
"used",
"read",
"-",
"only",
"by",
"any",
"number",
"of",
"threads",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/tracker.go#L469-L473 |
20,148 | decred/dcrdata | dcrrates/rateserver/log.go | initializeLogging | func initializeLogging(logFile, logLevel string) {
log = backendLog.Logger("SRVR")
exchanges.UseLogger(xcLogger)
logDir, _ := filepath.Split(logFile)
err := os.MkdirAll(logDir, 0700)
if err != nil {
log.Errorf("failed to create log directory: %v", err)
os.Exit(1)
}
r, err := rotator.New(logFile, 10*1024, fal... | go | func initializeLogging(logFile, logLevel string) {
log = backendLog.Logger("SRVR")
exchanges.UseLogger(xcLogger)
logDir, _ := filepath.Split(logFile)
err := os.MkdirAll(logDir, 0700)
if err != nil {
log.Errorf("failed to create log directory: %v", err)
os.Exit(1)
}
r, err := rotator.New(logFile, 10*1024, fal... | [
"func",
"initializeLogging",
"(",
"logFile",
",",
"logLevel",
"string",
")",
"{",
"log",
"=",
"backendLog",
".",
"Logger",
"(",
"\"",
"\"",
")",
"\n",
"exchanges",
".",
"UseLogger",
"(",
"xcLogger",
")",
"\n",
"logDir",
",",
"_",
":=",
"filepath",
".",
... | // initializeLogging initializes the logging rotater to write logs to logFile
// and create roll files in the same directory. It must be called before the
// package-global log rotater variables are used. | [
"initializeLogging",
"initializes",
"the",
"logging",
"rotater",
"to",
"write",
"logs",
"to",
"logFile",
"and",
"create",
"roll",
"files",
"in",
"the",
"same",
"directory",
".",
"It",
"must",
"be",
"called",
"before",
"the",
"package",
"-",
"global",
"log",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/log.go#L36-L60 |
20,149 | decred/dcrdata | db/dcrpg/chainmonitor.go | NewChainMonitor | func (pgb *ChainDBRPC) NewChainMonitor(ctx context.Context, wg *sync.WaitGroup,
blockChan chan *chainhash.Hash, reorgChan chan *txhelpers.ReorgData) *ChainMonitor {
if pgb == nil {
return nil
}
return &ChainMonitor{
ctx: ctx,
db: pgb,
wg: wg,
blockChan: blockChan,
... | go | func (pgb *ChainDBRPC) NewChainMonitor(ctx context.Context, wg *sync.WaitGroup,
blockChan chan *chainhash.Hash, reorgChan chan *txhelpers.ReorgData) *ChainMonitor {
if pgb == nil {
return nil
}
return &ChainMonitor{
ctx: ctx,
db: pgb,
wg: wg,
blockChan: blockChan,
... | [
"func",
"(",
"pgb",
"*",
"ChainDBRPC",
")",
"NewChainMonitor",
"(",
"ctx",
"context",
".",
"Context",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"blockChan",
"chan",
"*",
"chainhash",
".",
"Hash",
",",
"reorgChan",
"chan",
"*",
"txhelpers",
".",
"Reo... | // NewChainMonitor creates a new ChainMonitor. | [
"NewChainMonitor",
"creates",
"a",
"new",
"ChainMonitor",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/chainmonitor.go#L30-L44 |
20,150 | decred/dcrdata | rpcutils/rpcclient.go | ConnectNodeRPC | func ConnectNodeRPC(host, user, pass, cert string, disableTLS, disableReconnect bool,
ntfnHandlers ...*rpcclient.NotificationHandlers) (*rpcclient.Client, semver.Semver, error) {
var dcrdCerts []byte
var err error
var nodeVer semver.Semver
if !disableTLS {
dcrdCerts, err = ioutil.ReadFile(cert)
if err != nil {... | go | func ConnectNodeRPC(host, user, pass, cert string, disableTLS, disableReconnect bool,
ntfnHandlers ...*rpcclient.NotificationHandlers) (*rpcclient.Client, semver.Semver, error) {
var dcrdCerts []byte
var err error
var nodeVer semver.Semver
if !disableTLS {
dcrdCerts, err = ioutil.ReadFile(cert)
if err != nil {... | [
"func",
"ConnectNodeRPC",
"(",
"host",
",",
"user",
",",
"pass",
",",
"cert",
"string",
",",
"disableTLS",
",",
"disableReconnect",
"bool",
",",
"ntfnHandlers",
"...",
"*",
"rpcclient",
".",
"NotificationHandlers",
")",
"(",
"*",
"rpcclient",
".",
"Client",
... | // ConnectNodeRPC attempts to create a new websocket connection to a dcrd node,
// with the given credentials and optional notification handlers. | [
"ConnectNodeRPC",
"attempts",
"to",
"create",
"a",
"new",
"websocket",
"connection",
"to",
"a",
"dcrd",
"node",
"with",
"the",
"given",
"credentials",
"and",
"optional",
"notification",
"handlers",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/rpcclient.go#L44-L105 |
20,151 | decred/dcrdata | rpcutils/rpcclient.go | GetBlockByHash | func GetBlockByHash(blockhash *chainhash.Hash, client BlockFetcher) (*dcrutil.Block, error) {
msgBlock, err := client.GetBlock(blockhash)
if err != nil {
return nil, fmt.Errorf("GetBlock failed (%s): %v", blockhash, err)
}
block := dcrutil.NewBlock(msgBlock)
return block, nil
} | go | func GetBlockByHash(blockhash *chainhash.Hash, client BlockFetcher) (*dcrutil.Block, error) {
msgBlock, err := client.GetBlock(blockhash)
if err != nil {
return nil, fmt.Errorf("GetBlock failed (%s): %v", blockhash, err)
}
block := dcrutil.NewBlock(msgBlock)
return block, nil
} | [
"func",
"GetBlockByHash",
"(",
"blockhash",
"*",
"chainhash",
".",
"Hash",
",",
"client",
"BlockFetcher",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"msgBlock",
",",
"err",
":=",
"client",
".",
"GetBlock",
"(",
"blockhash",
")",
"\n"... | // GetBlockByHash gets the block with the given hash from a chain server. | [
"GetBlockByHash",
"gets",
"the",
"block",
"with",
"the",
"given",
"hash",
"from",
"a",
"chain",
"server",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/rpcclient.go#L261-L269 |
20,152 | decred/dcrdata | rpcutils/rpcclient.go | SideChains | func SideChains(client *rpcclient.Client) ([]dcrjson.GetChainTipsResult, error) {
tips, err := client.GetChainTips()
if err != nil {
return nil, err
}
return sideChainTips(tips), nil
} | go | func SideChains(client *rpcclient.Client) ([]dcrjson.GetChainTipsResult, error) {
tips, err := client.GetChainTips()
if err != nil {
return nil, err
}
return sideChainTips(tips), nil
} | [
"func",
"SideChains",
"(",
"client",
"*",
"rpcclient",
".",
"Client",
")",
"(",
"[",
"]",
"dcrjson",
".",
"GetChainTipsResult",
",",
"error",
")",
"{",
"tips",
",",
"err",
":=",
"client",
".",
"GetChainTips",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // SideChains gets a slice of known side chain tips. This corresponds to the
// results of the getchaintips node RPC where the block tip "status" is either
// "valid-headers" or "valid-fork". | [
"SideChains",
"gets",
"a",
"slice",
"of",
"known",
"side",
"chain",
"tips",
".",
"This",
"corresponds",
"to",
"the",
"results",
"of",
"the",
"getchaintips",
"node",
"RPC",
"where",
"the",
"block",
"tip",
"status",
"is",
"either",
"valid",
"-",
"headers",
"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/rpcclient.go#L274-L281 |
20,153 | decred/dcrdata | rpcutils/rpcclient.go | GetTransactionVerboseByID | func GetTransactionVerboseByID(client *rpcclient.Client, txhash *chainhash.Hash) (*dcrjson.TxRawResult, error) {
txraw, err := client.GetRawTransactionVerbose(txhash)
if err != nil {
log.Errorf("GetRawTransactionVerbose failed for: %v", txhash)
return nil, err
}
return txraw, nil
} | go | func GetTransactionVerboseByID(client *rpcclient.Client, txhash *chainhash.Hash) (*dcrjson.TxRawResult, error) {
txraw, err := client.GetRawTransactionVerbose(txhash)
if err != nil {
log.Errorf("GetRawTransactionVerbose failed for: %v", txhash)
return nil, err
}
return txraw, nil
} | [
"func",
"GetTransactionVerboseByID",
"(",
"client",
"*",
"rpcclient",
".",
"Client",
",",
"txhash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"dcrjson",
".",
"TxRawResult",
",",
"error",
")",
"{",
"txraw",
",",
"err",
":=",
"client",
".",
"GetRawTransa... | // GetTransactionVerboseByID get a transaction by transaction id | [
"GetTransactionVerboseByID",
"get",
"a",
"transaction",
"by",
"transaction",
"id"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/rpcclient.go#L341-L348 |
20,154 | decred/dcrdata | rpcutils/rpcclient.go | SearchRawTransaction | func SearchRawTransaction(client *rpcclient.Client, count int, address string) ([]*dcrjson.SearchRawTransactionsResult, error) {
addr, err := dcrutil.DecodeAddress(address)
if err != nil {
log.Infof("Invalid address %s: %v", address, err)
return nil, err
}
//change the 1000 000 number demo for now
txs, err := ... | go | func SearchRawTransaction(client *rpcclient.Client, count int, address string) ([]*dcrjson.SearchRawTransactionsResult, error) {
addr, err := dcrutil.DecodeAddress(address)
if err != nil {
log.Infof("Invalid address %s: %v", address, err)
return nil, err
}
//change the 1000 000 number demo for now
txs, err := ... | [
"func",
"SearchRawTransaction",
"(",
"client",
"*",
"rpcclient",
".",
"Client",
",",
"count",
"int",
",",
"address",
"string",
")",
"(",
"[",
"]",
"*",
"dcrjson",
".",
"SearchRawTransactionsResult",
",",
"error",
")",
"{",
"addr",
",",
"err",
":=",
"dcruti... | // SearchRawTransaction fetch transactions the belong to an
// address | [
"SearchRawTransaction",
"fetch",
"transactions",
"the",
"belong",
"to",
"an",
"address"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/rpcclient.go#L352-L365 |
20,155 | decred/dcrdata | rpcutils/rpcclient.go | CommonAncestor | func CommonAncestor(client BlockFetcher, hashA, hashB chainhash.Hash) (*chainhash.Hash, []chainhash.Hash, []chainhash.Hash, error) {
if client == nil {
return nil, nil, nil, errors.New("nil RPC client")
}
var length int
var chainA, chainB []chainhash.Hash
for {
if length >= maxAncestorChainLength {
return ... | go | func CommonAncestor(client BlockFetcher, hashA, hashB chainhash.Hash) (*chainhash.Hash, []chainhash.Hash, []chainhash.Hash, error) {
if client == nil {
return nil, nil, nil, errors.New("nil RPC client")
}
var length int
var chainA, chainB []chainhash.Hash
for {
if length >= maxAncestorChainLength {
return ... | [
"func",
"CommonAncestor",
"(",
"client",
"BlockFetcher",
",",
"hashA",
",",
"hashB",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"chainhash",
".",
"Hash",
",",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"error",
")",... | // CommonAncestor attempts to determine the common ancestor block for two chains
// specified by the hash of the chain tip block. The full chains from the tips
// back to but not including the common ancestor are also returned. The first
// element in the chain slices is the lowest block following the common
// ancesto... | [
"CommonAncestor",
"attempts",
"to",
"determine",
"the",
"common",
"ancestor",
"block",
"for",
"two",
"chains",
"specified",
"by",
"the",
"hash",
"of",
"the",
"chain",
"tip",
"block",
".",
"The",
"full",
"chains",
"from",
"the",
"tips",
"back",
"to",
"but",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/rpcclient.go#L376-L446 |
20,156 | decred/dcrdata | rpcutils/rpcclient.go | OrphanedTipLength | func OrphanedTipLength(ctx context.Context, client BlockHashGetter,
tipHeight int64, hashFunc func(int64) (string, error)) (int64, error) {
commonHeight := tipHeight
var dbHash string
var err error
var dcrdHash *chainhash.Hash
for {
// Since there are no limits on the number of blocks scanned, allow
// cancel... | go | func OrphanedTipLength(ctx context.Context, client BlockHashGetter,
tipHeight int64, hashFunc func(int64) (string, error)) (int64, error) {
commonHeight := tipHeight
var dbHash string
var err error
var dcrdHash *chainhash.Hash
for {
// Since there are no limits on the number of blocks scanned, allow
// cancel... | [
"func",
"OrphanedTipLength",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"BlockHashGetter",
",",
"tipHeight",
"int64",
",",
"hashFunc",
"func",
"(",
"int64",
")",
"(",
"string",
",",
"error",
")",
")",
"(",
"int64",
",",
"error",
")",
"{",
"com... | // OrphanedTipLength finds a common ancestor by iterating block heights
// backwards until a common block hash is found. Unlike CommonAncestor, an
// orphaned DB tip whose corresponding block is not known to dcrd will not cause
// an error. The number of blocks that have been orphaned is returned.
// Realistically, thi... | [
"OrphanedTipLength",
"finds",
"a",
"common",
"ancestor",
"by",
"iterating",
"block",
"heights",
"backwards",
"until",
"a",
"common",
"block",
"hash",
"is",
"found",
".",
"Unlike",
"CommonAncestor",
"an",
"orphaned",
"DB",
"tip",
"whose",
"corresponding",
"block",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/rpcclient.go#L458-L497 |
20,157 | decred/dcrdata | rpcutils/rpcclient.go | GetChainWork | func GetChainWork(client BlockFetcher, hash *chainhash.Hash) (string, error) {
header, err := client.GetBlockHeaderVerbose(hash)
if err != nil {
return "", err
}
return header.ChainWork, nil
} | go | func GetChainWork(client BlockFetcher, hash *chainhash.Hash) (string, error) {
header, err := client.GetBlockHeaderVerbose(hash)
if err != nil {
return "", err
}
return header.ChainWork, nil
} | [
"func",
"GetChainWork",
"(",
"client",
"BlockFetcher",
",",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"string",
",",
"error",
")",
"{",
"header",
",",
"err",
":=",
"client",
".",
"GetBlockHeaderVerbose",
"(",
"hash",
")",
"\n",
"if",
"err",
"!=",
... | // GetChainWork fetches the dcrjson.BlockHeaderVerbose and returns only the
// ChainWork field as a string. | [
"GetChainWork",
"fetches",
"the",
"dcrjson",
".",
"BlockHeaderVerbose",
"and",
"returns",
"only",
"the",
"ChainWork",
"field",
"as",
"a",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/rpcclient.go#L501-L507 |
20,158 | decred/dcrdata | explorer/explorer.go | TicketStatusText | func TicketStatusText(s dbtypes.TicketSpendType, p dbtypes.TicketPoolStatus) string {
switch p {
case dbtypes.PoolStatusLive:
return "In Live Ticket Pool"
case dbtypes.PoolStatusVoted:
return "Voted"
case dbtypes.PoolStatusExpired:
switch s {
case dbtypes.TicketUnspent:
return "Expired, Unrevoked"
case... | go | func TicketStatusText(s dbtypes.TicketSpendType, p dbtypes.TicketPoolStatus) string {
switch p {
case dbtypes.PoolStatusLive:
return "In Live Ticket Pool"
case dbtypes.PoolStatusVoted:
return "Voted"
case dbtypes.PoolStatusExpired:
switch s {
case dbtypes.TicketUnspent:
return "Expired, Unrevoked"
case... | [
"func",
"TicketStatusText",
"(",
"s",
"dbtypes",
".",
"TicketSpendType",
",",
"p",
"dbtypes",
".",
"TicketPoolStatus",
")",
"string",
"{",
"switch",
"p",
"{",
"case",
"dbtypes",
".",
"PoolStatusLive",
":",
"return",
"\"",
"\"",
"\n",
"case",
"dbtypes",
".",
... | // TicketStatusText generates the text to display on the explorer's transaction
// page for the "POOL STATUS" field. | [
"TicketStatusText",
"generates",
"the",
"text",
"to",
"display",
"on",
"the",
"explorer",
"s",
"transaction",
"page",
"for",
"the",
"POOL",
"STATUS",
"field",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/explorer.go#L159-L186 |
20,159 | decred/dcrdata | explorer/explorer.go | SetDBsSyncing | func (exp *explorerUI) SetDBsSyncing(syncing bool) {
exp.dbsSyncing.Store(syncing)
exp.wsHub.SetDBsSyncing(syncing)
} | go | func (exp *explorerUI) SetDBsSyncing(syncing bool) {
exp.dbsSyncing.Store(syncing)
exp.wsHub.SetDBsSyncing(syncing)
} | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"SetDBsSyncing",
"(",
"syncing",
"bool",
")",
"{",
"exp",
".",
"dbsSyncing",
".",
"Store",
"(",
"syncing",
")",
"\n",
"exp",
".",
"wsHub",
".",
"SetDBsSyncing",
"(",
"syncing",
")",
"\n",
"}"
] | // SetDBsSyncing is a thread-safe way to update dbsSyncing. | [
"SetDBsSyncing",
"is",
"a",
"thread",
"-",
"safe",
"way",
"to",
"update",
"dbsSyncing",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/explorer.go#L230-L233 |
20,160 | decred/dcrdata | explorer/explorer.go | StopWebsocketHub | func (exp *explorerUI) StopWebsocketHub() {
if exp == nil {
return
}
log.Info("Stopping websocket hub.")
exp.wsHub.Stop()
close(exp.xcDone)
} | go | func (exp *explorerUI) StopWebsocketHub() {
if exp == nil {
return
}
log.Info("Stopping websocket hub.")
exp.wsHub.Stop()
close(exp.xcDone)
} | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"StopWebsocketHub",
"(",
")",
"{",
"if",
"exp",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"exp",
".",
"wsHub",
".",
"Stop",
"(",
")",
"\n",
"close",
... | // StopWebsocketHub stops the websocket hub | [
"StopWebsocketHub",
"stops",
"the",
"websocket",
"hub"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/explorer.go#L260-L267 |
20,161 | decred/dcrdata | explorer/explorer.go | Height | func (exp *explorerUI) Height() int64 {
exp.pageData.RLock()
defer exp.pageData.RUnlock()
if exp.pageData.BlockInfo.BlockBasic == nil {
// If exp.pageData.BlockInfo.BlockBasic has not yet been set return:
return -1
}
return exp.pageData.BlockInfo.Height
} | go | func (exp *explorerUI) Height() int64 {
exp.pageData.RLock()
defer exp.pageData.RUnlock()
if exp.pageData.BlockInfo.BlockBasic == nil {
// If exp.pageData.BlockInfo.BlockBasic has not yet been set return:
return -1
}
return exp.pageData.BlockInfo.Height
} | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"Height",
"(",
")",
"int64",
"{",
"exp",
".",
"pageData",
".",
"RLock",
"(",
")",
"\n",
"defer",
"exp",
".",
"pageData",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"exp",
".",
"pageData",
".",
"BlockInfo",
"... | // Height returns the height of the current block data. | [
"Height",
"returns",
"the",
"height",
"of",
"the",
"current",
"block",
"data",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/explorer.go#L375-L385 |
20,162 | decred/dcrdata | explorer/explorer.go | LastBlock | func (exp *explorerUI) LastBlock() (lastBlockHash string, lastBlock int64, lastBlockTime int64) {
exp.pageData.RLock()
defer exp.pageData.RUnlock()
if exp.pageData.BlockInfo.BlockBasic == nil {
// If exp.pageData.BlockInfo.BlockBasic has not yet been set return:
lastBlock, lastBlockTime = -1, -1
return
}
l... | go | func (exp *explorerUI) LastBlock() (lastBlockHash string, lastBlock int64, lastBlockTime int64) {
exp.pageData.RLock()
defer exp.pageData.RUnlock()
if exp.pageData.BlockInfo.BlockBasic == nil {
// If exp.pageData.BlockInfo.BlockBasic has not yet been set return:
lastBlock, lastBlockTime = -1, -1
return
}
l... | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"LastBlock",
"(",
")",
"(",
"lastBlockHash",
"string",
",",
"lastBlock",
"int64",
",",
"lastBlockTime",
"int64",
")",
"{",
"exp",
".",
"pageData",
".",
"RLock",
"(",
")",
"\n",
"defer",
"exp",
".",
"pageData",
... | // LastBlock returns the last block hash, height and time. | [
"LastBlock",
"returns",
"the",
"last",
"block",
"hash",
"height",
"and",
"time",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/explorer.go#L388-L402 |
20,163 | decred/dcrdata | explorer/explorer.go | MempoolID | func (exp *explorerUI) MempoolID() uint64 {
exp.invsMtx.RLock()
defer exp.invsMtx.RUnlock()
return exp.invs.ID()
} | go | func (exp *explorerUI) MempoolID() uint64 {
exp.invsMtx.RLock()
defer exp.invsMtx.RUnlock()
return exp.invs.ID()
} | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"MempoolID",
"(",
")",
"uint64",
"{",
"exp",
".",
"invsMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"exp",
".",
"invsMtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"exp",
".",
"invs",
".",
"ID",
"(",
"... | // MempoolID safely fetches the current mempool inventory ID. | [
"MempoolID",
"safely",
"fetches",
"the",
"current",
"mempool",
"inventory",
"ID",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/explorer.go#L412-L416 |
20,164 | decred/dcrdata | explorer/explorer.go | simulateASR | func (exp *explorerUI) simulateASR(StartingDCRBalance float64, IntegerTicketQty bool,
CurrentStakePercent float64, ActualCoinbase float64, CurrentBlockNum float64,
ActualTicketPrice float64) (ASR float64, ReturnTable string) {
// Calculations are only useful on mainnet. Short circuit calculations if
// on any oth... | go | func (exp *explorerUI) simulateASR(StartingDCRBalance float64, IntegerTicketQty bool,
CurrentStakePercent float64, ActualCoinbase float64, CurrentBlockNum float64,
ActualTicketPrice float64) (ASR float64, ReturnTable string) {
// Calculations are only useful on mainnet. Short circuit calculations if
// on any oth... | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"simulateASR",
"(",
"StartingDCRBalance",
"float64",
",",
"IntegerTicketQty",
"bool",
",",
"CurrentStakePercent",
"float64",
",",
"ActualCoinbase",
"float64",
",",
"CurrentBlockNum",
"float64",
",",
"ActualTicketPrice",
"flo... | // Simulate ticket purchase and re-investment over a full year for a given
// starting amount of DCR and calculation parameters. Generate a TEXT table of
// the simulation results that can optionally be used for future expansion of
// dcrdata functionality. | [
"Simulate",
"ticket",
"purchase",
"and",
"re",
"-",
"investment",
"over",
"a",
"full",
"year",
"for",
"a",
"given",
"starting",
"amount",
"of",
"DCR",
"and",
"calculation",
"parameters",
".",
"Generate",
"a",
"TEXT",
"table",
"of",
"the",
"simulation",
"resu... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/explorer.go#L629-L736 |
20,165 | decred/dcrdata | explorer/explorer.go | mempoolTime | func (exp *explorerUI) mempoolTime(txid string) types.TimeDef {
exp.invsMtx.RLock()
defer exp.invsMtx.RUnlock()
tx, found := exp.invs.Tx(txid)
if !found {
return types.NewTimeDefFromUNIX(0)
}
return types.NewTimeDefFromUNIX(tx.Time)
} | go | func (exp *explorerUI) mempoolTime(txid string) types.TimeDef {
exp.invsMtx.RLock()
defer exp.invsMtx.RUnlock()
tx, found := exp.invs.Tx(txid)
if !found {
return types.NewTimeDefFromUNIX(0)
}
return types.NewTimeDefFromUNIX(tx.Time)
} | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"mempoolTime",
"(",
"txid",
"string",
")",
"types",
".",
"TimeDef",
"{",
"exp",
".",
"invsMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"exp",
".",
"invsMtx",
".",
"RUnlock",
"(",
")",
"\n",
"tx",
",",
"fo... | // mempoolTime is the TimeDef that the transaction was received in DCRData, or
// else a zero-valued TimeDef if no transaction is found. | [
"mempoolTime",
"is",
"the",
"TimeDef",
"that",
"the",
"transaction",
"was",
"received",
"in",
"DCRData",
"or",
"else",
"a",
"zero",
"-",
"valued",
"TimeDef",
"if",
"no",
"transaction",
"is",
"found",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/explorer.go#L795-L803 |
20,166 | decred/dcrdata | semver/semver.go | NewSemver | func NewSemver(major, minor, patch uint32) Semver {
return Semver{major, minor, patch}
} | go | func NewSemver(major, minor, patch uint32) Semver {
return Semver{major, minor, patch}
} | [
"func",
"NewSemver",
"(",
"major",
",",
"minor",
",",
"patch",
"uint32",
")",
"Semver",
"{",
"return",
"Semver",
"{",
"major",
",",
"minor",
",",
"patch",
"}",
"\n",
"}"
] | // NewSemver returns a new Semver with the version major.minor.patch | [
"NewSemver",
"returns",
"a",
"new",
"Semver",
"with",
"the",
"version",
"major",
".",
"minor",
".",
"patch"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/semver/semver.go#L14-L16 |
20,167 | decred/dcrdata | semver/semver.go | Compatible | func Compatible(required, actual Semver) bool {
switch {
case required.major != actual.major:
return false
case required.minor > actual.minor:
return false
case required.minor == actual.minor && required.patch > actual.patch:
return false
default:
return true
}
} | go | func Compatible(required, actual Semver) bool {
switch {
case required.major != actual.major:
return false
case required.minor > actual.minor:
return false
case required.minor == actual.minor && required.patch > actual.patch:
return false
default:
return true
}
} | [
"func",
"Compatible",
"(",
"required",
",",
"actual",
"Semver",
")",
"bool",
"{",
"switch",
"{",
"case",
"required",
".",
"major",
"!=",
"actual",
".",
"major",
":",
"return",
"false",
"\n",
"case",
"required",
".",
"minor",
">",
"actual",
".",
"minor",
... | // Compatible decides if the actual version is compatible with the required one. | [
"Compatible",
"decides",
"if",
"the",
"actual",
"version",
"is",
"compatible",
"with",
"the",
"required",
"one",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/semver/semver.go#L24-L35 |
20,168 | decred/dcrdata | semver/semver.go | AnyCompatible | func AnyCompatible(compatible []Semver, actual Semver) (isApiCompat bool) {
for _, v := range compatible {
if Compatible(v, actual) {
isApiCompat = true
break
}
}
return
} | go | func AnyCompatible(compatible []Semver, actual Semver) (isApiCompat bool) {
for _, v := range compatible {
if Compatible(v, actual) {
isApiCompat = true
break
}
}
return
} | [
"func",
"AnyCompatible",
"(",
"compatible",
"[",
"]",
"Semver",
",",
"actual",
"Semver",
")",
"(",
"isApiCompat",
"bool",
")",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"compatible",
"{",
"if",
"Compatible",
"(",
"v",
",",
"actual",
")",
"{",
"isApiCom... | // AnyCompatible checks if the version is compatible with any versions in a
// slice of versions. | [
"AnyCompatible",
"checks",
"if",
"the",
"version",
"is",
"compatible",
"with",
"any",
"versions",
"in",
"a",
"slice",
"of",
"versions",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/semver/semver.go#L39-L47 |
20,169 | decred/dcrdata | semver/semver.go | Split | func (s *Semver) Split() (uint32, uint32, uint32) {
return s.major, s.minor, s.patch
} | go | func (s *Semver) Split() (uint32, uint32, uint32) {
return s.major, s.minor, s.patch
} | [
"func",
"(",
"s",
"*",
"Semver",
")",
"Split",
"(",
")",
"(",
"uint32",
",",
"uint32",
",",
"uint32",
")",
"{",
"return",
"s",
".",
"major",
",",
"s",
".",
"minor",
",",
"s",
".",
"patch",
"\n",
"}"
] | // Split returns the major, minor and patch version. | [
"Split",
"returns",
"the",
"major",
"minor",
"and",
"patch",
"version",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/semver/semver.go#L54-L56 |
20,170 | decred/dcrdata | gov/politeia/proposals.go | NewProposalsDB | func NewProposalsDB(politeiaURL, dbPath string) (*ProposalDB, error) {
if politeiaURL == "" {
return nil, fmt.Errorf("missing politeia API URL")
}
if dbPath == "" {
return nil, fmt.Errorf("missing db path")
}
_, err := os.Stat(dbPath)
if err != nil && !os.IsNotExist(err) {
return nil, err
}
db, err := ... | go | func NewProposalsDB(politeiaURL, dbPath string) (*ProposalDB, error) {
if politeiaURL == "" {
return nil, fmt.Errorf("missing politeia API URL")
}
if dbPath == "" {
return nil, fmt.Errorf("missing db path")
}
_, err := os.Stat(dbPath)
if err != nil && !os.IsNotExist(err) {
return nil, err
}
db, err := ... | [
"func",
"NewProposalsDB",
"(",
"politeiaURL",
",",
"dbPath",
"string",
")",
"(",
"*",
"ProposalDB",
",",
"error",
")",
"{",
"if",
"politeiaURL",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n... | // NewProposalsDB opens an exiting database or creates a new DB instance with
// the provided file name. Returns an initialized instance of proposals DB, http
// client and the formatted politeia API URL path to be used. It also checks the
// db version, Reindexes the db if need be and sets the required db version. | [
"NewProposalsDB",
"opens",
"an",
"exiting",
"database",
"or",
"creates",
"a",
"new",
"DB",
"instance",
"with",
"the",
"provided",
"file",
"name",
".",
"Returns",
"an",
"initialized",
"instance",
"of",
"proposals",
"DB",
"http",
"client",
"and",
"the",
"formatt... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L51-L114 |
20,171 | decred/dcrdata | gov/politeia/proposals.go | Close | func (db *ProposalDB) Close() error {
if db == nil || db.dbP == nil {
return nil
}
return db.dbP.Close()
} | go | func (db *ProposalDB) Close() error {
if db == nil || db.dbP == nil {
return nil
}
return db.dbP.Close()
} | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"db",
"==",
"nil",
"||",
"db",
".",
"dbP",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"db",
".",
"dbP",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close closes the proposal DB instance created passed if it not nil. | [
"Close",
"closes",
"the",
"proposal",
"DB",
"instance",
"created",
"passed",
"if",
"it",
"not",
"nil",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L117-L123 |
20,172 | decred/dcrdata | gov/politeia/proposals.go | generateCustomID | func generateCustomID(title string) (string, error) {
if title == "" {
return "", fmt.Errorf("ID not generated: invalid title found")
}
// regex selects only the alphanumeric characters.
reg, err := regexp.Compile("[^a-zA-Z0-9]+")
if err != nil {
return "", err
}
// Replace all punctuation marks with a hyph... | go | func generateCustomID(title string) (string, error) {
if title == "" {
return "", fmt.Errorf("ID not generated: invalid title found")
}
// regex selects only the alphanumeric characters.
reg, err := regexp.Compile("[^a-zA-Z0-9]+")
if err != nil {
return "", err
}
// Replace all punctuation marks with a hyph... | [
"func",
"generateCustomID",
"(",
"title",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"title",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"// regex selects only the alp... | // generateCustomID generates a custom ID that is used to reference the proposals
// from the frontend. The ID generated from the title by having all its
// punctuation marks replaced with a hyphen and the string converted to lowercase.
// According to Politeia, a proposal title has a max length of 80 characters thus
/... | [
"generateCustomID",
"generates",
"a",
"custom",
"ID",
"that",
"is",
"used",
"to",
"reference",
"the",
"proposals",
"from",
"the",
"frontend",
".",
"The",
"ID",
"generated",
"from",
"the",
"title",
"by",
"having",
"all",
"its",
"punctuation",
"marks",
"replaced... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L130-L142 |
20,173 | decred/dcrdata | gov/politeia/proposals.go | saveProposals | func (db *ProposalDB) saveProposals(URLParams string) (int, error) {
copyURLParams := URLParams
pageSize := int(piapi.ProposalListPageSize)
var publicProposals pitypes.Proposals
// Since Politeia sets page the limit as piapi.ProposalListPageSize, keep
// fetching the proposals till the count of fetched proposals ... | go | func (db *ProposalDB) saveProposals(URLParams string) (int, error) {
copyURLParams := URLParams
pageSize := int(piapi.ProposalListPageSize)
var publicProposals pitypes.Proposals
// Since Politeia sets page the limit as piapi.ProposalListPageSize, keep
// fetching the proposals till the count of fetched proposals ... | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"saveProposals",
"(",
"URLParams",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"copyURLParams",
":=",
"URLParams",
"\n",
"pageSize",
":=",
"int",
"(",
"piapi",
".",
"ProposalListPageSize",
")",
"\n",
"var",... | // saveProposals adds the proposals data to the db. | [
"saveProposals",
"adds",
"the",
"proposals",
"data",
"to",
"the",
"db",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L145-L211 |
20,174 | decred/dcrdata | gov/politeia/proposals.go | AllProposals | func (db *ProposalDB) AllProposals(offset, rowsCount int,
filterByVoteStatus ...int) (proposals []*pitypes.ProposalInfo,
totalCount int, err error) {
if db == nil || db.dbP == nil {
return nil, 0, errDef
}
db.mtx.RLock()
defer db.mtx.RUnlock()
query := db.dbP.Select()
if len(filterByVoteStatus) > 0 {
// F... | go | func (db *ProposalDB) AllProposals(offset, rowsCount int,
filterByVoteStatus ...int) (proposals []*pitypes.ProposalInfo,
totalCount int, err error) {
if db == nil || db.dbP == nil {
return nil, 0, errDef
}
db.mtx.RLock()
defer db.mtx.RUnlock()
query := db.dbP.Select()
if len(filterByVoteStatus) > 0 {
// F... | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"AllProposals",
"(",
"offset",
",",
"rowsCount",
"int",
",",
"filterByVoteStatus",
"...",
"int",
")",
"(",
"proposals",
"[",
"]",
"*",
"pitypes",
".",
"ProposalInfo",
",",
"totalCount",
"int",
",",
"err",
"error",... | // AllProposals fetches all the proposals data saved to the db. | [
"AllProposals",
"fetches",
"all",
"the",
"proposals",
"data",
"saved",
"to",
"the",
"db",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L214-L248 |
20,175 | decred/dcrdata | gov/politeia/proposals.go | ProposalByToken | func (db *ProposalDB) ProposalByToken(proposalToken string) (*pitypes.ProposalInfo, error) {
if db == nil || db.dbP == nil {
return nil, errDef
}
db.mtx.RLock()
defer db.mtx.RUnlock()
return db.proposal("TokenVal", proposalToken)
} | go | func (db *ProposalDB) ProposalByToken(proposalToken string) (*pitypes.ProposalInfo, error) {
if db == nil || db.dbP == nil {
return nil, errDef
}
db.mtx.RLock()
defer db.mtx.RUnlock()
return db.proposal("TokenVal", proposalToken)
} | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"ProposalByToken",
"(",
"proposalToken",
"string",
")",
"(",
"*",
"pitypes",
".",
"ProposalInfo",
",",
"error",
")",
"{",
"if",
"db",
"==",
"nil",
"||",
"db",
".",
"dbP",
"==",
"nil",
"{",
"return",
"nil",
"... | // ProposalByToken returns the single proposal identified by the provided token. | [
"ProposalByToken",
"returns",
"the",
"single",
"proposal",
"identified",
"by",
"the",
"provided",
"token",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L251-L260 |
20,176 | decred/dcrdata | gov/politeia/proposals.go | ProposalByRefID | func (db *ProposalDB) ProposalByRefID(RefID string) (*pitypes.ProposalInfo, error) {
if db == nil || db.dbP == nil {
return nil, errDef
}
db.mtx.RLock()
defer db.mtx.RUnlock()
return db.proposal("RefID", RefID)
} | go | func (db *ProposalDB) ProposalByRefID(RefID string) (*pitypes.ProposalInfo, error) {
if db == nil || db.dbP == nil {
return nil, errDef
}
db.mtx.RLock()
defer db.mtx.RUnlock()
return db.proposal("RefID", RefID)
} | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"ProposalByRefID",
"(",
"RefID",
"string",
")",
"(",
"*",
"pitypes",
".",
"ProposalInfo",
",",
"error",
")",
"{",
"if",
"db",
"==",
"nil",
"||",
"db",
".",
"dbP",
"==",
"nil",
"{",
"return",
"nil",
",",
"e... | // ProposalByRefID returns the single proposal identified by the provided refID.
// RefID is generated from the proposal name and used as the descriptive part of
// the URL to proposal details page on the | [
"ProposalByRefID",
"returns",
"the",
"single",
"proposal",
"identified",
"by",
"the",
"provided",
"refID",
".",
"RefID",
"is",
"generated",
"from",
"the",
"proposal",
"name",
"and",
"used",
"as",
"the",
"descriptive",
"part",
"of",
"the",
"URL",
"to",
"proposa... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L265-L274 |
20,177 | decred/dcrdata | gov/politeia/proposals.go | proposal | func (db *ProposalDB) proposal(searchBy, searchTerm string) (*pitypes.ProposalInfo, error) {
var pInfo pitypes.ProposalInfo
err := db.dbP.Select(q.Eq(searchBy, searchTerm)).Limit(1).First(&pInfo)
if err != nil {
log.Errorf("Failed to fetch data from Proposals DB: %v", err)
return nil, err
}
return &pInfo, nil... | go | func (db *ProposalDB) proposal(searchBy, searchTerm string) (*pitypes.ProposalInfo, error) {
var pInfo pitypes.ProposalInfo
err := db.dbP.Select(q.Eq(searchBy, searchTerm)).Limit(1).First(&pInfo)
if err != nil {
log.Errorf("Failed to fetch data from Proposals DB: %v", err)
return nil, err
}
return &pInfo, nil... | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"proposal",
"(",
"searchBy",
",",
"searchTerm",
"string",
")",
"(",
"*",
"pitypes",
".",
"ProposalInfo",
",",
"error",
")",
"{",
"var",
"pInfo",
"pitypes",
".",
"ProposalInfo",
"\n",
"err",
":=",
"db",
".",
"d... | // proposal runs the query with searchBy and searchTerm parameters provided and
// returns the result. | [
"proposal",
"runs",
"the",
"query",
"with",
"searchBy",
"and",
"searchTerm",
"parameters",
"provided",
"and",
"returns",
"the",
"result",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L278-L287 |
20,178 | decred/dcrdata | gov/politeia/proposals.go | LastProposalsSync | func (db *ProposalDB) LastProposalsSync() int64 {
db.mtx.Lock()
defer db.mtx.Unlock()
return db.lastSync
} | go | func (db *ProposalDB) LastProposalsSync() int64 {
db.mtx.Lock()
defer db.mtx.Unlock()
return db.lastSync
} | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"LastProposalsSync",
"(",
")",
"int64",
"{",
"db",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"db",
".",
"lastSync",
"\n",
"}"
] | // LastProposalsSync returns the last time a sync to update the proposals was run
// but not necessarily the last time updates were synced in proposals.db. | [
"LastProposalsSync",
"returns",
"the",
"last",
"time",
"a",
"sync",
"to",
"update",
"the",
"proposals",
"was",
"run",
"but",
"not",
"necessarily",
"the",
"last",
"time",
"updates",
"were",
"synced",
"in",
"proposals",
".",
"db",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L291-L296 |
20,179 | decred/dcrdata | gov/politeia/proposals.go | CheckProposalsUpdates | func (db *ProposalDB) CheckProposalsUpdates() error {
if db == nil || db.dbP == nil {
return errDef
}
db.mtx.Lock()
defer func() {
// Update the lastSync before the function exits.
db.lastSync = time.Now().UTC().Unix()
db.mtx.Unlock()
}()
// Retrieve and update all current proposals whose vote statuses... | go | func (db *ProposalDB) CheckProposalsUpdates() error {
if db == nil || db.dbP == nil {
return errDef
}
db.mtx.Lock()
defer func() {
// Update the lastSync before the function exits.
db.lastSync = time.Now().UTC().Unix()
db.mtx.Unlock()
}()
// Retrieve and update all current proposals whose vote statuses... | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"CheckProposalsUpdates",
"(",
")",
"error",
"{",
"if",
"db",
"==",
"nil",
"||",
"db",
".",
"dbP",
"==",
"nil",
"{",
"return",
"errDef",
"\n",
"}",
"\n\n",
"db",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"... | // CheckProposalsUpdates updates the proposal changes if they exist and updates
// them to the proposal db. | [
"CheckProposalsUpdates",
"updates",
"the",
"proposal",
"changes",
"if",
"they",
"exist",
"and",
"updates",
"them",
"to",
"the",
"proposal",
"db",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L300-L343 |
20,180 | decred/dcrdata | gov/politeia/proposals.go | updateInProgressProposals | func (db *ProposalDB) updateInProgressProposals() (int, error) {
// statuses defines a list of vote statuses whose proposals may need an update.
statuses := []pitypes.VoteStatusType{
pitypes.VoteStatusType(piapi.PropVoteStatusNotAuthorized),
pitypes.VoteStatusType(piapi.PropVoteStatusAuthorized),
pitypes.VoteSt... | go | func (db *ProposalDB) updateInProgressProposals() (int, error) {
// statuses defines a list of vote statuses whose proposals may need an update.
statuses := []pitypes.VoteStatusType{
pitypes.VoteStatusType(piapi.PropVoteStatusNotAuthorized),
pitypes.VoteStatusType(piapi.PropVoteStatusAuthorized),
pitypes.VoteSt... | [
"func",
"(",
"db",
"*",
"ProposalDB",
")",
"updateInProgressProposals",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"// statuses defines a list of vote statuses whose proposals may need an update.",
"statuses",
":=",
"[",
"]",
"pitypes",
".",
"VoteStatusType",
"{",
... | // Proposals whose vote statuses are either NotAuthorized, Authorized or Started
// are considered to be in progress. Data for the in progress proposals is
// fetched from Politeia API. From the newly fetched proposals data, db update
// is only made for the vote statuses without NotAuthorized status out of all
// the ... | [
"Proposals",
"whose",
"vote",
"statuses",
"are",
"either",
"NotAuthorized",
"Authorized",
"or",
"Started",
"are",
"considered",
"to",
"be",
"in",
"progress",
".",
"Data",
"for",
"the",
"in",
"progress",
"proposals",
"is",
"fetched",
"from",
"Politeia",
"API",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/proposals.go#L355-L414 |
20,181 | decred/dcrdata | db/dcrpg/system.go | parseUnit | func parseUnit(unit string) (multiple float64, baseUnit string, err error) {
// This regular expression is defined so that it will match any input.
re := regexp.MustCompile(`([-\d\.]*)\s*(.*)`)
matches := re.FindStringSubmatch(unit)
// One or more of the matched substrings may be "", but the base unit
// substring... | go | func parseUnit(unit string) (multiple float64, baseUnit string, err error) {
// This regular expression is defined so that it will match any input.
re := regexp.MustCompile(`([-\d\.]*)\s*(.*)`)
matches := re.FindStringSubmatch(unit)
// One or more of the matched substrings may be "", but the base unit
// substring... | [
"func",
"parseUnit",
"(",
"unit",
"string",
")",
"(",
"multiple",
"float64",
",",
"baseUnit",
"string",
",",
"err",
"error",
")",
"{",
"// This regular expression is defined so that it will match any input.",
"re",
":=",
"regexp",
".",
"MustCompile",
"(",
"`([-\\d\\.]... | // parseUnit is used to separate a "unit" from pg_settings such as "8kB" into a
// numeric component and a base unit string. | [
"parseUnit",
"is",
"used",
"to",
"separate",
"a",
"unit",
"from",
"pg_settings",
"such",
"as",
"8kB",
"into",
"a",
"numeric",
"component",
"and",
"a",
"base",
"unit",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L19-L51 |
20,182 | decred/dcrdata | db/dcrpg/system.go | RetrievePGVersion | func RetrievePGVersion(db *sql.DB) (ver string, err error) {
err = db.QueryRow(internal.RetrievePGVersion).Scan(&ver)
return
} | go | func RetrievePGVersion(db *sql.DB) (ver string, err error) {
err = db.QueryRow(internal.RetrievePGVersion).Scan(&ver)
return
} | [
"func",
"RetrievePGVersion",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"ver",
"string",
",",
"err",
"error",
")",
"{",
"err",
"=",
"db",
".",
"QueryRow",
"(",
"internal",
".",
"RetrievePGVersion",
")",
".",
"Scan",
"(",
"&",
"ver",
")",
"\n",
"re... | // RetrievePGVersion retrieves the version of the connected PostgreSQL server. | [
"RetrievePGVersion",
"retrieves",
"the",
"version",
"of",
"the",
"connected",
"PostgreSQL",
"server",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L145-L148 |
20,183 | decred/dcrdata | db/dcrpg/system.go | RetrieveSysSettingsPerformance | func RetrieveSysSettingsPerformance(db *sql.DB) (PGSettings, error) {
return retrieveSysSettings(internal.RetrieveSysSettingsPerformance, db)
} | go | func RetrieveSysSettingsPerformance(db *sql.DB) (PGSettings, error) {
return retrieveSysSettings(internal.RetrieveSysSettingsPerformance, db)
} | [
"func",
"RetrieveSysSettingsPerformance",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"PGSettings",
",",
"error",
")",
"{",
"return",
"retrieveSysSettings",
"(",
"internal",
".",
"RetrieveSysSettingsPerformance",
",",
"db",
")",
"\n",
"}"
] | // RetrieveSysSettingsPerformance retrieves performance-related settings. | [
"RetrieveSysSettingsPerformance",
"retrieves",
"performance",
"-",
"related",
"settings",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L207-L209 |
20,184 | decred/dcrdata | db/dcrpg/system.go | RetrieveSysSettingSyncCommit | func RetrieveSysSettingSyncCommit(db *sql.DB) (syncCommit string, err error) {
err = db.QueryRow(internal.RetrieveSyncCommitSetting).Scan(&syncCommit)
return
} | go | func RetrieveSysSettingSyncCommit(db *sql.DB) (syncCommit string, err error) {
err = db.QueryRow(internal.RetrieveSyncCommitSetting).Scan(&syncCommit)
return
} | [
"func",
"RetrieveSysSettingSyncCommit",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"syncCommit",
"string",
",",
"err",
"error",
")",
"{",
"err",
"=",
"db",
".",
"QueryRow",
"(",
"internal",
".",
"RetrieveSyncCommitSetting",
")",
".",
"Scan",
"(",
"&",
"... | // RetrieveSysSettingSyncCommit retrieves the synchronous_commit setting. | [
"RetrieveSysSettingSyncCommit",
"retrieves",
"the",
"synchronous_commit",
"setting",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L220-L223 |
20,185 | decred/dcrdata | db/dcrpg/system.go | SetSynchronousCommit | func SetSynchronousCommit(db *sql.DB, syncCommit string) error {
_, err := db.Exec(fmt.Sprintf(`SET synchronous_commit TO %s;`, syncCommit))
return err
} | go | func SetSynchronousCommit(db *sql.DB, syncCommit string) error {
_, err := db.Exec(fmt.Sprintf(`SET synchronous_commit TO %s;`, syncCommit))
return err
} | [
"func",
"SetSynchronousCommit",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"syncCommit",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"db",
".",
"Exec",
"(",
"fmt",
".",
"Sprintf",
"(",
"`SET synchronous_commit TO %s;`",
",",
"syncCommit",
")",
")",
"... | // SetSynchronousCommit sets the synchronous_commit setting. | [
"SetSynchronousCommit",
"sets",
"the",
"synchronous_commit",
"setting",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L226-L229 |
20,186 | decred/dcrdata | db/dcrpg/system.go | CheckCurrentTimeZone | func CheckCurrentTimeZone(db *sql.DB) (currentTZ string, err error) {
if err = db.QueryRow(`SHOW TIME ZONE`).Scan(¤tTZ); err != nil {
err = fmt.Errorf("unable to query current time zone: %v", err)
}
return
} | go | func CheckCurrentTimeZone(db *sql.DB) (currentTZ string, err error) {
if err = db.QueryRow(`SHOW TIME ZONE`).Scan(¤tTZ); err != nil {
err = fmt.Errorf("unable to query current time zone: %v", err)
}
return
} | [
"func",
"CheckCurrentTimeZone",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"currentTZ",
"string",
",",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"db",
".",
"QueryRow",
"(",
"`SHOW TIME ZONE`",
")",
".",
"Scan",
"(",
"&",
"currentTZ",
")",
";",
"er... | // CheckCurrentTimeZone queries for the currently set postgres time zone. | [
"CheckCurrentTimeZone",
"queries",
"for",
"the",
"currently",
"set",
"postgres",
"time",
"zone",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L232-L237 |
20,187 | decred/dcrdata | db/dcrpg/system.go | CheckDefaultTimeZone | func CheckDefaultTimeZone(db *sql.DB) (defaultTZ, currentTZ string, err error) {
// Remember the current time zone before switching to default.
currentTZ, err = CheckCurrentTimeZone(db)
if err != nil {
return
}
// Switch to DEFAULT/LOCAL.
_, err = db.Exec(`SET TIME ZONE DEFAULT`)
if err != nil {
err = fmt.E... | go | func CheckDefaultTimeZone(db *sql.DB) (defaultTZ, currentTZ string, err error) {
// Remember the current time zone before switching to default.
currentTZ, err = CheckCurrentTimeZone(db)
if err != nil {
return
}
// Switch to DEFAULT/LOCAL.
_, err = db.Exec(`SET TIME ZONE DEFAULT`)
if err != nil {
err = fmt.E... | [
"func",
"CheckDefaultTimeZone",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"defaultTZ",
",",
"currentTZ",
"string",
",",
"err",
"error",
")",
"{",
"// Remember the current time zone before switching to default.",
"currentTZ",
",",
"err",
"=",
"CheckCurrentTimeZone",
... | // CheckDefaultTimeZone queries for the default postgres time zone. This is the
// value that would be observed if postgres were restarted using its current
// configuration. The currently set time zone is also returned. | [
"CheckDefaultTimeZone",
"queries",
"for",
"the",
"default",
"postgres",
"time",
"zone",
".",
"This",
"is",
"the",
"value",
"that",
"would",
"be",
"observed",
"if",
"postgres",
"were",
"restarted",
"using",
"its",
"current",
"configuration",
".",
"The",
"currentl... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L242-L268 |
20,188 | decred/dcrdata | signal.go | withShutdownCancel | func withShutdownCancel(ctx context.Context) context.Context {
ctx, cancel := context.WithCancel(ctx)
go func() {
<-shutdownSignal
cancel()
}()
return ctx
} | go | func withShutdownCancel(ctx context.Context) context.Context {
ctx, cancel := context.WithCancel(ctx)
go func() {
<-shutdownSignal
cancel()
}()
return ctx
} | [
"func",
"withShutdownCancel",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"<-",
"shutdownSignal",
"\n",
"cancel"... | // withShutdownCancel creates a copy of a context that is cancelled whenever
// shutdown is invoked through an interrupt signal or from an JSON-RPC stop
// request. | [
"withShutdownCancel",
"creates",
"a",
"copy",
"of",
"a",
"context",
"that",
"is",
"cancelled",
"whenever",
"shutdown",
"is",
"invoked",
"through",
"an",
"interrupt",
"signal",
"or",
"from",
"an",
"JSON",
"-",
"RPC",
"stop",
"request",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/signal.go#L43-L50 |
20,189 | decred/dcrdata | signal.go | shutdownListener | func shutdownListener() {
interruptChannel := make(chan os.Signal, 1)
signal.Notify(interruptChannel, signals...)
// Listen for the initial shutdown signal
select {
case sig := <-interruptChannel:
log.Infof("Received signal (%s). Shutting down...", sig)
case <-shutdownRequest:
log.Info("Shutdown requested. S... | go | func shutdownListener() {
interruptChannel := make(chan os.Signal, 1)
signal.Notify(interruptChannel, signals...)
// Listen for the initial shutdown signal
select {
case sig := <-interruptChannel:
log.Infof("Received signal (%s). Shutting down...", sig)
case <-shutdownRequest:
log.Info("Shutdown requested. S... | [
"func",
"shutdownListener",
"(",
")",
"{",
"interruptChannel",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"signal",
".",
"Notify",
"(",
"interruptChannel",
",",
"signals",
"...",
")",
"\n\n",
"// Listen for the initial shutdown signal",... | // shutdownListener listens for shutdown requests and cancels all contexts
// created from withShutdownCancel. This function never returns and is intended
// to be spawned in a new goroutine. | [
"shutdownListener",
"listens",
"for",
"shutdown",
"requests",
"and",
"cancels",
"all",
"contexts",
"created",
"from",
"withShutdownCancel",
".",
"This",
"function",
"never",
"returns",
"and",
"is",
"intended",
"to",
"be",
"spawned",
"in",
"a",
"new",
"goroutine",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/signal.go#L61-L85 |
20,190 | decred/dcrdata | pubsub/types/pubsub_types.go | IsWSClosedErr | func IsWSClosedErr(err error) (closedErr bool) {
// Must use strings.Contains to catch errors like "write tcp
// 127.0.0.1:7777->127.0.0.1:39196: use of closed network connection".
return err != nil && strings.Contains(err.Error(), ErrWsClosed)
} | go | func IsWSClosedErr(err error) (closedErr bool) {
// Must use strings.Contains to catch errors like "write tcp
// 127.0.0.1:7777->127.0.0.1:39196: use of closed network connection".
return err != nil && strings.Contains(err.Error(), ErrWsClosed)
} | [
"func",
"IsWSClosedErr",
"(",
"err",
"error",
")",
"(",
"closedErr",
"bool",
")",
"{",
"// Must use strings.Contains to catch errors like \"write tcp",
"// 127.0.0.1:7777->127.0.0.1:39196: use of closed network connection\".",
"return",
"err",
"!=",
"nil",
"&&",
"strings",
".",... | // IsWSClosedErr checks if the passed error indicates a closed websocket
// connection. | [
"IsWSClosedErr",
"checks",
"if",
"the",
"passed",
"error",
"indicates",
"a",
"closed",
"websocket",
"connection",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/types/pubsub_types.go#L20-L24 |
20,191 | decred/dcrdata | pubsub/types/pubsub_types.go | IsTemporaryErr | func IsTemporaryErr(err error) bool {
t, ok := err.(net.Error)
return ok && t.Temporary()
} | go | func IsTemporaryErr(err error) bool {
t, ok := err.(net.Error)
return ok && t.Temporary()
} | [
"func",
"IsTemporaryErr",
"(",
"err",
"error",
")",
"bool",
"{",
"t",
",",
"ok",
":=",
"err",
".",
"(",
"net",
".",
"Error",
")",
"\n",
"return",
"ok",
"&&",
"t",
".",
"Temporary",
"(",
")",
"\n",
"}"
] | // IsTemporaryErr checks if the passed error indicates a transient error. | [
"IsTemporaryErr",
"checks",
"if",
"the",
"passed",
"error",
"indicates",
"a",
"transient",
"error",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/types/pubsub_types.go#L33-L36 |
20,192 | decred/dcrdata | mempool/mptypes.go | Swap | func (tix TicketsDetails) Swap(i, j int) {
tix[i], tix[j] = tix[j], tix[i]
} | go | func (tix TicketsDetails) Swap(i, j int) {
tix[i], tix[j] = tix[j], tix[i]
} | [
"func",
"(",
"tix",
"TicketsDetails",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"tix",
"[",
"i",
"]",
",",
"tix",
"[",
"j",
"]",
"=",
"tix",
"[",
"j",
"]",
",",
"tix",
"[",
"i",
"]",
"\n",
"}"
] | // Swap swaps TicketsDetails elements at i and j | [
"Swap",
"swaps",
"TicketsDetails",
"elements",
"at",
"i",
"and",
"j"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mptypes.go#L55-L57 |
20,193 | decred/dcrdata | mempool/mptypes.go | Less | func (tix ByFeeRate) Less(i, j int) bool {
return tix.TicketsDetails[i].FeeRate < tix.TicketsDetails[j].FeeRate
} | go | func (tix ByFeeRate) Less(i, j int) bool {
return tix.TicketsDetails[i].FeeRate < tix.TicketsDetails[j].FeeRate
} | [
"func",
"(",
"tix",
"ByFeeRate",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"tix",
".",
"TicketsDetails",
"[",
"i",
"]",
".",
"FeeRate",
"<",
"tix",
".",
"TicketsDetails",
"[",
"j",
"]",
".",
"FeeRate",
"\n",
"}"
] | // Less compares fee rates by rate_i < rate_j | [
"Less",
"compares",
"fee",
"rates",
"by",
"rate_i",
"<",
"rate_j"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mptypes.go#L65-L67 |
20,194 | decred/dcrdata | mempool/mptypes.go | Less | func (tix ByAbsoluteFee) Less(i, j int) bool {
return tix.TicketsDetails[i].Fee < tix.TicketsDetails[j].Fee
} | go | func (tix ByAbsoluteFee) Less(i, j int) bool {
return tix.TicketsDetails[i].Fee < tix.TicketsDetails[j].Fee
} | [
"func",
"(",
"tix",
"ByAbsoluteFee",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"tix",
".",
"TicketsDetails",
"[",
"i",
"]",
".",
"Fee",
"<",
"tix",
".",
"TicketsDetails",
"[",
"j",
"]",
".",
"Fee",
"\n",
"}"
] | // Less compares fee rates by fee_i < fee_j | [
"Less",
"compares",
"fee",
"rates",
"by",
"fee_i",
"<",
"fee_j"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mptypes.go#L75-L77 |
20,195 | decred/dcrdata | db/dcrsqlite/sqlite.go | InitDB | func InitDB(dbInfo *DBInfo, shutdown func()) (*DB, error) {
dbPath, err := filepath.Abs(dbInfo.FileName)
if err != nil {
return nil, err
}
// Ensures target DB-file has a parent folder
parent := filepath.Dir(dbPath)
err = os.MkdirAll(parent, 0755)
if err != nil {
return nil, err
}
// "shared-cache" mode ... | go | func InitDB(dbInfo *DBInfo, shutdown func()) (*DB, error) {
dbPath, err := filepath.Abs(dbInfo.FileName)
if err != nil {
return nil, err
}
// Ensures target DB-file has a parent folder
parent := filepath.Dir(dbPath)
err = os.MkdirAll(parent, 0755)
if err != nil {
return nil, err
}
// "shared-cache" mode ... | [
"func",
"InitDB",
"(",
"dbInfo",
"*",
"DBInfo",
",",
"shutdown",
"func",
"(",
")",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"dbPath",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"dbInfo",
".",
"FileName",
")",
"\n",
"if",
"err",
"!=",
"nil... | // InitDB creates a new DB instance from a DBInfo containing the name of the
// file used to back the underlying sql database. | [
"InitDB",
"creates",
"a",
"new",
"DB",
"instance",
"from",
"a",
"DBInfo",
"containing",
"the",
"name",
"of",
"the",
"file",
"used",
"to",
"back",
"the",
"underlying",
"sql",
"database",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L324-L433 |
20,196 | decred/dcrdata | db/dcrsqlite/sqlite.go | Store | func (db *DBDataSaver) Store(data *blockdata.BlockData, msgBlock *wire.MsgBlock) error {
summary := data.ToBlockSummary()
var err error
// Store is assumed to be called with a mainchain block
lastIsValid := msgBlock.Header.VoteBits&1 != 0
if !lastIsValid {
// Update the is_valid flag in the blocks table.
// N... | go | func (db *DBDataSaver) Store(data *blockdata.BlockData, msgBlock *wire.MsgBlock) error {
summary := data.ToBlockSummary()
var err error
// Store is assumed to be called with a mainchain block
lastIsValid := msgBlock.Header.VoteBits&1 != 0
if !lastIsValid {
// Update the is_valid flag in the blocks table.
// N... | [
"func",
"(",
"db",
"*",
"DBDataSaver",
")",
"Store",
"(",
"data",
"*",
"blockdata",
".",
"BlockData",
",",
"msgBlock",
"*",
"wire",
".",
"MsgBlock",
")",
"error",
"{",
"summary",
":=",
"data",
".",
"ToBlockSummary",
"(",
")",
"\n",
"var",
"err",
"error... | // Store satisfies the blockdata.BlockDataSaver interface. This function is only
// to be used for storing main chain block data. Use StoreSideBlock or
// StoreBlock directly to store side chain block data. | [
"Store",
"satisfies",
"the",
"blockdata",
".",
"BlockDataSaver",
"interface",
".",
"This",
"function",
"is",
"only",
"to",
"be",
"used",
"for",
"storing",
"main",
"chain",
"block",
"data",
".",
"Use",
"StoreSideBlock",
"or",
"StoreBlock",
"directly",
"to",
"st... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L459-L505 |
20,197 | decred/dcrdata | db/dcrsqlite/sqlite.go | DeleteBlock | func (db *DB) DeleteBlock(blockhash string) (NSummaryRows, NStakeInfoRows int64, err error) {
// Attempt to purge the block data.
NSummaryRows, NStakeInfoRows, err = db.deleteBlock(blockhash)
if err != nil {
return
}
err = db.updateHeights()
return
} | go | func (db *DB) DeleteBlock(blockhash string) (NSummaryRows, NStakeInfoRows int64, err error) {
// Attempt to purge the block data.
NSummaryRows, NStakeInfoRows, err = db.deleteBlock(blockhash)
if err != nil {
return
}
err = db.updateHeights()
return
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"DeleteBlock",
"(",
"blockhash",
"string",
")",
"(",
"NSummaryRows",
",",
"NStakeInfoRows",
"int64",
",",
"err",
"error",
")",
"{",
"// Attempt to purge the block data.",
"NSummaryRows",
",",
"NStakeInfoRows",
",",
"err",
"=",
... | // DeleteBlock purges the summary data and stake info for the block with the
// given hash. The number of rows deleted is returned. | [
"DeleteBlock",
"purges",
"the",
"summary",
"data",
"and",
"stake",
"info",
"for",
"the",
"block",
"with",
"the",
"given",
"hash",
".",
"The",
"number",
"of",
"rows",
"deleted",
"is",
"returned",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L565-L574 |
20,198 | decred/dcrdata | db/dcrsqlite/sqlite.go | DeleteBlocksAboveHeight | func (db *DB) DeleteBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error) {
// Attempt to purge the block data.
NSummaryRows, NStakeInfoRows, err = db.deleteBlocksAboveHeight(height)
if err != nil {
return
}
err = db.updateHeights()
return
} | go | func (db *DB) DeleteBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error) {
// Attempt to purge the block data.
NSummaryRows, NStakeInfoRows, err = db.deleteBlocksAboveHeight(height)
if err != nil {
return
}
err = db.updateHeights()
return
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"DeleteBlocksAboveHeight",
"(",
"height",
"int64",
")",
"(",
"NSummaryRows",
",",
"NStakeInfoRows",
"int64",
",",
"err",
"error",
")",
"{",
"// Attempt to purge the block data.",
"NSummaryRows",
",",
"NStakeInfoRows",
",",
"err",... | // DeleteBlocksAboveHeight purges the summary data and stake info for the blocks
// above the given height, including side chain blocks. | [
"DeleteBlocksAboveHeight",
"purges",
"the",
"summary",
"data",
"and",
"stake",
"info",
"for",
"the",
"blocks",
"above",
"the",
"given",
"height",
"including",
"side",
"chain",
"blocks",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L610-L619 |
20,199 | decred/dcrdata | db/dcrsqlite/sqlite.go | invalidateBlock | func (db *DB) invalidateBlock(blockhash string) error {
_, err := db.Exec(db.invalidateBlockSQL, blockhash)
return db.filterError(err)
} | go | func (db *DB) invalidateBlock(blockhash string) error {
_, err := db.Exec(db.invalidateBlockSQL, blockhash)
return db.filterError(err)
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"invalidateBlock",
"(",
"blockhash",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"db",
".",
"Exec",
"(",
"db",
".",
"invalidateBlockSQL",
",",
"blockhash",
")",
"\n",
"return",
"db",
".",
"filterError",
"(",
... | // Invalidate block with the given hash. | [
"Invalidate",
"block",
"with",
"the",
"given",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L632-L635 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.