id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
141,800 | decred/dcrdata | main.go | FileServer | func FileServer(r chi.Router, pathRoot, fsRoot string, cacheControlMaxAge int64) {
if strings.ContainsAny(pathRoot, "{}*") {
panic("FileServer does not permit URL parameters.")
}
// Define a http.HandlerFunc to serve files but not directory indexes.
hf := func(w http.ResponseWriter, r *http.Request) {
// Ensur... | go | func FileServer(r chi.Router, pathRoot, fsRoot string, cacheControlMaxAge int64) {
if strings.ContainsAny(pathRoot, "{}*") {
panic("FileServer does not permit URL parameters.")
}
// Define a http.HandlerFunc to serve files but not directory indexes.
hf := func(w http.ResponseWriter, r *http.Request) {
// Ensur... | [
"func",
"FileServer",
"(",
"r",
"chi",
".",
"Router",
",",
"pathRoot",
",",
"fsRoot",
"string",
",",
"cacheControlMaxAge",
"int64",
")",
"{",
"if",
"strings",
".",
"ContainsAny",
"(",
"pathRoot",
",",
"\"",
"\"",
")",
"{",
"panic",
"(",
"\"",
"\"",
")"... | // FileServer conveniently sets up a http.FileServer handler to serve static
// files from path on the file system. Directory listings are denied, as are URL
// paths containing "..". | [
"FileServer",
"conveniently",
"sets",
"up",
"a",
"http",
".",
"FileServer",
"handler",
"to",
"serve",
"static",
"files",
"from",
"path",
"on",
"the",
"file",
"system",
".",
"Directory",
"listings",
"are",
"denied",
"as",
"are",
"URL",
"paths",
"containing",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/main.go#L1350-L1404 |
141,801 | decred/dcrdata | api/insight/apimiddleware.go | StatusInfoCtx | func (iapi *InsightApi) StatusInfoCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := m.StatusInfoCtx(r, iapi.BlockData.ChainDB)
next.ServeHTTP(w, r.WithContext(ctx))
})
} | go | func (iapi *InsightApi) StatusInfoCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := m.StatusInfoCtx(r, iapi.BlockData.ChainDB)
next.ServeHTTP(w, r.WithContext(ctx))
})
} | [
"func",
"(",
"iapi",
"*",
"InsightApi",
")",
"StatusInfoCtx",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",... | // StatusInfoCtx is a middleware that embeds into the request context the data
// for the "?q=x" URL query, where x is "getInfo" or "getDifficulty" or
// "getBestBlockHash" or "getLastBlockHash". | [
"StatusInfoCtx",
"is",
"a",
"middleware",
"that",
"embeds",
"into",
"the",
"request",
"context",
"the",
"data",
"for",
"the",
"?q",
"=",
"x",
"URL",
"query",
"where",
"x",
"is",
"getInfo",
"or",
"getDifficulty",
"or",
"getBestBlockHash",
"or",
"getLastBlockHas... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L46-L52 |
141,802 | decred/dcrdata | api/insight/apimiddleware.go | ValidatePostCtx | func (iapi *InsightApi) ValidatePostCtx(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 {
writeInsightError(w, "Content-Length He... | go | func (iapi *InsightApi) ValidatePostCtx(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 {
writeInsightError(w, "Content-Length He... | [
"func",
"(",
"iapi",
"*",
"InsightApi",
")",
"ValidatePostCtx",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".... | // ValidatePostCtx will confirm Post content length is valid. | [
"ValidatePostCtx",
"will",
"confirm",
"Post",
"content",
"length",
"is",
"valid",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L148-L166 |
141,803 | decred/dcrdata | api/insight/apimiddleware.go | PostAddrsTxsCtx | func PostAddrsTxsCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var req apitypes.InsightMultiAddrsTx
var from, to, noAsm, noScriptSig, noSpent int64
body, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
writeInsightError(w, fmt.Sp... | go | func PostAddrsTxsCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var req apitypes.InsightMultiAddrsTx
var from, to, noAsm, noScriptSig, noSpent int64
body, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
writeInsightError(w, fmt.Sp... | [
"func",
"PostAddrsTxsCtx",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"var",
"req",... | // PostAddrsTxsCtx middleware processes parameters given in the POST request
// body for an addrs endpoint. | [
"PostAddrsTxsCtx",
"middleware",
"processes",
"parameters",
"given",
"in",
"the",
"POST",
"request",
"body",
"for",
"an",
"addrs",
"endpoint",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L170-L223 |
141,804 | decred/dcrdata | api/insight/apimiddleware.go | PostAddrsUtxoCtx | func PostAddrsUtxoCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
req := apitypes.InsightAddr{}
body, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
writeInsightError(w, fmt.Sprintf("error reading JSON message: %v", err))
return
... | go | func PostAddrsUtxoCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
req := apitypes.InsightAddr{}
body, err := ioutil.ReadAll(r.Body)
r.Body.Close()
if err != nil {
writeInsightError(w, fmt.Sprintf("error reading JSON message: %v", err))
return
... | [
"func",
"PostAddrsUtxoCtx",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"req",
":=",... | // PostAddrsUtxoCtx middleware processes parameters given in the POST request
// body for an addrs utxo endpoint. | [
"PostAddrsUtxoCtx",
"middleware",
"processes",
"parameters",
"given",
"in",
"the",
"POST",
"request",
"body",
"for",
"an",
"addrs",
"utxo",
"endpoint",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L227-L248 |
141,805 | decred/dcrdata | api/insight/apimiddleware.go | GetAddressCommandCtx | func GetAddressCommandCtx(r *http.Request) (string, bool) {
command, ok := r.Context().Value(ctxAddrCmd).(string)
if !ok {
return "", false
}
return command, true
} | go | func GetAddressCommandCtx(r *http.Request) (string, bool) {
command, ok := r.Context().Value(ctxAddrCmd).(string)
if !ok {
return "", false
}
return command, true
} | [
"func",
"GetAddressCommandCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"string",
",",
"bool",
")",
"{",
"command",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxAddrCmd",
")",
".",
"(",
"string",
")",
"\n",
"if",
... | // GetAddressCommandCtx retrieves the ctxAddrCmd data from the request context.
// If not set the return value is "" and false. | [
"GetAddressCommandCtx",
"retrieves",
"the",
"ctxAddrCmd",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"and",
"false",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L262-L268 |
141,806 | decred/dcrdata | api/insight/apimiddleware.go | GetLimitCtx | func GetLimitCtx(r *http.Request) int {
limit, ok := r.Context().Value(m.CtxLimit).(string)
if !ok {
return 0
}
intValue, err := strconv.Atoi(limit)
if err != nil {
return 0
}
return intValue
} | go | func GetLimitCtx(r *http.Request) int {
limit, ok := r.Context().Value(m.CtxLimit).(string)
if !ok {
return 0
}
intValue, err := strconv.Atoi(limit)
if err != nil {
return 0
}
return intValue
} | [
"func",
"GetLimitCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"int",
"{",
"limit",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"m",
".",
"CtxLimit",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",... | // GetLimitCtx retrieves the ctxLimit data from the request context. If not set,
// the return value is 0 which is interpreted as no limit. | [
"GetLimitCtx",
"retrieves",
"the",
"ctxLimit",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"0",
"which",
"is",
"interpreted",
"as",
"no",
"limit",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L286-L296 |
141,807 | decred/dcrdata | api/insight/apimiddleware.go | GetNbBlocksCtx | func GetNbBlocksCtx(r *http.Request) int {
nbBlocks, ok := r.Context().Value(ctxNbBlocks).(int)
if !ok {
return 0
}
return nbBlocks
} | go | func GetNbBlocksCtx(r *http.Request) int {
nbBlocks, ok := r.Context().Value(ctxNbBlocks).(int)
if !ok {
return 0
}
return nbBlocks
} | [
"func",
"GetNbBlocksCtx",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"int",
"{",
"nbBlocks",
",",
"ok",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"ctxNbBlocks",
")",
".",
"(",
"int",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"0",
... | // GetNbBlocksCtx retrieves the ctxNbBlocks data from the request context. If not
// set, the return value is 0. | [
"GetNbBlocksCtx",
"retrieves",
"the",
"ctxNbBlocks",
"data",
"from",
"the",
"request",
"context",
".",
"If",
"not",
"set",
"the",
"return",
"value",
"is",
"0",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L322-L328 |
141,808 | decred/dcrdata | api/insight/apimiddleware.go | NbBlocksCtx | func NbBlocksCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
nbBlocks := r.FormValue("nbBlocks")
nbBlocksint, err := strconv.Atoi(nbBlocks)
if err == nil {
ctx = context.WithValue(r.Context(), ctxNbBlocks, nbBlocksint)
}
nex... | go | func NbBlocksCtx(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
nbBlocks := r.FormValue("nbBlocks")
nbBlocksint, err := strconv.Atoi(nbBlocks)
if err == nil {
ctx = context.WithValue(r.Context(), ctxNbBlocks, nbBlocksint)
}
nex... | [
"func",
"NbBlocksCtx",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"ctx",
":=",
"r... | // NbBlocksCtx will parse the query parameters for nbBlocks. | [
"NbBlocksCtx",
"will",
"parse",
"the",
"query",
"parameters",
"for",
"nbBlocks",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L331-L341 |
141,809 | decred/dcrdata | mempool/monitor.go | NewMempoolMonitor | func NewMempoolMonitor(ctx context.Context, collector *MempoolDataCollector,
savers []MempoolDataSaver, params *chaincfg.Params, wg *sync.WaitGroup,
newTxInChan <-chan *dcrjson.TxRawResult, signalOuts []chan<- pstypes.HubMessage,
initialStore bool) (*MempoolMonitor, error) {
// Make the skeleton MempoolMonitor.
p... | go | func NewMempoolMonitor(ctx context.Context, collector *MempoolDataCollector,
savers []MempoolDataSaver, params *chaincfg.Params, wg *sync.WaitGroup,
newTxInChan <-chan *dcrjson.TxRawResult, signalOuts []chan<- pstypes.HubMessage,
initialStore bool) (*MempoolMonitor, error) {
// Make the skeleton MempoolMonitor.
p... | [
"func",
"NewMempoolMonitor",
"(",
"ctx",
"context",
".",
"Context",
",",
"collector",
"*",
"MempoolDataCollector",
",",
"savers",
"[",
"]",
"MempoolDataSaver",
",",
"params",
"*",
"chaincfg",
".",
"Params",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"new... | // NewMempoolMonitor creates a new MempoolMonitor. The MempoolMonitor receives
// notifications of new transactions on newTxInChan, and of new blocks on the
// same channel using a nil transaction message. Once TxHandler is started, the
// MempoolMonitor will process incoming transactions, and forward new ones on
// vi... | [
"NewMempoolMonitor",
"creates",
"a",
"new",
"MempoolMonitor",
".",
"The",
"MempoolMonitor",
"receives",
"notifications",
"of",
"new",
"transactions",
"on",
"newTxInChan",
"and",
"of",
"new",
"blocks",
"on",
"the",
"same",
"channel",
"using",
"a",
"nil",
"transacti... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L72-L93 |
141,810 | decred/dcrdata | mempool/monitor.go | LastBlockHash | func (p *MempoolMonitor) LastBlockHash() chainhash.Hash {
p.mtx.RLock()
defer p.mtx.RUnlock()
return p.lastBlock.Hash
} | go | func (p *MempoolMonitor) LastBlockHash() chainhash.Hash {
p.mtx.RLock()
defer p.mtx.RUnlock()
return p.lastBlock.Hash
} | [
"func",
"(",
"p",
"*",
"MempoolMonitor",
")",
"LastBlockHash",
"(",
")",
"chainhash",
".",
"Hash",
"{",
"p",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"p",
".",
"lastBlock",
".",
... | // LastBlockHash returns the hash of the most recently stored block. | [
"LastBlockHash",
"returns",
"the",
"hash",
"of",
"the",
"most",
"recently",
"stored",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L96-L100 |
141,811 | decred/dcrdata | mempool/monitor.go | LastBlockHeight | func (p *MempoolMonitor) LastBlockHeight() int64 {
p.mtx.RLock()
defer p.mtx.RUnlock()
return p.lastBlock.Height
} | go | func (p *MempoolMonitor) LastBlockHeight() int64 {
p.mtx.RLock()
defer p.mtx.RUnlock()
return p.lastBlock.Height
} | [
"func",
"(",
"p",
"*",
"MempoolMonitor",
")",
"LastBlockHeight",
"(",
")",
"int64",
"{",
"p",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"p",
".",
"lastBlock",
".",
"Height",
"\n",
... | // LastBlockHeight returns the height of the most recently stored block. | [
"LastBlockHeight",
"returns",
"the",
"height",
"of",
"the",
"most",
"recently",
"stored",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L103-L107 |
141,812 | decred/dcrdata | mempool/monitor.go | LastBlockTime | func (p *MempoolMonitor) LastBlockTime() int64 {
p.mtx.RLock()
defer p.mtx.RUnlock()
return p.lastBlock.Time
} | go | func (p *MempoolMonitor) LastBlockTime() int64 {
p.mtx.RLock()
defer p.mtx.RUnlock()
return p.lastBlock.Time
} | [
"func",
"(",
"p",
"*",
"MempoolMonitor",
")",
"LastBlockTime",
"(",
")",
"int64",
"{",
"p",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"p",
".",
"lastBlock",
".",
"Time",
"\n",
"}... | // LastBlockTime returns the time of the most recently stored block. | [
"LastBlockTime",
"returns",
"the",
"time",
"of",
"the",
"most",
"recently",
"stored",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L110-L114 |
141,813 | decred/dcrdata | mempool/monitor.go | Refresh | func (p *MempoolMonitor) Refresh() (*StakeData, []exptypes.MempoolTx, *exptypes.MempoolInfo, error) {
// Collect mempool data (currently ticket fees)
log.Trace("Gathering new mempool data.")
stakeData, txs, addrOuts, txnsStore, err := p.collector.Collect()
if err != nil {
log.Errorf("mempool data collection faile... | go | func (p *MempoolMonitor) Refresh() (*StakeData, []exptypes.MempoolTx, *exptypes.MempoolInfo, error) {
// Collect mempool data (currently ticket fees)
log.Trace("Gathering new mempool data.")
stakeData, txs, addrOuts, txnsStore, err := p.collector.Collect()
if err != nil {
log.Errorf("mempool data collection faile... | [
"func",
"(",
"p",
"*",
"MempoolMonitor",
")",
"Refresh",
"(",
")",
"(",
"*",
"StakeData",
",",
"[",
"]",
"exptypes",
".",
"MempoolTx",
",",
"*",
"exptypes",
".",
"MempoolInfo",
",",
"error",
")",
"{",
"// Collect mempool data (currently ticket fees)",
"log",
... | // Refresh collects mempool data, resets counters ticket counters and the timer,
// but does not dispatch the MempoolDataSavers. | [
"Refresh",
"collects",
"mempool",
"data",
"resets",
"counters",
"ticket",
"counters",
"and",
"the",
"timer",
"but",
"does",
"not",
"dispatch",
"the",
"MempoolDataSavers",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L368-L412 |
141,814 | decred/dcrdata | mempool/monitor.go | CollectAndStore | func (p *MempoolMonitor) CollectAndStore() error {
log.Trace("Gathering new mempool data.")
stakeData, txs, inv, err := p.Refresh()
if err != nil {
log.Errorf("mempool data collection failed: %v", err.Error())
// stakeData is nil when err != nil
return err
}
// Store mempool stakeData with each registered s... | go | func (p *MempoolMonitor) CollectAndStore() error {
log.Trace("Gathering new mempool data.")
stakeData, txs, inv, err := p.Refresh()
if err != nil {
log.Errorf("mempool data collection failed: %v", err.Error())
// stakeData is nil when err != nil
return err
}
// Store mempool stakeData with each registered s... | [
"func",
"(",
"p",
"*",
"MempoolMonitor",
")",
"CollectAndStore",
"(",
")",
"error",
"{",
"log",
".",
"Trace",
"(",
"\"",
"\"",
")",
"\n",
"stakeData",
",",
"txs",
",",
"inv",
",",
"err",
":=",
"p",
".",
"Refresh",
"(",
")",
"\n",
"if",
"err",
"!=... | // CollectAndStore collects mempool data, resets counters ticket counters and
// the timer, and dispatches the storers. | [
"CollectAndStore",
"collects",
"mempool",
"data",
"resets",
"counters",
"ticket",
"counters",
"and",
"the",
"timer",
"and",
"dispatches",
"the",
"storers",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L416-L437 |
141,815 | decred/dcrdata | explorer/types/explorertypes.go | BlocksToTicketMaturity | func (t *TxInfo) BlocksToTicketMaturity() (blocks int64) {
if t.Type != "Ticket" {
return
}
if t.Mature == "True" {
return
}
return t.TicketInfo.TicketMaturity + 1 - t.Confirmations
} | go | func (t *TxInfo) BlocksToTicketMaturity() (blocks int64) {
if t.Type != "Ticket" {
return
}
if t.Mature == "True" {
return
}
return t.TicketInfo.TicketMaturity + 1 - t.Confirmations
} | [
"func",
"(",
"t",
"*",
"TxInfo",
")",
"BlocksToTicketMaturity",
"(",
")",
"(",
"blocks",
"int64",
")",
"{",
"if",
"t",
".",
"Type",
"!=",
"\"",
"\"",
"{",
"return",
"\n",
"}",
"\n",
"if",
"t",
".",
"Mature",
"==",
"\"",
"\"",
"{",
"return",
"\n",... | // BlocksToTicketMaturity will return 0 if this isn't an immature ticket. | [
"BlocksToTicketMaturity",
"will",
"return",
"0",
"if",
"this",
"isn",
"t",
"an",
"immature",
"ticket",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L227-L235 |
141,816 | decred/dcrdata | explorer/types/explorertypes.go | VotesOnBlock | func (vi *VoteInfo) VotesOnBlock(blockHash string) bool {
return vi.Validation.ForBlock(blockHash)
} | go | func (vi *VoteInfo) VotesOnBlock(blockHash string) bool {
return vi.Validation.ForBlock(blockHash)
} | [
"func",
"(",
"vi",
"*",
"VoteInfo",
")",
"VotesOnBlock",
"(",
"blockHash",
"string",
")",
"bool",
"{",
"return",
"vi",
".",
"Validation",
".",
"ForBlock",
"(",
"blockHash",
")",
"\n",
"}"
] | // VotesOnBlock indicates if the vote is voting on the validity of block
// specified by the given hash. | [
"VotesOnBlock",
"indicates",
"if",
"the",
"vote",
"is",
"voting",
"on",
"the",
"validity",
"of",
"block",
"specified",
"by",
"the",
"given",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L318-L320 |
141,817 | decred/dcrdata | explorer/types/explorertypes.go | ForBlock | func (v *BlockValidation) ForBlock(blockHash string) bool {
return blockHash != "" && blockHash == v.Hash
} | go | func (v *BlockValidation) ForBlock(blockHash string) bool {
return blockHash != "" && blockHash == v.Hash
} | [
"func",
"(",
"v",
"*",
"BlockValidation",
")",
"ForBlock",
"(",
"blockHash",
"string",
")",
"bool",
"{",
"return",
"blockHash",
"!=",
"\"",
"\"",
"&&",
"blockHash",
"==",
"v",
".",
"Hash",
"\n",
"}"
] | // ForBlock indicates if the validation choice is for the specified block. | [
"ForBlock",
"indicates",
"if",
"the",
"validation",
"choice",
"is",
"for",
"the",
"specified",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L323-L325 |
141,818 | decred/dcrdata | explorer/types/explorertypes.go | DeepCopy | func (mpi *MempoolInfo) DeepCopy() *MempoolInfo {
if mpi == nil {
return nil
}
mpi.RLock()
defer mpi.RUnlock()
out := new(MempoolInfo)
out.Transactions = CopyMempoolTxSlice(mpi.Transactions)
out.Tickets = CopyMempoolTxSlice(mpi.Tickets)
out.Votes = CopyMempoolTxSlice(mpi.Votes)
out.Revocations = CopyMempoo... | go | func (mpi *MempoolInfo) DeepCopy() *MempoolInfo {
if mpi == nil {
return nil
}
mpi.RLock()
defer mpi.RUnlock()
out := new(MempoolInfo)
out.Transactions = CopyMempoolTxSlice(mpi.Transactions)
out.Tickets = CopyMempoolTxSlice(mpi.Tickets)
out.Votes = CopyMempoolTxSlice(mpi.Votes)
out.Revocations = CopyMempoo... | [
"func",
"(",
"mpi",
"*",
"MempoolInfo",
")",
"DeepCopy",
"(",
")",
"*",
"MempoolInfo",
"{",
"if",
"mpi",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"mpi",
".",
"RLock",
"(",
")",
"\n",
"defer",
"mpi",
".",
"RUnlock",
"(",
")",
"\n\n",
... | // DeepCopy makes a deep copy of MempoolInfo, where all the slice and map data
// are copied over. | [
"DeepCopy",
"makes",
"a",
"deep",
"copy",
"of",
"MempoolInfo",
"where",
"all",
"the",
"slice",
"and",
"map",
"data",
"are",
"copied",
"over",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L449-L467 |
141,819 | decred/dcrdata | explorer/types/explorertypes.go | Trim | func (mpi *MempoolInfo) Trim() *TrimmedMempoolInfo {
mpi.RLock()
mempoolRegularTxs := TrimMempoolTx(mpi.Transactions)
mempoolVotes := TrimMempoolTx(mpi.Votes)
data := &TrimmedMempoolInfo{
Transactions: FilterRegularTx(mempoolRegularTxs),
Tickets: TrimMempoolTx(mpi.Tickets),
Votes: FilterUniqueLa... | go | func (mpi *MempoolInfo) Trim() *TrimmedMempoolInfo {
mpi.RLock()
mempoolRegularTxs := TrimMempoolTx(mpi.Transactions)
mempoolVotes := TrimMempoolTx(mpi.Votes)
data := &TrimmedMempoolInfo{
Transactions: FilterRegularTx(mempoolRegularTxs),
Tickets: TrimMempoolTx(mpi.Tickets),
Votes: FilterUniqueLa... | [
"func",
"(",
"mpi",
"*",
"MempoolInfo",
")",
"Trim",
"(",
")",
"*",
"TrimmedMempoolInfo",
"{",
"mpi",
".",
"RLock",
"(",
")",
"\n\n",
"mempoolRegularTxs",
":=",
"TrimMempoolTx",
"(",
"mpi",
".",
"Transactions",
")",
"\n",
"mempoolVotes",
":=",
"TrimMempoolTx... | // Trim converts the MempoolInfo to TrimmedMempoolInfo. | [
"Trim",
"converts",
"the",
"MempoolInfo",
"to",
"TrimmedMempoolInfo",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L470-L501 |
141,820 | decred/dcrdata | explorer/types/explorertypes.go | getTxFromList | func getTxFromList(txid string, txns []MempoolTx) (MempoolTx, bool) {
for idx := range txns {
if txns[idx].TxID == txid {
return txns[idx], true
}
}
return MempoolTx{}, false
} | go | func getTxFromList(txid string, txns []MempoolTx) (MempoolTx, bool) {
for idx := range txns {
if txns[idx].TxID == txid {
return txns[idx], true
}
}
return MempoolTx{}, false
} | [
"func",
"getTxFromList",
"(",
"txid",
"string",
",",
"txns",
"[",
"]",
"MempoolTx",
")",
"(",
"MempoolTx",
",",
"bool",
")",
"{",
"for",
"idx",
":=",
"range",
"txns",
"{",
"if",
"txns",
"[",
"idx",
"]",
".",
"TxID",
"==",
"txid",
"{",
"return",
"tx... | // getTxFromList is a helper function for searching the MempoolInfo tx lists. | [
"getTxFromList",
"is",
"a",
"helper",
"function",
"for",
"searching",
"the",
"MempoolInfo",
"tx",
"lists",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L504-L511 |
141,821 | decred/dcrdata | explorer/types/explorertypes.go | Tx | func (mpi *MempoolInfo) Tx(txid string) (MempoolTx, bool) {
mpi.RLock()
defer mpi.RUnlock()
_, found := mpi.InvRegular[txid]
if found {
return getTxFromList(txid, mpi.Transactions)
}
_, found = mpi.InvStake[txid]
if found {
tx, found := getTxFromList(txid, mpi.Tickets)
if found {
return tx, true
}
t... | go | func (mpi *MempoolInfo) Tx(txid string) (MempoolTx, bool) {
mpi.RLock()
defer mpi.RUnlock()
_, found := mpi.InvRegular[txid]
if found {
return getTxFromList(txid, mpi.Transactions)
}
_, found = mpi.InvStake[txid]
if found {
tx, found := getTxFromList(txid, mpi.Tickets)
if found {
return tx, true
}
t... | [
"func",
"(",
"mpi",
"*",
"MempoolInfo",
")",
"Tx",
"(",
"txid",
"string",
")",
"(",
"MempoolTx",
",",
"bool",
")",
"{",
"mpi",
".",
"RLock",
"(",
")",
"\n",
"defer",
"mpi",
".",
"RUnlock",
"(",
")",
"\n",
"_",
",",
"found",
":=",
"mpi",
".",
"I... | // Tx checks the inventory and searches the appropriate lists for a
// transaction matching the provided transaction ID. | [
"Tx",
"checks",
"the",
"inventory",
"and",
"searches",
"the",
"appropriate",
"lists",
"for",
"a",
"transaction",
"matching",
"the",
"provided",
"transaction",
"ID",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L515-L535 |
141,822 | decred/dcrdata | explorer/types/explorertypes.go | ID | func (mpi *MempoolInfo) ID() uint64 {
mpi.RLock()
defer mpi.RUnlock()
return mpi.Ident
} | go | func (mpi *MempoolInfo) ID() uint64 {
mpi.RLock()
defer mpi.RUnlock()
return mpi.Ident
} | [
"func",
"(",
"mpi",
"*",
"MempoolInfo",
")",
"ID",
"(",
")",
"uint64",
"{",
"mpi",
".",
"RLock",
"(",
")",
"\n",
"defer",
"mpi",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"mpi",
".",
"Ident",
"\n",
"}"
] | // ID can be used to track state changes. | [
"ID",
"can",
"be",
"used",
"to",
"track",
"state",
"changes",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L538-L542 |
141,823 | decred/dcrdata | explorer/types/explorertypes.go | FilterUniqueLastBlockVotes | func FilterUniqueLastBlockVotes(txs []*TrimmedTxInfo) (votes []*TrimmedTxInfo) {
seenVotes := make(map[string]struct{})
for _, tx := range txs {
if tx.VoteInfo != nil && tx.VoteInfo.ForLastBlock {
// Do not append duplicates.
if _, seen := seenVotes[tx.TxID]; seen {
continue
}
votes = append(votes, ... | go | func FilterUniqueLastBlockVotes(txs []*TrimmedTxInfo) (votes []*TrimmedTxInfo) {
seenVotes := make(map[string]struct{})
for _, tx := range txs {
if tx.VoteInfo != nil && tx.VoteInfo.ForLastBlock {
// Do not append duplicates.
if _, seen := seenVotes[tx.TxID]; seen {
continue
}
votes = append(votes, ... | [
"func",
"FilterUniqueLastBlockVotes",
"(",
"txs",
"[",
"]",
"*",
"TrimmedTxInfo",
")",
"(",
"votes",
"[",
"]",
"*",
"TrimmedTxInfo",
")",
"{",
"seenVotes",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
"\n",
"for",
"_",
",",
... | // FilterUniqueLastBlockVotes returns a slice of all the vote transactions from
// the input slice that are flagged as voting on the previous block. | [
"FilterUniqueLastBlockVotes",
"returns",
"a",
"slice",
"of",
"all",
"the",
"vote",
"transactions",
"from",
"the",
"input",
"slice",
"that",
"are",
"flagged",
"as",
"voting",
"on",
"the",
"previous",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L594-L607 |
141,824 | decred/dcrdata | explorer/types/explorertypes.go | NewVotingInfo | func NewVotingInfo(votesPerBlock uint16) VotingInfo {
return VotingInfo{
MaxVotesPerBlock: votesPerBlock,
VotedTickets: make(map[string]bool),
VoteTallys: make(map[string]*VoteTally),
}
} | go | func NewVotingInfo(votesPerBlock uint16) VotingInfo {
return VotingInfo{
MaxVotesPerBlock: votesPerBlock,
VotedTickets: make(map[string]bool),
VoteTallys: make(map[string]*VoteTally),
}
} | [
"func",
"NewVotingInfo",
"(",
"votesPerBlock",
"uint16",
")",
"VotingInfo",
"{",
"return",
"VotingInfo",
"{",
"MaxVotesPerBlock",
":",
"votesPerBlock",
",",
"VotedTickets",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
",",
"VoteTallys",
":",
"make... | // NewVotingInfo initializes a VotingInfo. | [
"NewVotingInfo",
"initializes",
"a",
"VotingInfo",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L726-L732 |
141,825 | decred/dcrdata | explorer/types/explorertypes.go | Tally | func (vi *VotingInfo) Tally(vinfo *VoteInfo) {
_, ok := vi.VoteTallys[vinfo.Validation.Hash]
if ok {
vi.VoteTallys[vinfo.Validation.Hash].Mark(vinfo.Validation.Validity)
return
}
marks := make([]bool, 1, vi.MaxVotesPerBlock)
marks[0] = vinfo.Validation.Validity
vi.VoteTallys[vinfo.Validation.Hash] = &VoteTall... | go | func (vi *VotingInfo) Tally(vinfo *VoteInfo) {
_, ok := vi.VoteTallys[vinfo.Validation.Hash]
if ok {
vi.VoteTallys[vinfo.Validation.Hash].Mark(vinfo.Validation.Validity)
return
}
marks := make([]bool, 1, vi.MaxVotesPerBlock)
marks[0] = vinfo.Validation.Validity
vi.VoteTallys[vinfo.Validation.Hash] = &VoteTall... | [
"func",
"(",
"vi",
"*",
"VotingInfo",
")",
"Tally",
"(",
"vinfo",
"*",
"VoteInfo",
")",
"{",
"_",
",",
"ok",
":=",
"vi",
".",
"VoteTallys",
"[",
"vinfo",
".",
"Validation",
".",
"Hash",
"]",
"\n",
"if",
"ok",
"{",
"vi",
".",
"VoteTallys",
"[",
"v... | // Tally adds the VoteInfo to the VotingInfo.VoteTally | [
"Tally",
"adds",
"the",
"VoteInfo",
"to",
"the",
"VotingInfo",
".",
"VoteTally"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L735-L747 |
141,826 | decred/dcrdata | explorer/types/explorertypes.go | BlockStatus | func (vi *VotingInfo) BlockStatus(hash string) ([]int, int) {
tally, ok := vi.VoteTallys[hash]
if ok {
return tally.Status()
}
marks := make([]int, int(vi.MaxVotesPerBlock))
for i := range marks {
marks[i] = VoteMissing
}
return marks, VoteMissing
} | go | func (vi *VotingInfo) BlockStatus(hash string) ([]int, int) {
tally, ok := vi.VoteTallys[hash]
if ok {
return tally.Status()
}
marks := make([]int, int(vi.MaxVotesPerBlock))
for i := range marks {
marks[i] = VoteMissing
}
return marks, VoteMissing
} | [
"func",
"(",
"vi",
"*",
"VotingInfo",
")",
"BlockStatus",
"(",
"hash",
"string",
")",
"(",
"[",
"]",
"int",
",",
"int",
")",
"{",
"tally",
",",
"ok",
":=",
"vi",
".",
"VoteTallys",
"[",
"hash",
"]",
"\n",
"if",
"ok",
"{",
"return",
"tally",
".",
... | // BlockStatus fetches a list of votes in mempool, for the provided block hash.
// If not found, a list of VoteMissing is returned. | [
"BlockStatus",
"fetches",
"a",
"list",
"of",
"votes",
"in",
"mempool",
"for",
"the",
"provided",
"block",
"hash",
".",
"If",
"not",
"found",
"a",
"list",
"of",
"VoteMissing",
"is",
"returned",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L751-L761 |
141,827 | decred/dcrdata | explorer/types/explorertypes.go | Mark | func (tally *VoteTally) Mark(vote bool) {
tally.Marks = append(tally.Marks, vote)
} | go | func (tally *VoteTally) Mark(vote bool) {
tally.Marks = append(tally.Marks, vote)
} | [
"func",
"(",
"tally",
"*",
"VoteTally",
")",
"Mark",
"(",
"vote",
"bool",
")",
"{",
"tally",
".",
"Marks",
"=",
"append",
"(",
"tally",
".",
"Marks",
",",
"vote",
")",
"\n",
"}"
] | // Mark adds the vote to the VoteTally. | [
"Mark",
"adds",
"the",
"vote",
"to",
"the",
"VoteTally",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L770-L772 |
141,828 | decred/dcrdata | explorer/types/explorertypes.go | Affirmations | func (tally *VoteTally) Affirmations() (c int) {
for _, affirmed := range tally.Marks {
if affirmed {
c++
}
}
return c
} | go | func (tally *VoteTally) Affirmations() (c int) {
for _, affirmed := range tally.Marks {
if affirmed {
c++
}
}
return c
} | [
"func",
"(",
"tally",
"*",
"VoteTally",
")",
"Affirmations",
"(",
")",
"(",
"c",
"int",
")",
"{",
"for",
"_",
",",
"affirmed",
":=",
"range",
"tally",
".",
"Marks",
"{",
"if",
"affirmed",
"{",
"c",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"c",... | // Affirmations counts the number of selected ticket holders who have voted
// in favor of the block for the given hash. | [
"Affirmations",
"counts",
"the",
"number",
"of",
"selected",
"ticket",
"holders",
"who",
"have",
"voted",
"in",
"favor",
"of",
"the",
"block",
"for",
"the",
"given",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L803-L810 |
141,829 | decred/dcrdata | explorer/types/explorertypes.go | AddressPrefixes | func AddressPrefixes(params *chaincfg.Params) []AddrPrefix {
Descriptions := []string{"P2PK address",
"P2PKH address prefix. Standard wallet address. 1 public key -> 1 private key",
"Ed25519 P2PKH address prefix",
"secp256k1 Schnorr P2PKH address prefix",
"P2SH address prefix",
"WIF private key prefix",
"H... | go | func AddressPrefixes(params *chaincfg.Params) []AddrPrefix {
Descriptions := []string{"P2PK address",
"P2PKH address prefix. Standard wallet address. 1 public key -> 1 private key",
"Ed25519 P2PKH address prefix",
"secp256k1 Schnorr P2PKH address prefix",
"P2SH address prefix",
"WIF private key prefix",
"H... | [
"func",
"AddressPrefixes",
"(",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"[",
"]",
"AddrPrefix",
"{",
"Descriptions",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
... | // AddressPrefixes generates an array AddrPrefix by using chaincfg.Params | [
"AddressPrefixes",
"generates",
"an",
"array",
"AddrPrefix",
"by",
"using",
"chaincfg",
".",
"Params"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L952-L997 |
141,830 | decred/dcrdata | explorer/types/explorertypes.go | UnspentOutputIndices | func UnspentOutputIndices(vouts []Vout) (unspents []int) {
for idx := range vouts {
vout := vouts[idx]
if vout.Amount == 0.0 || vout.Spent {
continue
}
unspents = append(unspents, idx)
}
return
} | go | func UnspentOutputIndices(vouts []Vout) (unspents []int) {
for idx := range vouts {
vout := vouts[idx]
if vout.Amount == 0.0 || vout.Spent {
continue
}
unspents = append(unspents, idx)
}
return
} | [
"func",
"UnspentOutputIndices",
"(",
"vouts",
"[",
"]",
"Vout",
")",
"(",
"unspents",
"[",
"]",
"int",
")",
"{",
"for",
"idx",
":=",
"range",
"vouts",
"{",
"vout",
":=",
"vouts",
"[",
"idx",
"]",
"\n",
"if",
"vout",
".",
"Amount",
"==",
"0.0",
"||"... | // UnspentOutputIndices finds the indices of the transaction outputs that appear
// unspent. The indices returned are the index within the passed slice, not
// within the transaction. | [
"UnspentOutputIndices",
"finds",
"the",
"indices",
"of",
"the",
"transaction",
"outputs",
"that",
"appear",
"unspent",
".",
"The",
"indices",
"returned",
"are",
"the",
"index",
"within",
"the",
"passed",
"slice",
"not",
"within",
"the",
"transaction",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L1035-L1044 |
141,831 | decred/dcrdata | explorer/types/explorertypes.go | MsgTxMempoolInputs | func MsgTxMempoolInputs(msgTx *wire.MsgTx) (inputs []MempoolInput) {
for vindex := range msgTx.TxIn {
outpoint := msgTx.TxIn[vindex].PreviousOutPoint
outId := outpoint.Hash.String()
inputs = append(inputs, MempoolInput{
TxId: outId,
Index: uint32(vindex),
Outdex: outpoint.Index,
})
}
return
} | go | func MsgTxMempoolInputs(msgTx *wire.MsgTx) (inputs []MempoolInput) {
for vindex := range msgTx.TxIn {
outpoint := msgTx.TxIn[vindex].PreviousOutPoint
outId := outpoint.Hash.String()
inputs = append(inputs, MempoolInput{
TxId: outId,
Index: uint32(vindex),
Outdex: outpoint.Index,
})
}
return
} | [
"func",
"MsgTxMempoolInputs",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
")",
"(",
"inputs",
"[",
"]",
"MempoolInput",
")",
"{",
"for",
"vindex",
":=",
"range",
"msgTx",
".",
"TxIn",
"{",
"outpoint",
":=",
"msgTx",
".",
"TxIn",
"[",
"vindex",
"]",
".",
... | // MsgTxMempoolInputs parses a MsgTx and creates a list of MempoolInput. | [
"MsgTxMempoolInputs",
"parses",
"a",
"MsgTx",
"and",
"creates",
"a",
"list",
"of",
"MempoolInput",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L1047-L1058 |
141,832 | decred/dcrdata | explorer/templates.go | execTemplateToString | func (t *templates) execTemplateToString(name string, data interface{}) (string, error) {
temp, ok := t.templates[name]
if !ok {
return "", fmt.Errorf("Template %s not known", name)
}
var page bytes.Buffer
err := temp.template.ExecuteTemplate(&page, name, data)
return page.String(), err
} | go | func (t *templates) execTemplateToString(name string, data interface{}) (string, error) {
temp, ok := t.templates[name]
if !ok {
return "", fmt.Errorf("Template %s not known", name)
}
var page bytes.Buffer
err := temp.template.ExecuteTemplate(&page, name, data)
return page.String(), err
} | [
"func",
"(",
"t",
"*",
"templates",
")",
"execTemplateToString",
"(",
"name",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"temp",
",",
"ok",
":=",
"t",
".",
"templates",
"[",
"name",
"]",
"\n",
"if",
"!... | // execTemplateToString executes the associated input template using the
// supplied data, and writes the result into a string. If the template fails to
// execute or isn't found, a non-nil error will be returned. Check it before
// writing to theclient, otherwise you might as well execute directly into
// your respons... | [
"execTemplateToString",
"executes",
"the",
"associated",
"input",
"template",
"using",
"the",
"supplied",
"data",
"and",
"writes",
"the",
"result",
"into",
"a",
"string",
".",
"If",
"the",
"template",
"fails",
"to",
"execute",
"or",
"isn",
"t",
"found",
"a",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/templates.go#L83-L92 |
141,833 | decred/dcrdata | txhelpers/subsidy.go | UltimateSubsidy | func UltimateSubsidy(params *chaincfg.Params) int64 {
// Check previously computed ultimate subsidies.
totalSubsidy, ok := ultimateSubsidies[params]
if ok {
return totalSubsidy
}
subsidyCache := blockchain.NewSubsidyCache(0, params)
totalSubsidy = params.BlockOneSubsidy()
for i := int64(0); ; i++ {
// Gene... | go | func UltimateSubsidy(params *chaincfg.Params) int64 {
// Check previously computed ultimate subsidies.
totalSubsidy, ok := ultimateSubsidies[params]
if ok {
return totalSubsidy
}
subsidyCache := blockchain.NewSubsidyCache(0, params)
totalSubsidy = params.BlockOneSubsidy()
for i := int64(0); ; i++ {
// Gene... | [
"func",
"UltimateSubsidy",
"(",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"int64",
"{",
"// Check previously computed ultimate subsidies.",
"totalSubsidy",
",",
"ok",
":=",
"ultimateSubsidies",
"[",
"params",
"]",
"\n",
"if",
"ok",
"{",
"return",
"totalSubsidy"... | // UltimateSubsidy computes the total subsidy over the entire subsidy
// distribution period of the network. | [
"UltimateSubsidy",
"computes",
"the",
"total",
"subsidy",
"over",
"the",
"entire",
"subsidy",
"distribution",
"period",
"of",
"the",
"network",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/subsidy.go#L18-L66 |
141,834 | decred/dcrdata | db/dcrsqlite/apisource.go | InitWiredDB | func InitWiredDB(dbInfo *DBInfo, stakeDB *stakedb.StakeDatabase, statusC chan uint32, cl *rpcclient.Client,
p *chaincfg.Params, shutdown func()) (*WiredDB, error) {
db, err := InitDB(dbInfo, shutdown)
if err != nil {
return nil, err
}
return newWiredDB(db, stakeDB, statusC, cl, p), nil
} | go | func InitWiredDB(dbInfo *DBInfo, stakeDB *stakedb.StakeDatabase, statusC chan uint32, cl *rpcclient.Client,
p *chaincfg.Params, shutdown func()) (*WiredDB, error) {
db, err := InitDB(dbInfo, shutdown)
if err != nil {
return nil, err
}
return newWiredDB(db, stakeDB, statusC, cl, p), nil
} | [
"func",
"InitWiredDB",
"(",
"dbInfo",
"*",
"DBInfo",
",",
"stakeDB",
"*",
"stakedb",
".",
"StakeDatabase",
",",
"statusC",
"chan",
"uint32",
",",
"cl",
"*",
"rpcclient",
".",
"Client",
",",
"p",
"*",
"chaincfg",
".",
"Params",
",",
"shutdown",
"func",
"(... | // InitWiredDB creates a new WiredDB from a file containing the data for a
// sql.DB. The other parameters are same as those for NewWiredDB. | [
"InitWiredDB",
"creates",
"a",
"new",
"WiredDB",
"from",
"a",
"file",
"containing",
"the",
"data",
"for",
"a",
"sql",
".",
"DB",
".",
"The",
"other",
"parameters",
"are",
"same",
"as",
"those",
"for",
"NewWiredDB",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L78-L86 |
141,835 | decred/dcrdata | db/dcrsqlite/apisource.go | ReportHeights | func (db *WiredDB) ReportHeights() error {
// Check and report heights of the DBs. dbHeight is the lowest of the
// heights, and may be -1 with an empty SQLite DB.
dbHeight, summaryHeight, stakeInfoHeight, stakeDBHeight, err := db.DBHeights()
if err != nil {
return fmt.Errorf("DBHeights failed: %v", err)
}
if d... | go | func (db *WiredDB) ReportHeights() error {
// Check and report heights of the DBs. dbHeight is the lowest of the
// heights, and may be -1 with an empty SQLite DB.
dbHeight, summaryHeight, stakeInfoHeight, stakeDBHeight, err := db.DBHeights()
if err != nil {
return fmt.Errorf("DBHeights failed: %v", err)
}
if d... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"ReportHeights",
"(",
")",
"error",
"{",
"// Check and report heights of the DBs. dbHeight is the lowest of the",
"// heights, and may be -1 with an empty SQLite DB.",
"dbHeight",
",",
"summaryHeight",
",",
"stakeInfoHeight",
",",
"stakeD... | // ReportHeights logs the SQLite table heights, and the stake database height,
// returning a non-nil error only when the SQLite tables are not at the same
// height. | [
"ReportHeights",
"logs",
"the",
"SQLite",
"table",
"heights",
"and",
"the",
"stake",
"database",
"height",
"returning",
"a",
"non",
"-",
"nil",
"error",
"only",
"when",
"the",
"SQLite",
"tables",
"are",
"not",
"at",
"the",
"same",
"height",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L149-L168 |
141,836 | decred/dcrdata | db/dcrsqlite/apisource.go | CheckConnectivity | func (db *WiredDB) CheckConnectivity() error {
var err error
if err = db.Ping(); err != nil {
return err
}
if err = db.client.Ping(); err != nil {
return err
}
return err
} | go | func (db *WiredDB) CheckConnectivity() error {
var err error
if err = db.Ping(); err != nil {
return err
}
if err = db.client.Ping(); err != nil {
return err
}
return err
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"CheckConnectivity",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"if",
"err",
"=",
"db",
".",
"Ping",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"err",
"=",
"... | // CheckConnectivity ensures the db and RPC client are working. | [
"CheckConnectivity",
"ensures",
"the",
"db",
"and",
"RPC",
"client",
"are",
"working",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L171-L180 |
141,837 | decred/dcrdata | db/dcrsqlite/apisource.go | PurgeBlocksAboveHeight | func (db *WiredDB) PurgeBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error) {
var summaryHeight, stakeInfoHeight int64
_, summaryHeight, stakeInfoHeight, _, err = db.DBHeights()
if err != nil {
return
}
if summaryHeight != stakeInfoHeight {
log.Warnf("Tables are at different heights... | go | func (db *WiredDB) PurgeBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error) {
var summaryHeight, stakeInfoHeight int64
_, summaryHeight, stakeInfoHeight, _, err = db.DBHeights()
if err != nil {
return
}
if summaryHeight != stakeInfoHeight {
log.Warnf("Tables are at different heights... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"PurgeBlocksAboveHeight",
"(",
"height",
"int64",
")",
"(",
"NSummaryRows",
",",
"NStakeInfoRows",
"int64",
",",
"err",
"error",
")",
"{",
"var",
"summaryHeight",
",",
"stakeInfoHeight",
"int64",
"\n",
"_",
",",
"summa... | // PurgeBlocksAboveHeight deletes all data across all tables for the blocks
// above the given height, including side chain blocks. The numbers of blocks
// removed from the block summary table and stake info table are returned.
// PurgeBlocksAboveHeight will not return sql.ErrNoRows, but it will return
// without remo... | [
"PurgeBlocksAboveHeight",
"deletes",
"all",
"data",
"across",
"all",
"tables",
"for",
"the",
"blocks",
"above",
"the",
"given",
"height",
"including",
"side",
"chain",
"blocks",
".",
"The",
"numbers",
"of",
"blocks",
"removed",
"from",
"the",
"block",
"summary",... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L257-L306 |
141,838 | decred/dcrdata | db/dcrsqlite/apisource.go | PurgeBlock | func (db *WiredDB) PurgeBlock(hash string) (NSummaryRows, NStakeInfoRows int64, err error) {
NSummaryRows, NStakeInfoRows, err = db.DeleteBlock(hash)
// DeleteBlock should not return sql.ErrNoRows, but check anyway.
if err == sql.ErrNoRows {
err = nil
}
return
} | go | func (db *WiredDB) PurgeBlock(hash string) (NSummaryRows, NStakeInfoRows int64, err error) {
NSummaryRows, NStakeInfoRows, err = db.DeleteBlock(hash)
// DeleteBlock should not return sql.ErrNoRows, but check anyway.
if err == sql.ErrNoRows {
err = nil
}
return
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"PurgeBlock",
"(",
"hash",
"string",
")",
"(",
"NSummaryRows",
",",
"NStakeInfoRows",
"int64",
",",
"err",
"error",
")",
"{",
"NSummaryRows",
",",
"NStakeInfoRows",
",",
"err",
"=",
"db",
".",
"DeleteBlock",
"(",
"... | // PurgeBlock deletes all data across all tables for the block with the
// specified hash. The numbers of blocks removed from the block summary table
// and stake info table are returned. PurgeBlock will not return sql.ErrNoRows,
// but it may return without removing a block. | [
"PurgeBlock",
"deletes",
"all",
"data",
"across",
"all",
"tables",
"for",
"the",
"block",
"with",
"the",
"specified",
"hash",
".",
"The",
"numbers",
"of",
"blocks",
"removed",
"from",
"the",
"block",
"summary",
"table",
"and",
"stake",
"info",
"table",
"are"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L312-L319 |
141,839 | decred/dcrdata | db/dcrsqlite/apisource.go | PurgeBestBlock | func (db *WiredDB) PurgeBestBlock() (NSummaryRows, NStakeInfoRows, height int64, hash string, err error) {
var summaryHeight, stakeInfoHeight int64
_, summaryHeight, stakeInfoHeight, _, err = db.DBHeights()
if err != nil {
return
}
if summaryHeight != stakeInfoHeight {
err = fmt.Errorf("tables are at different... | go | func (db *WiredDB) PurgeBestBlock() (NSummaryRows, NStakeInfoRows, height int64, hash string, err error) {
var summaryHeight, stakeInfoHeight int64
_, summaryHeight, stakeInfoHeight, _, err = db.DBHeights()
if err != nil {
return
}
if summaryHeight != stakeInfoHeight {
err = fmt.Errorf("tables are at different... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"PurgeBestBlock",
"(",
")",
"(",
"NSummaryRows",
",",
"NStakeInfoRows",
",",
"height",
"int64",
",",
"hash",
"string",
",",
"err",
"error",
")",
"{",
"var",
"summaryHeight",
",",
"stakeInfoHeight",
"int64",
"\n",
"_"... | // PurgeBestBlock deletes all data across all tables for the best block in the
// block summary table. The numbers of blocks removed from the block summary
// table and stake info table are returned. PurgeBestBlock will not return
// sql.ErrNoRows, but it will return without removing a block if the tables are
// empty.... | [
"PurgeBestBlock",
"deletes",
"all",
"data",
"across",
"all",
"tables",
"for",
"the",
"best",
"block",
"in",
"the",
"block",
"summary",
"table",
".",
"The",
"numbers",
"of",
"blocks",
"removed",
"from",
"the",
"block",
"summary",
"table",
"and",
"stake",
"inf... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L327-L368 |
141,840 | decred/dcrdata | db/dcrsqlite/apisource.go | PurgeBestBlocks | func (db *WiredDB) PurgeBestBlocks(N int64) (NSummaryRows, NStakeInfoRows, height int64, hash string, err error) {
// If N is less than 1, get the current best block height and hash, then
// return.
if N < 1 {
var h chainhash.Hash
h, height, err = db.GetBestBlockHeightHash()
if err == sql.ErrNoRows {
err = ... | go | func (db *WiredDB) PurgeBestBlocks(N int64) (NSummaryRows, NStakeInfoRows, height int64, hash string, err error) {
// If N is less than 1, get the current best block height and hash, then
// return.
if N < 1 {
var h chainhash.Hash
h, height, err = db.GetBestBlockHeightHash()
if err == sql.ErrNoRows {
err = ... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"PurgeBestBlocks",
"(",
"N",
"int64",
")",
"(",
"NSummaryRows",
",",
"NStakeInfoRows",
",",
"height",
"int64",
",",
"hash",
"string",
",",
"err",
"error",
")",
"{",
"// If N is less than 1, get the current best block height ... | // PurgeBestBlocks deletes all data across all tables for the N best blocks in
// the block summary table. The number of blocks removed is returned.
// PurgeBestBlocks will not return sql.ErrNoRows, but it will return without
// removing the requested number of blocks if the tables are empty or become
// empty. The ret... | [
"PurgeBestBlocks",
"deletes",
"all",
"data",
"across",
"all",
"tables",
"for",
"the",
"N",
"best",
"blocks",
"in",
"the",
"block",
"summary",
"table",
".",
"The",
"number",
"of",
"blocks",
"removed",
"is",
"returned",
".",
"PurgeBestBlocks",
"will",
"not",
"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L376-L424 |
141,841 | decred/dcrdata | db/dcrsqlite/apisource.go | GetBestBlockHeightHash | func (db *WiredDB) GetBestBlockHeightHash() (chainhash.Hash, int64, error) {
bestBlockSummary := db.GetBestBlockSummary()
if bestBlockSummary == nil {
return chainhash.Hash{}, -1, fmt.Errorf("unable to retrieve best block summary")
}
height := int64(bestBlockSummary.Height)
hash, err := chainhash.NewHashFromStr(... | go | func (db *WiredDB) GetBestBlockHeightHash() (chainhash.Hash, int64, error) {
bestBlockSummary := db.GetBestBlockSummary()
if bestBlockSummary == nil {
return chainhash.Hash{}, -1, fmt.Errorf("unable to retrieve best block summary")
}
height := int64(bestBlockSummary.Height)
hash, err := chainhash.NewHashFromStr(... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetBestBlockHeightHash",
"(",
")",
"(",
"chainhash",
".",
"Hash",
",",
"int64",
",",
"error",
")",
"{",
"bestBlockSummary",
":=",
"db",
".",
"GetBestBlockSummary",
"(",
")",
"\n",
"if",
"bestBlockSummary",
"==",
"ni... | // GetBestBlockHeightHash retrieves the DB's best block hash and height. | [
"GetBestBlockHeightHash",
"retrieves",
"the",
"DB",
"s",
"best",
"block",
"hash",
"and",
"height",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L427-L435 |
141,842 | decred/dcrdata | db/dcrsqlite/apisource.go | GetRawTransactionWithPrevOutAddresses | func (db *WiredDB) GetRawTransactionWithPrevOutAddresses(txid *chainhash.Hash) (*apitypes.Tx, [][]string) {
tx, _ := db.getRawTransaction(txid)
if tx == nil {
return nil, nil
}
prevOutAddresses := make([][]string, len(tx.Vin))
for i := range tx.Vin {
vin := &tx.Vin[i]
// Skip inspecting previous outpoint f... | go | func (db *WiredDB) GetRawTransactionWithPrevOutAddresses(txid *chainhash.Hash) (*apitypes.Tx, [][]string) {
tx, _ := db.getRawTransaction(txid)
if tx == nil {
return nil, nil
}
prevOutAddresses := make([][]string, len(tx.Vin))
for i := range tx.Vin {
vin := &tx.Vin[i]
// Skip inspecting previous outpoint f... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetRawTransactionWithPrevOutAddresses",
"(",
"txid",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"apitypes",
".",
"Tx",
",",
"[",
"]",
"[",
"]",
"string",
")",
"{",
"tx",
",",
"_",
":=",
"db",
".",
"getRawTr... | // GetRawTransactionWithPrevOutAddresses looks up the previous outpoints for a
// transaction and extracts a slice of addresses encoded by the pkScript for
// each previous outpoint consumed by the transaction. | [
"GetRawTransactionWithPrevOutAddresses",
"looks",
"up",
"the",
"previous",
"outpoints",
"for",
"a",
"transaction",
"and",
"extracts",
"a",
"slice",
"of",
"addresses",
"encoded",
"by",
"the",
"pkScript",
"for",
"each",
"previous",
"outpoint",
"consumed",
"by",
"the",... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L611-L635 |
141,843 | decred/dcrdata | db/dcrsqlite/apisource.go | GetVoteVersionInfo | func (db *WiredDB) GetVoteVersionInfo(ver uint32) (*dcrjson.GetVoteInfoResult, error) {
return db.client.GetVoteInfo(ver)
} | go | func (db *WiredDB) GetVoteVersionInfo(ver uint32) (*dcrjson.GetVoteInfoResult, error) {
return db.client.GetVoteInfo(ver)
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetVoteVersionInfo",
"(",
"ver",
"uint32",
")",
"(",
"*",
"dcrjson",
".",
"GetVoteInfoResult",
",",
"error",
")",
"{",
"return",
"db",
".",
"client",
".",
"GetVoteInfo",
"(",
"ver",
")",
"\n",
"}"
] | // GetVoteVersionInfo requests stake version info from the dcrd RPC server | [
"GetVoteVersionInfo",
"requests",
"stake",
"version",
"info",
"from",
"the",
"dcrd",
"RPC",
"server"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L700-L702 |
141,844 | decred/dcrdata | db/dcrsqlite/apisource.go | GetStakeVersions | func (db *WiredDB) GetStakeVersions(blockHash string, count int32) (*dcrjson.GetStakeVersionsResult, error) {
return db.client.GetStakeVersions(blockHash, count)
} | go | func (db *WiredDB) GetStakeVersions(blockHash string, count int32) (*dcrjson.GetStakeVersionsResult, error) {
return db.client.GetStakeVersions(blockHash, count)
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetStakeVersions",
"(",
"blockHash",
"string",
",",
"count",
"int32",
")",
"(",
"*",
"dcrjson",
".",
"GetStakeVersionsResult",
",",
"error",
")",
"{",
"return",
"db",
".",
"client",
".",
"GetStakeVersions",
"(",
"bl... | // GetStakeVersions requests the output of the getstakeversions RPC, which gets
// stake version information and individual vote version information starting at the
// given block and for count-1 blocks prior. | [
"GetStakeVersions",
"requests",
"the",
"output",
"of",
"the",
"getstakeversions",
"RPC",
"which",
"gets",
"stake",
"version",
"information",
"and",
"individual",
"vote",
"version",
"information",
"starting",
"at",
"the",
"given",
"block",
"and",
"for",
"count",
"-... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L707-L709 |
141,845 | decred/dcrdata | db/dcrsqlite/apisource.go | GetBlockSummaryTimeRange | func (db *WiredDB) GetBlockSummaryTimeRange(min, max int64, limit int) []apitypes.BlockDataBasic {
blockSummary, err := db.RetrieveBlockSummaryByTimeRange(min, max, limit)
if err != nil {
log.Errorf("Unable to retrieve block summary using time %d: %v", min, err)
}
return blockSummary
} | go | func (db *WiredDB) GetBlockSummaryTimeRange(min, max int64, limit int) []apitypes.BlockDataBasic {
blockSummary, err := db.RetrieveBlockSummaryByTimeRange(min, max, limit)
if err != nil {
log.Errorf("Unable to retrieve block summary using time %d: %v", min, err)
}
return blockSummary
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetBlockSummaryTimeRange",
"(",
"min",
",",
"max",
"int64",
",",
"limit",
"int",
")",
"[",
"]",
"apitypes",
".",
"BlockDataBasic",
"{",
"blockSummary",
",",
"err",
":=",
"db",
".",
"RetrieveBlockSummaryByTimeRange",
"... | // GetBlockSummaryTimeRange returns the blocks created within a specified time
// range min, max time | [
"GetBlockSummaryTimeRange",
"returns",
"the",
"blocks",
"created",
"within",
"a",
"specified",
"time",
"range",
"min",
"max",
"time"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L930-L936 |
141,846 | decred/dcrdata | db/dcrsqlite/apisource.go | RetreiveDifficulty | func (db *WiredDB) RetreiveDifficulty(timestamp int64) float64 {
sdiff, err := db.RetrieveDiff(timestamp)
if err != nil {
log.Errorf("Unable to retrieve difficulty: %v", err)
return -1
}
return sdiff
} | go | func (db *WiredDB) RetreiveDifficulty(timestamp int64) float64 {
sdiff, err := db.RetrieveDiff(timestamp)
if err != nil {
log.Errorf("Unable to retrieve difficulty: %v", err)
return -1
}
return sdiff
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"RetreiveDifficulty",
"(",
"timestamp",
"int64",
")",
"float64",
"{",
"sdiff",
",",
"err",
":=",
"db",
".",
"RetrieveDiff",
"(",
"timestamp",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
... | // RetreiveDifficulty fetches the difficulty value in the last 24hrs or
// immediately after 24hrs. | [
"RetreiveDifficulty",
"fetches",
"the",
"difficulty",
"value",
"in",
"the",
"last",
"24hrs",
"or",
"immediately",
"after",
"24hrs",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L985-L992 |
141,847 | decred/dcrdata | db/dcrsqlite/apisource.go | GetAddressTransactionsWithSkip | func (db *WiredDB) GetAddressTransactionsWithSkip(addr string, count, skip int) *apitypes.Address {
address, err := dcrutil.DecodeAddress(addr)
if err != nil {
log.Infof("Invalid address %s: %v", addr, err)
return nil
}
txs, err := db.client.SearchRawTransactionsVerbose(address, skip, count, false, true, nil)
... | go | func (db *WiredDB) GetAddressTransactionsWithSkip(addr string, count, skip int) *apitypes.Address {
address, err := dcrutil.DecodeAddress(addr)
if err != nil {
log.Infof("Invalid address %s: %v", addr, err)
return nil
}
txs, err := db.client.SearchRawTransactionsVerbose(address, skip, count, false, true, nil)
... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetAddressTransactionsWithSkip",
"(",
"addr",
"string",
",",
"count",
",",
"skip",
"int",
")",
"*",
"apitypes",
".",
"Address",
"{",
"address",
",",
"err",
":=",
"dcrutil",
".",
"DecodeAddress",
"(",
"addr",
")",
... | // GetAddressTransactionsWithSkip returns an apitypes.Address Object with at most the
// last count transactions the address was in | [
"GetAddressTransactionsWithSkip",
"returns",
"an",
"apitypes",
".",
"Address",
"Object",
"with",
"at",
"most",
"the",
"last",
"count",
"transactions",
"the",
"address",
"was",
"in"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1040-L1073 |
141,848 | decred/dcrdata | db/dcrsqlite/apisource.go | GetAddressTransactions | func (db *WiredDB) GetAddressTransactions(addr string, count int) *apitypes.Address {
return db.GetAddressTransactionsWithSkip(addr, count, 0)
} | go | func (db *WiredDB) GetAddressTransactions(addr string, count int) *apitypes.Address {
return db.GetAddressTransactionsWithSkip(addr, count, 0)
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetAddressTransactions",
"(",
"addr",
"string",
",",
"count",
"int",
")",
"*",
"apitypes",
".",
"Address",
"{",
"return",
"db",
".",
"GetAddressTransactionsWithSkip",
"(",
"addr",
",",
"count",
",",
"0",
")",
"\n",
... | // GetAddressTransactions returns an apitypes.Address Object with at most the
// last count transactions the address was in | [
"GetAddressTransactions",
"returns",
"an",
"apitypes",
".",
"Address",
"Object",
"with",
"at",
"most",
"the",
"last",
"count",
"transactions",
"the",
"address",
"was",
"in"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1077-L1079 |
141,849 | decred/dcrdata | db/dcrsqlite/apisource.go | GetAddressTransactionsRaw | func (db *WiredDB) GetAddressTransactionsRaw(addr string, count int) []*apitypes.AddressTxRaw {
return db.GetAddressTransactionsRawWithSkip(addr, count, 0)
} | go | func (db *WiredDB) GetAddressTransactionsRaw(addr string, count int) []*apitypes.AddressTxRaw {
return db.GetAddressTransactionsRawWithSkip(addr, count, 0)
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetAddressTransactionsRaw",
"(",
"addr",
"string",
",",
"count",
"int",
")",
"[",
"]",
"*",
"apitypes",
".",
"AddressTxRaw",
"{",
"return",
"db",
".",
"GetAddressTransactionsRawWithSkip",
"(",
"addr",
",",
"count",
",... | // GetAddressTransactionsRaw returns an array of apitypes.AddressTxRaw objects
// representing the raw result of SearchRawTransactionsverbose | [
"GetAddressTransactionsRaw",
"returns",
"an",
"array",
"of",
"apitypes",
".",
"AddressTxRaw",
"objects",
"representing",
"the",
"raw",
"result",
"of",
"SearchRawTransactionsverbose"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1083-L1085 |
141,850 | decred/dcrdata | db/dcrsqlite/apisource.go | GetExplorerBlocks | func (db *WiredDB) GetExplorerBlocks(start int, end int) []*exptypes.BlockBasic {
if start < end {
return nil
}
summaries := make([]*exptypes.BlockBasic, 0, start-end)
for i := start; i > end; i-- {
data := db.GetBlockVerbose(i, true)
block := new(exptypes.BlockBasic)
if data != nil {
block = makeExplore... | go | func (db *WiredDB) GetExplorerBlocks(start int, end int) []*exptypes.BlockBasic {
if start < end {
return nil
}
summaries := make([]*exptypes.BlockBasic, 0, start-end)
for i := start; i > end; i-- {
data := db.GetBlockVerbose(i, true)
block := new(exptypes.BlockBasic)
if data != nil {
block = makeExplore... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetExplorerBlocks",
"(",
"start",
"int",
",",
"end",
"int",
")",
"[",
"]",
"*",
"exptypes",
".",
"BlockBasic",
"{",
"if",
"start",
"<",
"end",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"summaries",
":=",
"make",
... | // GetExplorerBlocks creates an slice of exptypes.BlockBasic beginning at start
// and decreasing in block height to end, not including end. | [
"GetExplorerBlocks",
"creates",
"an",
"slice",
"of",
"exptypes",
".",
"BlockBasic",
"beginning",
"at",
"start",
"and",
"decreasing",
"in",
"block",
"height",
"to",
"end",
"not",
"including",
"end",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1245-L1259 |
141,851 | decred/dcrdata | db/dcrsqlite/apisource.go | GetMempool | func (db *WiredDB) GetMempool() []exptypes.MempoolTx {
mempooltxs, err := db.client.GetRawMempoolVerbose(dcrjson.GRMAll)
if err != nil {
log.Errorf("GetRawMempoolVerbose failed: %v", err)
return nil
}
txs := make([]exptypes.MempoolTx, 0, len(mempooltxs))
for hashStr, tx := range mempooltxs {
hash, err := c... | go | func (db *WiredDB) GetMempool() []exptypes.MempoolTx {
mempooltxs, err := db.client.GetRawMempoolVerbose(dcrjson.GRMAll)
if err != nil {
log.Errorf("GetRawMempoolVerbose failed: %v", err)
return nil
}
txs := make([]exptypes.MempoolTx, 0, len(mempooltxs))
for hashStr, tx := range mempooltxs {
hash, err := c... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetMempool",
"(",
")",
"[",
"]",
"exptypes",
".",
"MempoolTx",
"{",
"mempooltxs",
",",
"err",
":=",
"db",
".",
"client",
".",
"GetRawMempoolVerbose",
"(",
"dcrjson",
".",
"GRMAll",
")",
"\n",
"if",
"err",
"!=",
... | // GetMempool gets all transactions from the mempool for explorer and adds the
// total out for all the txs and vote info for the votes. The returned slice
// will be nil if the GetRawMempoolVerbose RPC fails. A zero-length non-nil
// slice is returned if there are no transactions in mempool. | [
"GetMempool",
"gets",
"all",
"transactions",
"from",
"the",
"mempool",
"for",
"explorer",
"and",
"adds",
"the",
"total",
"out",
"for",
"all",
"the",
"txs",
"and",
"vote",
"info",
"for",
"the",
"votes",
".",
"The",
"returned",
"slice",
"will",
"be",
"nil",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1706-L1766 |
141,852 | decred/dcrdata | db/dcrsqlite/apisource.go | TxHeight | func (db *WiredDB) TxHeight(txid *chainhash.Hash) (height int64) {
txraw, err := db.client.GetRawTransactionVerbose(txid)
if err != nil {
log.Errorf("GetRawTransactionVerbose failed for: %v", txid)
return 0
}
height = txraw.BlockHeight
return
} | go | func (db *WiredDB) TxHeight(txid *chainhash.Hash) (height int64) {
txraw, err := db.client.GetRawTransactionVerbose(txid)
if err != nil {
log.Errorf("GetRawTransactionVerbose failed for: %v", txid)
return 0
}
height = txraw.BlockHeight
return
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"TxHeight",
"(",
"txid",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"height",
"int64",
")",
"{",
"txraw",
",",
"err",
":=",
"db",
".",
"client",
".",
"GetRawTransactionVerbose",
"(",
"txid",
")",
"\n",
"if",
"err... | // TxHeight gives the block height of the transaction id specified | [
"TxHeight",
"gives",
"the",
"block",
"height",
"of",
"the",
"transaction",
"id",
"specified"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1769-L1777 |
141,853 | decred/dcrdata | db/dcrsqlite/apisource.go | Difficulty | func (db *WiredDB) Difficulty() (float64, error) {
diff, err := db.client.GetDifficulty()
if err != nil {
log.Error("GetDifficulty failed")
return diff, err
}
return diff, nil
} | go | func (db *WiredDB) Difficulty() (float64, error) {
diff, err := db.client.GetDifficulty()
if err != nil {
log.Error("GetDifficulty failed")
return diff, err
}
return diff, nil
} | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"Difficulty",
"(",
")",
"(",
"float64",
",",
"error",
")",
"{",
"diff",
",",
"err",
":=",
"db",
".",
"client",
".",
"GetDifficulty",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Error",
"(",
... | // Difficulty returns the difficulty. | [
"Difficulty",
"returns",
"the",
"difficulty",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1780-L1787 |
141,854 | decred/dcrdata | db/dcrsqlite/apisource.go | GetTip | func (db *WiredDB) GetTip() (*exptypes.WebBasicBlock, error) {
tip, err := db.DB.getTip()
if err != nil {
return nil, err
}
blockdata := exptypes.WebBasicBlock{
Height: tip.Height,
Size: tip.Size,
Hash: tip.Hash,
Difficulty: tip.Difficulty,
StakeDiff: tip.StakeDiff,
Time: ... | go | func (db *WiredDB) GetTip() (*exptypes.WebBasicBlock, error) {
tip, err := db.DB.getTip()
if err != nil {
return nil, err
}
blockdata := exptypes.WebBasicBlock{
Height: tip.Height,
Size: tip.Size,
Hash: tip.Hash,
Difficulty: tip.Difficulty,
StakeDiff: tip.StakeDiff,
Time: ... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"GetTip",
"(",
")",
"(",
"*",
"exptypes",
".",
"WebBasicBlock",
",",
"error",
")",
"{",
"tip",
",",
"err",
":=",
"db",
".",
"DB",
".",
"getTip",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n... | // GetTip grabs the highest block stored in the database. | [
"GetTip",
"grabs",
"the",
"highest",
"block",
"stored",
"in",
"the",
"database",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1790-L1809 |
141,855 | decred/dcrdata | api/types/apitypes.go | MarshalJSON | func (t *TimeAPI) MarshalJSON() ([]byte, error) {
return json.Marshal(t.S.UNIX())
} | go | func (t *TimeAPI) MarshalJSON() ([]byte, error) {
return json.Marshal(t.S.UNIX())
} | [
"func",
"(",
"t",
"*",
"TimeAPI",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"t",
".",
"S",
".",
"UNIX",
"(",
")",
")",
"\n",
"}"
] | // MarshalJSON is set as the default marshalling function for TimeAPI struct. | [
"MarshalJSON",
"is",
"set",
"as",
"the",
"default",
"marshalling",
"function",
"for",
"TimeAPI",
"struct",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L37-L39 |
141,856 | decred/dcrdata | api/types/apitypes.go | NewTimeAPI | func NewTimeAPI(t time.Time) TimeAPI {
return TimeAPI{
S: dbtypes.NewTimeDef(t),
}
} | go | func NewTimeAPI(t time.Time) TimeAPI {
return TimeAPI{
S: dbtypes.NewTimeDef(t),
}
} | [
"func",
"NewTimeAPI",
"(",
"t",
"time",
".",
"Time",
")",
"TimeAPI",
"{",
"return",
"TimeAPI",
"{",
"S",
":",
"dbtypes",
".",
"NewTimeDef",
"(",
"t",
")",
",",
"}",
"\n",
"}"
] | // NewTimeAPI constructs a TimeAPI from the given time.Time. It presets the
// timezone for formatting to UTC. | [
"NewTimeAPI",
"constructs",
"a",
"TimeAPI",
"from",
"the",
"given",
"time",
".",
"Time",
".",
"It",
"presets",
"the",
"timezone",
"for",
"formatting",
"to",
"UTC",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L56-L60 |
141,857 | decred/dcrdata | api/types/apitypes.go | String | func (sc ScriptClass) String() string {
name, found := scriptClassToName[sc]
if !found {
return ScriptClassInvalid.String() // better be in scriptClassToName!
}
return name
} | go | func (sc ScriptClass) String() string {
name, found := scriptClassToName[sc]
if !found {
return ScriptClassInvalid.String() // better be in scriptClassToName!
}
return name
} | [
"func",
"(",
"sc",
"ScriptClass",
")",
"String",
"(",
")",
"string",
"{",
"name",
",",
"found",
":=",
"scriptClassToName",
"[",
"sc",
"]",
"\n",
"if",
"!",
"found",
"{",
"return",
"ScriptClassInvalid",
".",
"String",
"(",
")",
"// better be in scriptClassToN... | // String returns the name of the ScriptClass. If the ScriptClass is
// unrecognized it is treated as ScriptClassInvalid. | [
"String",
"returns",
"the",
"name",
"of",
"the",
"ScriptClass",
".",
"If",
"the",
"ScriptClass",
"is",
"unrecognized",
"it",
"is",
"treated",
"as",
"ScriptClassInvalid",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L265-L271 |
141,858 | decred/dcrdata | api/types/apitypes.go | NewStatus | func NewStatus(nodeHeight uint32, conns int64, apiVersion int, dcrdataVersion, netName string) *Status {
return &Status{
height: nodeHeight,
nodeConnections: conns,
api: APIStatus{
APIVersion: apiVersion,
DcrdataVersion: dcrdataVersion,
NetworkName: netName,
},
}
} | go | func NewStatus(nodeHeight uint32, conns int64, apiVersion int, dcrdataVersion, netName string) *Status {
return &Status{
height: nodeHeight,
nodeConnections: conns,
api: APIStatus{
APIVersion: apiVersion,
DcrdataVersion: dcrdataVersion,
NetworkName: netName,
},
}
} | [
"func",
"NewStatus",
"(",
"nodeHeight",
"uint32",
",",
"conns",
"int64",
",",
"apiVersion",
"int",
",",
"dcrdataVersion",
",",
"netName",
"string",
")",
"*",
"Status",
"{",
"return",
"&",
"Status",
"{",
"height",
":",
"nodeHeight",
",",
"nodeConnections",
":... | // NewStatus is the constructor for a new Status. | [
"NewStatus",
"is",
"the",
"constructor",
"for",
"a",
"new",
"Status",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L435-L445 |
141,859 | decred/dcrdata | api/types/apitypes.go | API | func (s *Status) API() APIStatus {
s.RLock()
defer s.RUnlock()
return APIStatus{
Ready: s.ready,
DBHeight: s.dbHeight,
DBLastBlockTime: s.dbLastBlockTime,
Height: s.height,
NodeConnections: s.nodeConnections,
APIVersion: s.api.APIVersion,
DcrdataVersion: s.api.DcrdataVer... | go | func (s *Status) API() APIStatus {
s.RLock()
defer s.RUnlock()
return APIStatus{
Ready: s.ready,
DBHeight: s.dbHeight,
DBLastBlockTime: s.dbLastBlockTime,
Height: s.height,
NodeConnections: s.nodeConnections,
APIVersion: s.api.APIVersion,
DcrdataVersion: s.api.DcrdataVer... | [
"func",
"(",
"s",
"*",
"Status",
")",
"API",
"(",
")",
"APIStatus",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"APIStatus",
"{",
"Ready",
":",
"s",
".",
"ready",
",",
"DBHeight",
":",
"s",
".... | // API is a method for creating an APIStatus from Status. | [
"API",
"is",
"a",
"method",
"for",
"creating",
"an",
"APIStatus",
"from",
"Status",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L448-L461 |
141,860 | decred/dcrdata | api/types/apitypes.go | Height | func (s *Status) Height() uint32 {
s.RLock()
defer s.RUnlock()
return s.height
} | go | func (s *Status) Height() uint32 {
s.RLock()
defer s.RUnlock()
return s.height
} | [
"func",
"(",
"s",
"*",
"Status",
")",
"Height",
"(",
")",
"uint32",
"{",
"s",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"s",
".",
"height",
"\n",
"}"
] | // Height is the last known node height. | [
"Height",
"is",
"the",
"last",
"known",
"node",
"height",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L464-L468 |
141,861 | decred/dcrdata | api/types/apitypes.go | SetHeight | func (s *Status) SetHeight(height uint32) {
s.Lock()
defer s.Unlock()
s.ready = height == s.dbHeight
s.height = height
} | go | func (s *Status) SetHeight(height uint32) {
s.Lock()
defer s.Unlock()
s.ready = height == s.dbHeight
s.height = height
} | [
"func",
"(",
"s",
"*",
"Status",
")",
"SetHeight",
"(",
"height",
"uint32",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"ready",
"=",
"height",
"==",
"s",
".",
"dbHeight",
"\n",
"s",
".",
... | // SetHeight stores the node height. Additionally, Status.ready is set to true
// if Status.height is the same as Status.dbHeight. | [
"SetHeight",
"stores",
"the",
"node",
"height",
".",
"Additionally",
"Status",
".",
"ready",
"is",
"set",
"to",
"true",
"if",
"Status",
".",
"height",
"is",
"the",
"same",
"as",
"Status",
".",
"dbHeight",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L472-L477 |
141,862 | decred/dcrdata | api/types/apitypes.go | SetHeightAndConnections | func (s *Status) SetHeightAndConnections(height uint32, conns int64) {
s.Lock()
defer s.Unlock()
s.nodeConnections = conns
s.ready = height == s.dbHeight
s.height = height
} | go | func (s *Status) SetHeightAndConnections(height uint32, conns int64) {
s.Lock()
defer s.Unlock()
s.nodeConnections = conns
s.ready = height == s.dbHeight
s.height = height
} | [
"func",
"(",
"s",
"*",
"Status",
")",
"SetHeightAndConnections",
"(",
"height",
"uint32",
",",
"conns",
"int64",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"nodeConnections",
"=",
"conns",
"\n",... | // SetHeightAndConnections simultaneously sets the node height and node
// connection count. Status.ready is set to true if the height and dbHeight are
// the same. | [
"SetHeightAndConnections",
"simultaneously",
"sets",
"the",
"node",
"height",
"and",
"node",
"connection",
"count",
".",
"Status",
".",
"ready",
"is",
"set",
"to",
"true",
"if",
"the",
"height",
"and",
"dbHeight",
"are",
"the",
"same",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L482-L488 |
141,863 | decred/dcrdata | api/types/apitypes.go | SetReady | func (s *Status) SetReady(ready bool) {
s.Lock()
defer s.Unlock()
s.ready = ready
} | go | func (s *Status) SetReady(ready bool) {
s.Lock()
defer s.Unlock()
s.ready = ready
} | [
"func",
"(",
"s",
"*",
"Status",
")",
"SetReady",
"(",
"ready",
"bool",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"ready",
"=",
"ready",
"\n",
"}"
] | // SetReady sets the ready state. | [
"SetReady",
"sets",
"the",
"ready",
"state",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L491-L495 |
141,864 | decred/dcrdata | api/types/apitypes.go | DBUpdate | func (s *Status) DBUpdate(height uint32, blockTime int64) {
s.Lock()
defer s.Unlock()
s.dbHeight = height
s.dbLastBlockTime = blockTime
s.ready = s.dbHeight == height
} | go | func (s *Status) DBUpdate(height uint32, blockTime int64) {
s.Lock()
defer s.Unlock()
s.dbHeight = height
s.dbLastBlockTime = blockTime
s.ready = s.dbHeight == height
} | [
"func",
"(",
"s",
"*",
"Status",
")",
"DBUpdate",
"(",
"height",
"uint32",
",",
"blockTime",
"int64",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"dbHeight",
"=",
"height",
"\n",
"s",
".",
... | // DBUpdate updates both the height and time of the best DB block. Status.ready
// is set to true if Status.height is the same as Status.dbHeight. | [
"DBUpdate",
"updates",
"both",
"the",
"height",
"and",
"time",
"of",
"the",
"best",
"DB",
"block",
".",
"Status",
".",
"ready",
"is",
"set",
"to",
"true",
"if",
"Status",
".",
"height",
"is",
"the",
"same",
"as",
"Status",
".",
"dbHeight",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L499-L505 |
141,865 | decred/dcrdata | db/dcrpg/upgrades.go | String | func (v DatabaseVersion) String() string {
return fmt.Sprintf("%d.%d.%d", v.compat, v.schema, v.maint)
} | go | func (v DatabaseVersion) String() string {
return fmt.Sprintf("%d.%d.%d", v.compat, v.schema, v.maint)
} | [
"func",
"(",
"v",
"DatabaseVersion",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
".",
"compat",
",",
"v",
".",
"schema",
",",
"v",
".",
"maint",
")",
"\n",
"}"
] | // String implements Stringer for DatabaseVersion. | [
"String",
"implements",
"Stringer",
"for",
"DatabaseVersion",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades.go#L52-L54 |
141,866 | decred/dcrdata | db/dcrpg/upgrades.go | NewDatabaseVersion | func NewDatabaseVersion(major, minor, patch uint32) DatabaseVersion {
return DatabaseVersion{major, minor, patch}
} | go | func NewDatabaseVersion(major, minor, patch uint32) DatabaseVersion {
return DatabaseVersion{major, minor, patch}
} | [
"func",
"NewDatabaseVersion",
"(",
"major",
",",
"minor",
",",
"patch",
"uint32",
")",
"DatabaseVersion",
"{",
"return",
"DatabaseVersion",
"{",
"major",
",",
"minor",
",",
"patch",
"}",
"\n",
"}"
] | // NewDatabaseVersion returns a new DatabaseVersion with the version major.minor.patch | [
"NewDatabaseVersion",
"returns",
"a",
"new",
"DatabaseVersion",
"with",
"the",
"version",
"major",
".",
"minor",
".",
"patch"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades.go#L57-L59 |
141,867 | decred/dcrdata | db/dcrpg/upgrades.go | NeededToReach | func (v *DatabaseVersion) NeededToReach(other *DatabaseVersion) CompatAction {
switch {
case v.compat < other.compat:
return Rebuild
case v.compat < other.compat:
return TimeTravel
case v.schema < other.schema:
return Upgrade
case v.schema > other.schema:
return TimeTravel
case v.maint < other.maint:
re... | go | func (v *DatabaseVersion) NeededToReach(other *DatabaseVersion) CompatAction {
switch {
case v.compat < other.compat:
return Rebuild
case v.compat < other.compat:
return TimeTravel
case v.schema < other.schema:
return Upgrade
case v.schema > other.schema:
return TimeTravel
case v.maint < other.maint:
re... | [
"func",
"(",
"v",
"*",
"DatabaseVersion",
")",
"NeededToReach",
"(",
"other",
"*",
"DatabaseVersion",
")",
"CompatAction",
"{",
"switch",
"{",
"case",
"v",
".",
"compat",
"<",
"other",
".",
"compat",
":",
"return",
"Rebuild",
"\n",
"case",
"v",
".",
"com... | // NeededToReach describes what action is required for the DatabaseVersion to
// reach another version provided in the input argument. | [
"NeededToReach",
"describes",
"what",
"action",
"is",
"required",
"for",
"the",
"DatabaseVersion",
"to",
"reach",
"another",
"version",
"provided",
"in",
"the",
"input",
"argument",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades.go#L83-L100 |
141,868 | decred/dcrdata | db/dcrpg/upgrades.go | String | func (v CompatAction) String() string {
actions := map[CompatAction]string{
Rebuild: "rebuild",
Upgrade: "upgrade",
Maintenance: "maintenance",
TimeTravel: "time travel",
OK: "ok",
}
if actionStr, ok := actions[v]; ok {
return actionStr
}
return "unknown"
} | go | func (v CompatAction) String() string {
actions := map[CompatAction]string{
Rebuild: "rebuild",
Upgrade: "upgrade",
Maintenance: "maintenance",
TimeTravel: "time travel",
OK: "ok",
}
if actionStr, ok := actions[v]; ok {
return actionStr
}
return "unknown"
} | [
"func",
"(",
"v",
"CompatAction",
")",
"String",
"(",
")",
"string",
"{",
"actions",
":=",
"map",
"[",
"CompatAction",
"]",
"string",
"{",
"Rebuild",
":",
"\"",
"\"",
",",
"Upgrade",
":",
"\"",
"\"",
",",
"Maintenance",
":",
"\"",
"\"",
",",
"TimeTra... | // String implements Stringer for CompatAction. | [
"String",
"implements",
"Stringer",
"for",
"CompatAction",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades.go#L103-L115 |
141,869 | decred/dcrdata | dcrrates/rateserver/types.go | NewRateServer | func NewRateServer(index string, xcBot *exchanges.ExchangeBot) *RateServer {
return &RateServer{
btcIndex: index,
clientLock: new(sync.RWMutex),
clients: make(map[StreamID]RateClient),
xcBot: xcBot,
}
} | go | func NewRateServer(index string, xcBot *exchanges.ExchangeBot) *RateServer {
return &RateServer{
btcIndex: index,
clientLock: new(sync.RWMutex),
clients: make(map[StreamID]RateClient),
xcBot: xcBot,
}
} | [
"func",
"NewRateServer",
"(",
"index",
"string",
",",
"xcBot",
"*",
"exchanges",
".",
"ExchangeBot",
")",
"*",
"RateServer",
"{",
"return",
"&",
"RateServer",
"{",
"btcIndex",
":",
"index",
",",
"clientLock",
":",
"new",
"(",
"sync",
".",
"RWMutex",
")",
... | // NewRateServer is a constructor for a RateServer. | [
"NewRateServer",
"is",
"a",
"constructor",
"for",
"a",
"RateServer",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L37-L44 |
141,870 | decred/dcrdata | dcrrates/rateserver/types.go | sendStateList | func sendStateList(client RateClient, states map[string]*exchanges.ExchangeState) (err error) {
for token, state := range states {
err = client.SendExchangeUpdate(makeExchangeRateUpdate(&exchanges.ExchangeUpdate{
Token: token,
State: state,
}))
if err != nil {
log.Errorf("SendExchangeUpdate error for %s... | go | func sendStateList(client RateClient, states map[string]*exchanges.ExchangeState) (err error) {
for token, state := range states {
err = client.SendExchangeUpdate(makeExchangeRateUpdate(&exchanges.ExchangeUpdate{
Token: token,
State: state,
}))
if err != nil {
log.Errorf("SendExchangeUpdate error for %s... | [
"func",
"sendStateList",
"(",
"client",
"RateClient",
",",
"states",
"map",
"[",
"string",
"]",
"*",
"exchanges",
".",
"ExchangeState",
")",
"(",
"err",
"error",
")",
"{",
"for",
"token",
",",
"state",
":=",
"range",
"states",
"{",
"err",
"=",
"client",
... | // sendStateList is a helper for parsing the ExchangeBotState when a new client
// subscription is received. | [
"sendStateList",
"is",
"a",
"helper",
"for",
"parsing",
"the",
"ExchangeBotState",
"when",
"a",
"new",
"client",
"subscription",
"is",
"received",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L54-L66 |
141,871 | decred/dcrdata | dcrrates/rateserver/types.go | ReallySubscribeExchanges | func (server *RateServer) ReallySubscribeExchanges(hello *dcrrates.ExchangeSubscription, stream GRPCStream) (err error) {
// For now, require the ExchangeBot clients to have the same base currency.
// ToDo: Allow any index.
if hello.BtcIndex != server.btcIndex {
return fmt.Errorf("Exchange subscription has wrong B... | go | func (server *RateServer) ReallySubscribeExchanges(hello *dcrrates.ExchangeSubscription, stream GRPCStream) (err error) {
// For now, require the ExchangeBot clients to have the same base currency.
// ToDo: Allow any index.
if hello.BtcIndex != server.btcIndex {
return fmt.Errorf("Exchange subscription has wrong B... | [
"func",
"(",
"server",
"*",
"RateServer",
")",
"ReallySubscribeExchanges",
"(",
"hello",
"*",
"dcrrates",
".",
"ExchangeSubscription",
",",
"stream",
"GRPCStream",
")",
"(",
"err",
"error",
")",
"{",
"// For now, require the ExchangeBot clients to have the same base curre... | // ReallySubscribeExchanges stores the client and their exchange subscriptions.
// It waits for the client contexts Done channel to close and deletes the client
// from the RateServer.clients map. | [
"ReallySubscribeExchanges",
"stores",
"the",
"client",
"and",
"their",
"exchange",
"subscriptions",
".",
"It",
"waits",
"for",
"the",
"client",
"contexts",
"Done",
"channel",
"to",
"close",
"and",
"deletes",
"the",
"client",
"from",
"the",
"RateServer",
".",
"cl... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L78-L122 |
141,872 | decred/dcrdata | dcrrates/rateserver/types.go | addClient | func (server *RateServer) addClient(stream GRPCStream, hello *dcrrates.ExchangeSubscription) (RateClient, StreamID) {
server.clientLock.Lock()
defer server.clientLock.Unlock()
client := NewRateClient(stream, hello.GetExchanges())
streamCounter++
server.clients[streamCounter] = client
return client, streamCounter
... | go | func (server *RateServer) addClient(stream GRPCStream, hello *dcrrates.ExchangeSubscription) (RateClient, StreamID) {
server.clientLock.Lock()
defer server.clientLock.Unlock()
client := NewRateClient(stream, hello.GetExchanges())
streamCounter++
server.clients[streamCounter] = client
return client, streamCounter
... | [
"func",
"(",
"server",
"*",
"RateServer",
")",
"addClient",
"(",
"stream",
"GRPCStream",
",",
"hello",
"*",
"dcrrates",
".",
"ExchangeSubscription",
")",
"(",
"RateClient",
",",
"StreamID",
")",
"{",
"server",
".",
"clientLock",
".",
"Lock",
"(",
")",
"\n"... | // addClient adds a client to the map and advance the streamCounter. | [
"addClient",
"adds",
"a",
"client",
"to",
"the",
"map",
"and",
"advance",
"the",
"streamCounter",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L125-L132 |
141,873 | decred/dcrdata | dcrrates/rateserver/types.go | deleteClient | func (server *RateServer) deleteClient(sid StreamID) {
server.clientLock.Lock()
defer server.clientLock.Unlock()
delete(server.clients, sid)
} | go | func (server *RateServer) deleteClient(sid StreamID) {
server.clientLock.Lock()
defer server.clientLock.Unlock()
delete(server.clients, sid)
} | [
"func",
"(",
"server",
"*",
"RateServer",
")",
"deleteClient",
"(",
"sid",
"StreamID",
")",
"{",
"server",
".",
"clientLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"server",
".",
"clientLock",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"server",
"."... | // deleteClient deletes the client from the map. | [
"deleteClient",
"deletes",
"the",
"client",
"from",
"the",
"map",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L135-L139 |
141,874 | decred/dcrdata | dcrrates/rateserver/types.go | NewRateClient | func NewRateClient(stream GRPCStream, exchanges []string) RateClient {
return &rateClient{
stream: stream,
exchanges: exchanges,
}
} | go | func NewRateClient(stream GRPCStream, exchanges []string) RateClient {
return &rateClient{
stream: stream,
exchanges: exchanges,
}
} | [
"func",
"NewRateClient",
"(",
"stream",
"GRPCStream",
",",
"exchanges",
"[",
"]",
"string",
")",
"RateClient",
"{",
"return",
"&",
"rateClient",
"{",
"stream",
":",
"stream",
",",
"exchanges",
":",
"exchanges",
",",
"}",
"\n",
"}"
] | // NewRateClient is a constructor for rate client. It returns the RateClient
// interface rather than rateClient itself. | [
"NewRateClient",
"is",
"a",
"constructor",
"for",
"rate",
"client",
".",
"It",
"returns",
"the",
"RateClient",
"interface",
"rather",
"than",
"rateClient",
"itself",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L150-L155 |
141,875 | decred/dcrdata | dcrrates/rateserver/types.go | makeExchangeRateUpdate | func makeExchangeRateUpdate(update *exchanges.ExchangeUpdate) *dcrrates.ExchangeRateUpdate {
state := update.State
protoUpdate := &dcrrates.ExchangeRateUpdate{
Token: update.Token,
Price: state.Price,
BaseVolume: state.BaseVolume,
Volume: state.Volume,
Change: state.Change,
Stamp: s... | go | func makeExchangeRateUpdate(update *exchanges.ExchangeUpdate) *dcrrates.ExchangeRateUpdate {
state := update.State
protoUpdate := &dcrrates.ExchangeRateUpdate{
Token: update.Token,
Price: state.Price,
BaseVolume: state.BaseVolume,
Volume: state.Volume,
Change: state.Change,
Stamp: s... | [
"func",
"makeExchangeRateUpdate",
"(",
"update",
"*",
"exchanges",
".",
"ExchangeUpdate",
")",
"*",
"dcrrates",
".",
"ExchangeRateUpdate",
"{",
"state",
":=",
"update",
".",
"State",
"\n",
"protoUpdate",
":=",
"&",
"dcrrates",
".",
"ExchangeRateUpdate",
"{",
"To... | // Translate from the ExchangeBot's type to the gRPC type. | [
"Translate",
"from",
"the",
"ExchangeBot",
"s",
"type",
"to",
"the",
"gRPC",
"type",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L158-L211 |
141,876 | decred/dcrdata | dcrrates/rateserver/types.go | SendExchangeUpdate | func (client *rateClient) SendExchangeUpdate(update *dcrrates.ExchangeRateUpdate) (err error) {
for i := range client.exchanges {
if client.exchanges[i] == update.Token {
err = client.stream.Send(update)
return
}
}
return
} | go | func (client *rateClient) SendExchangeUpdate(update *dcrrates.ExchangeRateUpdate) (err error) {
for i := range client.exchanges {
if client.exchanges[i] == update.Token {
err = client.stream.Send(update)
return
}
}
return
} | [
"func",
"(",
"client",
"*",
"rateClient",
")",
"SendExchangeUpdate",
"(",
"update",
"*",
"dcrrates",
".",
"ExchangeRateUpdate",
")",
"(",
"err",
"error",
")",
"{",
"for",
"i",
":=",
"range",
"client",
".",
"exchanges",
"{",
"if",
"client",
".",
"exchanges"... | // SendExchangeUpdate sends the update if the client is subscribed to the exchange. | [
"SendExchangeUpdate",
"sends",
"the",
"update",
"if",
"the",
"client",
"is",
"subscribed",
"to",
"the",
"exchange",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L214-L222 |
141,877 | decred/dcrdata | blockdata/datasaver.go | NewBlockDataToSummaryStdOut | func NewBlockDataToSummaryStdOut(sdiffWinSize int64, m ...*sync.Mutex) *BlockDataToSummaryStdOut {
if len(m) > 1 {
panic("Too many inputs.")
}
if len(m) > 0 {
return &BlockDataToSummaryStdOut{m[0], sdiffWinSize}
}
return &BlockDataToSummaryStdOut{sdiffWinSize: sdiffWinSize}
} | go | func NewBlockDataToSummaryStdOut(sdiffWinSize int64, m ...*sync.Mutex) *BlockDataToSummaryStdOut {
if len(m) > 1 {
panic("Too many inputs.")
}
if len(m) > 0 {
return &BlockDataToSummaryStdOut{m[0], sdiffWinSize}
}
return &BlockDataToSummaryStdOut{sdiffWinSize: sdiffWinSize}
} | [
"func",
"NewBlockDataToSummaryStdOut",
"(",
"sdiffWinSize",
"int64",
",",
"m",
"...",
"*",
"sync",
".",
"Mutex",
")",
"*",
"BlockDataToSummaryStdOut",
"{",
"if",
"len",
"(",
"m",
")",
">",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",... | // NewBlockDataToSummaryStdOut creates a new BlockDataToSummaryStdOut with
// optional existing mutex | [
"NewBlockDataToSummaryStdOut",
"creates",
"a",
"new",
"BlockDataToSummaryStdOut",
"with",
"optional",
"existing",
"mutex"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/datasaver.go#L77-L85 |
141,878 | decred/dcrdata | blockdata/datasaver.go | NewBlockDataToJSONFiles | func NewBlockDataToJSONFiles(folder string, fileBase string,
m ...*sync.Mutex) *BlockDataToJSONFiles {
if len(m) > 1 {
panic("Too many inputs.")
}
var mtx *sync.Mutex
if len(m) > 0 {
mtx = m[0]
} else {
mtx = new(sync.Mutex)
}
return &BlockDataToJSONFiles{
fileSaver: fileSaver{
folder: folder,
... | go | func NewBlockDataToJSONFiles(folder string, fileBase string,
m ...*sync.Mutex) *BlockDataToJSONFiles {
if len(m) > 1 {
panic("Too many inputs.")
}
var mtx *sync.Mutex
if len(m) > 0 {
mtx = m[0]
} else {
mtx = new(sync.Mutex)
}
return &BlockDataToJSONFiles{
fileSaver: fileSaver{
folder: folder,
... | [
"func",
"NewBlockDataToJSONFiles",
"(",
"folder",
"string",
",",
"fileBase",
"string",
",",
"m",
"...",
"*",
"sync",
".",
"Mutex",
")",
"*",
"BlockDataToJSONFiles",
"{",
"if",
"len",
"(",
"m",
")",
">",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
... | // NewBlockDataToJSONFiles creates a new BlockDataToJSONFiles with optional
// existing mutex | [
"NewBlockDataToJSONFiles",
"creates",
"a",
"new",
"BlockDataToJSONFiles",
"with",
"optional",
"existing",
"mutex"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/datasaver.go#L89-L110 |
141,879 | decred/dcrdata | blockdata/datasaver.go | Store | func (s *BlockDataToJSONStdOut) Store(data *BlockData, _ *wire.MsgBlock) error {
if s.mtx != nil {
s.mtx.Lock()
defer s.mtx.Unlock()
}
// Marshall all the block data results in to a single JSON object, indented
jsonConcat, err := JSONFormatBlockData(data)
if err != nil {
return err
}
// Write JSON to std... | go | func (s *BlockDataToJSONStdOut) Store(data *BlockData, _ *wire.MsgBlock) error {
if s.mtx != nil {
s.mtx.Lock()
defer s.mtx.Unlock()
}
// Marshall all the block data results in to a single JSON object, indented
jsonConcat, err := JSONFormatBlockData(data)
if err != nil {
return err
}
// Write JSON to std... | [
"func",
"(",
"s",
"*",
"BlockDataToJSONStdOut",
")",
"Store",
"(",
"data",
"*",
"BlockData",
",",
"_",
"*",
"wire",
".",
"MsgBlock",
")",
"error",
"{",
"if",
"s",
".",
"mtx",
"!=",
"nil",
"{",
"s",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer"... | // Store writes BlockData to stdout in JSON format | [
"Store",
"writes",
"BlockData",
"to",
"stdout",
"in",
"JSON",
"format"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/datasaver.go#L113-L131 |
141,880 | decred/dcrdata | blockdata/datasaver.go | Store | func (s *BlockDataToSummaryStdOut) Store(data *BlockData, _ *wire.MsgBlock) error {
if s.mtx != nil {
s.mtx.Lock()
defer s.mtx.Unlock()
}
fmt.Printf("\nBlock %v:\n", data.Header.Height)
fmt.Printf(" Stake difficulty: %9.3f -> %.3f (current -> next block)\n",
data.CurrentStakeDiff.CurrentSta... | go | func (s *BlockDataToSummaryStdOut) Store(data *BlockData, _ *wire.MsgBlock) error {
if s.mtx != nil {
s.mtx.Lock()
defer s.mtx.Unlock()
}
fmt.Printf("\nBlock %v:\n", data.Header.Height)
fmt.Printf(" Stake difficulty: %9.3f -> %.3f (current -> next block)\n",
data.CurrentStakeDiff.CurrentSta... | [
"func",
"(",
"s",
"*",
"BlockDataToSummaryStdOut",
")",
"Store",
"(",
"data",
"*",
"BlockData",
",",
"_",
"*",
"wire",
".",
"MsgBlock",
")",
"error",
"{",
"if",
"s",
".",
"mtx",
"!=",
"nil",
"{",
"s",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"def... | // Store writes BlockData to stdout as plain text summary | [
"Store",
"writes",
"BlockData",
"to",
"stdout",
"as",
"plain",
"text",
"summary"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/datasaver.go#L134-L163 |
141,881 | decred/dcrdata | blockdata/datasaver.go | Store | func (s *BlockDataToJSONFiles) Store(data *BlockData, _ *wire.MsgBlock) error {
if s.mtx != nil {
s.mtx.Lock()
defer s.mtx.Unlock()
}
// Marshall all the block data results in to a single JSON object, indented
jsonConcat, err := JSONFormatBlockData(data)
if err != nil {
return err
}
// Write JSON to a fi... | go | func (s *BlockDataToJSONFiles) Store(data *BlockData, _ *wire.MsgBlock) error {
if s.mtx != nil {
s.mtx.Lock()
defer s.mtx.Unlock()
}
// Marshall all the block data results in to a single JSON object, indented
jsonConcat, err := JSONFormatBlockData(data)
if err != nil {
return err
}
// Write JSON to a fi... | [
"func",
"(",
"s",
"*",
"BlockDataToJSONFiles",
")",
"Store",
"(",
"data",
"*",
"BlockData",
",",
"_",
"*",
"wire",
".",
"MsgBlock",
")",
"error",
"{",
"if",
"s",
".",
"mtx",
"!=",
"nil",
"{",
"s",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",... | // Store writes BlockData to a file in JSON format
// The file name is nameBase+height+".json". | [
"Store",
"writes",
"BlockData",
"to",
"a",
"file",
"in",
"JSON",
"format",
"The",
"file",
"name",
"is",
"nameBase",
"+",
"height",
"+",
".",
"json",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/datasaver.go#L167-L194 |
141,882 | decred/dcrdata | blockdata/datasaver.go | JSONFormatBlockData | func JSONFormatBlockData(data *BlockData) (*bytes.Buffer, error) {
var jsonAll bytes.Buffer
jsonAll.WriteString("{\"estimatestakediff\": ")
stakeDiffEstJSON, err := json.Marshal(data.EstStakeDiff)
if err != nil {
return nil, err
}
jsonAll.Write(stakeDiffEstJSON)
//stakeDiffEstJSON, err := json.MarshalIndent(d... | go | func JSONFormatBlockData(data *BlockData) (*bytes.Buffer, error) {
var jsonAll bytes.Buffer
jsonAll.WriteString("{\"estimatestakediff\": ")
stakeDiffEstJSON, err := json.Marshal(data.EstStakeDiff)
if err != nil {
return nil, err
}
jsonAll.Write(stakeDiffEstJSON)
//stakeDiffEstJSON, err := json.MarshalIndent(d... | [
"func",
"JSONFormatBlockData",
"(",
"data",
"*",
"BlockData",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"error",
")",
"{",
"var",
"jsonAll",
"bytes",
".",
"Buffer",
"\n\n",
"jsonAll",
".",
"WriteString",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"s... | // JSONFormatBlockData concatenates block data results into a single JSON
// object with primary keys for the result type | [
"JSONFormatBlockData",
"concatenates",
"block",
"data",
"results",
"into",
"a",
"single",
"JSON",
"object",
"with",
"primary",
"keys",
"for",
"the",
"result",
"type"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/datasaver.go#L204-L253 |
141,883 | decred/dcrdata | blockdata/datasaver.go | Store | func (s BlockTrigger) Store(bd *BlockData, _ *wire.MsgBlock) error {
s.Saver(bd.Header.Hash, bd.Header.Height)
return nil
} | go | func (s BlockTrigger) Store(bd *BlockData, _ *wire.MsgBlock) error {
s.Saver(bd.Header.Hash, bd.Header.Height)
return nil
} | [
"func",
"(",
"s",
"BlockTrigger",
")",
"Store",
"(",
"bd",
"*",
"BlockData",
",",
"_",
"*",
"wire",
".",
"MsgBlock",
")",
"error",
"{",
"s",
".",
"Saver",
"(",
"bd",
".",
"Header",
".",
"Hash",
",",
"bd",
".",
"Header",
".",
"Height",
")",
"\n",
... | // Store reduces the block data to the hash and height in builtin types,
// and passes the data to the saver. | [
"Store",
"reduces",
"the",
"block",
"data",
"to",
"the",
"hash",
"and",
"height",
"in",
"builtin",
"types",
"and",
"passes",
"the",
"data",
"to",
"the",
"saver",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/datasaver.go#L263-L266 |
141,884 | decred/dcrdata | blockdata/blockdata.go | ToStakeInfoExtended | func (b *BlockData) ToStakeInfoExtended() apitypes.StakeInfoExtended {
return apitypes.StakeInfoExtended{
Hash: b.Header.Hash,
Feeinfo: b.FeeInfo,
StakeDiff: b.CurrentStakeDiff.CurrentStakeDifficulty,
PriceWindowNum: b.PriceWindowNum,
IdxBlockInWindow: b.IdxBlockInWindow,
Pool... | go | func (b *BlockData) ToStakeInfoExtended() apitypes.StakeInfoExtended {
return apitypes.StakeInfoExtended{
Hash: b.Header.Hash,
Feeinfo: b.FeeInfo,
StakeDiff: b.CurrentStakeDiff.CurrentStakeDifficulty,
PriceWindowNum: b.PriceWindowNum,
IdxBlockInWindow: b.IdxBlockInWindow,
Pool... | [
"func",
"(",
"b",
"*",
"BlockData",
")",
"ToStakeInfoExtended",
"(",
")",
"apitypes",
".",
"StakeInfoExtended",
"{",
"return",
"apitypes",
".",
"StakeInfoExtended",
"{",
"Hash",
":",
"b",
".",
"Header",
".",
"Hash",
",",
"Feeinfo",
":",
"b",
".",
"FeeInfo"... | // ToStakeInfoExtended returns an apitypes.StakeInfoExtended object from the
// blockdata | [
"ToStakeInfoExtended",
"returns",
"an",
"apitypes",
".",
"StakeInfoExtended",
"object",
"from",
"the",
"blockdata"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/blockdata.go#L42-L51 |
141,885 | decred/dcrdata | blockdata/blockdata.go | ToStakeInfoExtendedEstimates | func (b *BlockData) ToStakeInfoExtendedEstimates() apitypes.StakeInfoExtendedEstimates {
return apitypes.StakeInfoExtendedEstimates{
Hash: b.Header.Hash,
Feeinfo: b.FeeInfo,
StakeDiff: apitypes.StakeDiff{
GetStakeDifficultyResult: b.CurrentStakeDiff,
Estimates: b.EstStakeDiff,
IdxBlock... | go | func (b *BlockData) ToStakeInfoExtendedEstimates() apitypes.StakeInfoExtendedEstimates {
return apitypes.StakeInfoExtendedEstimates{
Hash: b.Header.Hash,
Feeinfo: b.FeeInfo,
StakeDiff: apitypes.StakeDiff{
GetStakeDifficultyResult: b.CurrentStakeDiff,
Estimates: b.EstStakeDiff,
IdxBlock... | [
"func",
"(",
"b",
"*",
"BlockData",
")",
"ToStakeInfoExtendedEstimates",
"(",
")",
"apitypes",
".",
"StakeInfoExtendedEstimates",
"{",
"return",
"apitypes",
".",
"StakeInfoExtendedEstimates",
"{",
"Hash",
":",
"b",
".",
"Header",
".",
"Hash",
",",
"Feeinfo",
":"... | // ToStakeInfoExtendedEstimates returns an apitypes.StakeInfoExtendedEstimates
// object from the blockdata | [
"ToStakeInfoExtendedEstimates",
"returns",
"an",
"apitypes",
".",
"StakeInfoExtendedEstimates",
"object",
"from",
"the",
"blockdata"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/blockdata.go#L55-L70 |
141,886 | decred/dcrdata | blockdata/blockdata.go | ToBlockSummary | func (b *BlockData) ToBlockSummary() apitypes.BlockDataBasic {
t := dbtypes.NewTimeDefFromUNIX(b.Header.Time)
return apitypes.BlockDataBasic{
Height: b.Header.Height,
Size: b.Header.Size,
Hash: b.Header.Hash,
Difficulty: b.Header.Difficulty,
StakeDiff: b.Header.SBits,
Time: apitypes... | go | func (b *BlockData) ToBlockSummary() apitypes.BlockDataBasic {
t := dbtypes.NewTimeDefFromUNIX(b.Header.Time)
return apitypes.BlockDataBasic{
Height: b.Header.Height,
Size: b.Header.Size,
Hash: b.Header.Hash,
Difficulty: b.Header.Difficulty,
StakeDiff: b.Header.SBits,
Time: apitypes... | [
"func",
"(",
"b",
"*",
"BlockData",
")",
"ToBlockSummary",
"(",
")",
"apitypes",
".",
"BlockDataBasic",
"{",
"t",
":=",
"dbtypes",
".",
"NewTimeDefFromUNIX",
"(",
"b",
".",
"Header",
".",
"Time",
")",
"\n",
"return",
"apitypes",
".",
"BlockDataBasic",
"{",... | // ToBlockSummary returns an apitypes.BlockDataBasic object from the blockdata | [
"ToBlockSummary",
"returns",
"an",
"apitypes",
".",
"BlockDataBasic",
"object",
"from",
"the",
"blockdata"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/blockdata.go#L73-L84 |
141,887 | decred/dcrdata | blockdata/blockdata.go | ToBlockExplorerSummary | func (b *BlockData) ToBlockExplorerSummary() apitypes.BlockExplorerBasic {
extra := b.ExtraInfo
t := dbtypes.NewTimeDefFromUNIX(b.Header.Time)
return apitypes.BlockExplorerBasic{
Height: b.Header.Height,
Size: b.Header.Size,
Voters: b.Header.Voters,
Revocatio... | go | func (b *BlockData) ToBlockExplorerSummary() apitypes.BlockExplorerBasic {
extra := b.ExtraInfo
t := dbtypes.NewTimeDefFromUNIX(b.Header.Time)
return apitypes.BlockExplorerBasic{
Height: b.Header.Height,
Size: b.Header.Size,
Voters: b.Header.Voters,
Revocatio... | [
"func",
"(",
"b",
"*",
"BlockData",
")",
"ToBlockExplorerSummary",
"(",
")",
"apitypes",
".",
"BlockExplorerBasic",
"{",
"extra",
":=",
"b",
".",
"ExtraInfo",
"\n",
"t",
":=",
"dbtypes",
".",
"NewTimeDefFromUNIX",
"(",
"b",
".",
"Header",
".",
"Time",
")",... | // ToBlockExplorerSummary returns a BlockExplorerBasic | [
"ToBlockExplorerSummary",
"returns",
"a",
"BlockExplorerBasic"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/blockdata.go#L87-L100 |
141,888 | decred/dcrdata | blockdata/blockdata.go | NewCollector | func NewCollector(dcrdChainSvr *rpcclient.Client, params *chaincfg.Params,
stakeDB *stakedb.StakeDatabase) *Collector {
return &Collector{
dcrdChainSvr: dcrdChainSvr,
netParams: params,
stakeDB: stakeDB,
}
} | go | func NewCollector(dcrdChainSvr *rpcclient.Client, params *chaincfg.Params,
stakeDB *stakedb.StakeDatabase) *Collector {
return &Collector{
dcrdChainSvr: dcrdChainSvr,
netParams: params,
stakeDB: stakeDB,
}
} | [
"func",
"NewCollector",
"(",
"dcrdChainSvr",
"*",
"rpcclient",
".",
"Client",
",",
"params",
"*",
"chaincfg",
".",
"Params",
",",
"stakeDB",
"*",
"stakedb",
".",
"StakeDatabase",
")",
"*",
"Collector",
"{",
"return",
"&",
"Collector",
"{",
"dcrdChainSvr",
":... | // NewCollector creates a new Collector. | [
"NewCollector",
"creates",
"a",
"new",
"Collector",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/blockdata.go#L111-L118 |
141,889 | decred/dcrdata | blockdata/blockdata.go | CollectAPITypes | func (t *Collector) CollectAPITypes(hash *chainhash.Hash) (*apitypes.BlockDataBasic, *apitypes.StakeInfoExtended) {
blockDataBasic, feeInfoBlock, _, _, _, err := t.CollectBlockInfo(hash)
if err != nil {
return nil, nil
}
height := int64(blockDataBasic.Height)
winSize := t.netParams.StakeDiffWindowSize
stakeIn... | go | func (t *Collector) CollectAPITypes(hash *chainhash.Hash) (*apitypes.BlockDataBasic, *apitypes.StakeInfoExtended) {
blockDataBasic, feeInfoBlock, _, _, _, err := t.CollectBlockInfo(hash)
if err != nil {
return nil, nil
}
height := int64(blockDataBasic.Height)
winSize := t.netParams.StakeDiffWindowSize
stakeIn... | [
"func",
"(",
"t",
"*",
"Collector",
")",
"CollectAPITypes",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"apitypes",
".",
"BlockDataBasic",
",",
"*",
"apitypes",
".",
"StakeInfoExtended",
")",
"{",
"blockDataBasic",
",",
"feeInfoBlock",
",",
... | // CollectAPITypes uses CollectBlockInfo to collect block data, then organizes
// it into the BlockDataBasic and StakeInfoExtended and dcrdataapi types. | [
"CollectAPITypes",
"uses",
"CollectBlockInfo",
"to",
"collect",
"block",
"data",
"then",
"organizes",
"it",
"into",
"the",
"BlockDataBasic",
"and",
"StakeInfoExtended",
"and",
"dcrdataapi",
"types",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/blockdata.go#L122-L141 |
141,890 | decred/dcrdata | blockdata/blockdata.go | CollectHash | func (t *Collector) CollectHash(hash *chainhash.Hash) (*BlockData, *wire.MsgBlock, error) {
// In case of a very fast block, make sure previous call to collect is not
// still running, or dcrd may be mad.
t.mtx.Lock()
defer t.mtx.Unlock()
// Time this function
defer func(start time.Time) {
log.Debugf("Collecto... | go | func (t *Collector) CollectHash(hash *chainhash.Hash) (*BlockData, *wire.MsgBlock, error) {
// In case of a very fast block, make sure previous call to collect is not
// still running, or dcrd may be mad.
t.mtx.Lock()
defer t.mtx.Unlock()
// Time this function
defer func(start time.Time) {
log.Debugf("Collecto... | [
"func",
"(",
"t",
"*",
"Collector",
")",
"CollectHash",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"BlockData",
",",
"*",
"wire",
".",
"MsgBlock",
",",
"error",
")",
"{",
"// In case of a very fast block, make sure previous call to collect is not",... | // CollectHash collects chain data at the block with the specified hash. | [
"CollectHash",
"collects",
"chain",
"data",
"at",
"the",
"block",
"with",
"the",
"specified",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/blockdata.go#L225-L277 |
141,891 | decred/dcrdata | blockdata/blockdata.go | Collect | func (t *Collector) Collect() (*BlockData, *wire.MsgBlock, error) {
// In case of a very fast block, make sure previous call to collect is not
// still running, or dcrd may be mad.
t.mtx.Lock()
defer t.mtx.Unlock()
// Time this function
defer func(start time.Time) {
log.Debugf("Collector.Collect() completed in... | go | func (t *Collector) Collect() (*BlockData, *wire.MsgBlock, error) {
// In case of a very fast block, make sure previous call to collect is not
// still running, or dcrd may be mad.
t.mtx.Lock()
defer t.mtx.Unlock()
// Time this function
defer func(start time.Time) {
log.Debugf("Collector.Collect() completed in... | [
"func",
"(",
"t",
"*",
"Collector",
")",
"Collect",
"(",
")",
"(",
"*",
"BlockData",
",",
"*",
"wire",
".",
"MsgBlock",
",",
"error",
")",
"{",
"// In case of a very fast block, make sure previous call to collect is not",
"// still running, or dcrd may be mad.",
"t",
... | // Collect collects chain data at the current best block. | [
"Collect",
"collects",
"chain",
"data",
"at",
"the",
"current",
"best",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/blockdata.go#L280-L367 |
141,892 | decred/dcrdata | explorer/websocket.go | NewWebsocketHub | func NewWebsocketHub() *WebsocketHub {
return &WebsocketHub{
clients: make(map[*hubSpoke]*clientHubSpoke),
Register: make(chan *clientHubSpoke),
Unregister: make(chan *hubSpoke),
HubRelay: make(chan hubMessage),
newTxBuffer: make([]*types.MempoolTx, 0, newTxBufferSize),
... | go | func NewWebsocketHub() *WebsocketHub {
return &WebsocketHub{
clients: make(map[*hubSpoke]*clientHubSpoke),
Register: make(chan *clientHubSpoke),
Unregister: make(chan *hubSpoke),
HubRelay: make(chan hubMessage),
newTxBuffer: make([]*types.MempoolTx, 0, newTxBufferSize),
... | [
"func",
"NewWebsocketHub",
"(",
")",
"*",
"WebsocketHub",
"{",
"return",
"&",
"WebsocketHub",
"{",
"clients",
":",
"make",
"(",
"map",
"[",
"*",
"hubSpoke",
"]",
"*",
"clientHubSpoke",
")",
",",
"Register",
":",
"make",
"(",
"chan",
"*",
"clientHubSpoke",
... | // NewWebsocketHub creates a new WebsocketHub | [
"NewWebsocketHub",
"creates",
"a",
"new",
"WebsocketHub"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/websocket.go#L90-L102 |
141,893 | decred/dcrdata | explorer/websocket.go | NumClients | func (wsh *WebsocketHub) NumClients() int {
// Swallow any type assertion error since the default int of 0 is OK.
n, _ := wsh.numClients.Load().(int)
return n
} | go | func (wsh *WebsocketHub) NumClients() int {
// Swallow any type assertion error since the default int of 0 is OK.
n, _ := wsh.numClients.Load().(int)
return n
} | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"NumClients",
"(",
")",
"int",
"{",
"// Swallow any type assertion error since the default int of 0 is OK.",
"n",
",",
"_",
":=",
"wsh",
".",
"numClients",
".",
"Load",
"(",
")",
".",
"(",
"int",
")",
"\n",
"return... | // NumClients returns the number of clients connected to the websocket hub. | [
"NumClients",
"returns",
"the",
"number",
"of",
"clients",
"connected",
"to",
"the",
"websocket",
"hub",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/websocket.go#L111-L115 |
141,894 | decred/dcrdata | explorer/websocket.go | RegisterClient | func (wsh *WebsocketHub) RegisterClient(c *hubSpoke, xcChan exchangeChannel) *client {
cl := new(client)
wsh.Register <- &clientHubSpoke{cl, c, xcChan}
return cl
} | go | func (wsh *WebsocketHub) RegisterClient(c *hubSpoke, xcChan exchangeChannel) *client {
cl := new(client)
wsh.Register <- &clientHubSpoke{cl, c, xcChan}
return cl
} | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"RegisterClient",
"(",
"c",
"*",
"hubSpoke",
",",
"xcChan",
"exchangeChannel",
")",
"*",
"client",
"{",
"cl",
":=",
"new",
"(",
"client",
")",
"\n",
"wsh",
".",
"Register",
"<-",
"&",
"clientHubSpoke",
"{",
... | // RegisterClient registers a websocket connection with the hub, and returns a
// pointer to the new client data object. | [
"RegisterClient",
"registers",
"a",
"websocket",
"connection",
"with",
"the",
"hub",
"and",
"returns",
"a",
"pointer",
"to",
"the",
"new",
"client",
"data",
"object",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/websocket.go#L123-L127 |
141,895 | decred/dcrdata | explorer/websocket.go | pingClients | func (wsh *WebsocketHub) pingClients() chan<- struct{} {
stopPing := make(chan struct{})
go func() {
// start the client ping ticker
ticker := time.NewTicker(pingInterval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
wsh.HubRelay <- pstypes.HubMessage{Signal: sigPingAndUserCount}
case _,... | go | func (wsh *WebsocketHub) pingClients() chan<- struct{} {
stopPing := make(chan struct{})
go func() {
// start the client ping ticker
ticker := time.NewTicker(pingInterval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
wsh.HubRelay <- pstypes.HubMessage{Signal: sigPingAndUserCount}
case _,... | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"pingClients",
"(",
")",
"chan",
"<-",
"struct",
"{",
"}",
"{",
"stopPing",
":=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"// start the client ping ticker",
"ticker"... | // Periodically ping clients over websocket connection. Stop the ping loop by
// closing the returned channel. | [
"Periodically",
"ping",
"clients",
"over",
"websocket",
"connection",
".",
"Stop",
"the",
"ping",
"loop",
"by",
"closing",
"the",
"returned",
"channel",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/websocket.go#L171-L193 |
141,896 | decred/dcrdata | explorer/websocket.go | addTxToBuffer | func (wsh *WebsocketHub) addTxToBuffer(tx *types.MempoolTx) bool {
wsh.bufferMtx.Lock()
defer wsh.bufferMtx.Unlock()
wsh.newTxBuffer = append(wsh.newTxBuffer, tx)
return len(wsh.newTxBuffer) >= newTxBufferSize
} | go | func (wsh *WebsocketHub) addTxToBuffer(tx *types.MempoolTx) bool {
wsh.bufferMtx.Lock()
defer wsh.bufferMtx.Unlock()
wsh.newTxBuffer = append(wsh.newTxBuffer, tx)
return len(wsh.newTxBuffer) >= newTxBufferSize
} | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"addTxToBuffer",
"(",
"tx",
"*",
"types",
".",
"MempoolTx",
")",
"bool",
"{",
"wsh",
".",
"bufferMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"wsh",
".",
"bufferMtx",
".",
"Unlock",
"(",
")",
"\n\n",
"wsh"... | // addTxToBuffer adds a tx to the buffer, then returns if the buffer is full | [
"addTxToBuffer",
"adds",
"a",
"tx",
"to",
"the",
"buffer",
"then",
"returns",
"if",
"the",
"buffer",
"is",
"full"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/websocket.go#L358-L365 |
141,897 | decred/dcrdata | explorer/websocket.go | periodicBufferSend | func (wsh *WebsocketHub) periodicBufferSend() {
ticker := time.NewTicker(bufferTickerInterval * time.Second)
for {
select {
case <-ticker.C:
wsh.sendBufferChan <- bufferSend
case sig := <-wsh.bufferTickerChan:
switch sig {
case tickerSigReset:
ticker.Stop()
ticker = time.NewTicker(bufferTickerI... | go | func (wsh *WebsocketHub) periodicBufferSend() {
ticker := time.NewTicker(bufferTickerInterval * time.Second)
for {
select {
case <-ticker.C:
wsh.sendBufferChan <- bufferSend
case sig := <-wsh.bufferTickerChan:
switch sig {
case tickerSigReset:
ticker.Stop()
ticker = time.NewTicker(bufferTickerI... | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"periodicBufferSend",
"(",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"bufferTickerInterval",
"*",
"time",
".",
"Second",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"ticker",
".",
"C",
... | // periodicBufferSend initiates a buffer send every bufferTickerInterval seconds | [
"periodicBufferSend",
"initiates",
"a",
"buffer",
"send",
"every",
"bufferTickerInterval",
"seconds"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/websocket.go#L368-L385 |
141,898 | decred/dcrdata | blockdata/chainmonitor.go | NewChainMonitor | func NewChainMonitor(ctx context.Context, collector *Collector, savers []BlockDataSaver,
reorgSavers []BlockDataSaver, wg *sync.WaitGroup, addrs map[string]txhelpers.TxAction,
recvTxBlockChan chan *txhelpers.BlockWatchedTx, reorgChan chan *txhelpers.ReorgData) *chainMonitor {
return &chainMonitor{
ctx: ... | go | func NewChainMonitor(ctx context.Context, collector *Collector, savers []BlockDataSaver,
reorgSavers []BlockDataSaver, wg *sync.WaitGroup, addrs map[string]txhelpers.TxAction,
recvTxBlockChan chan *txhelpers.BlockWatchedTx, reorgChan chan *txhelpers.ReorgData) *chainMonitor {
return &chainMonitor{
ctx: ... | [
"func",
"NewChainMonitor",
"(",
"ctx",
"context",
".",
"Context",
",",
"collector",
"*",
"Collector",
",",
"savers",
"[",
"]",
"BlockDataSaver",
",",
"reorgSavers",
"[",
"]",
"BlockDataSaver",
",",
"wg",
"*",
"sync",
".",
"WaitGroup",
",",
"addrs",
"map",
... | // NewChainMonitor creates a new chainMonitor. | [
"NewChainMonitor",
"creates",
"a",
"new",
"chainMonitor",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/blockdata/chainmonitor.go#L34-L47 |
141,899 | decred/dcrdata | db/dcrpg/pgblockchain.go | TicketPoolData | func TicketPoolData(interval dbtypes.TimeBasedGrouping, height int64) (timeGraph *dbtypes.PoolTicketsData,
priceGraph *dbtypes.PoolTicketsData, donutChart *dbtypes.PoolTicketsData, actualHeight int64, intervalFound, isStale bool) {
ticketPoolGraphsCache.RLock()
defer ticketPoolGraphsCache.RUnlock()
var tFound, pFo... | go | func TicketPoolData(interval dbtypes.TimeBasedGrouping, height int64) (timeGraph *dbtypes.PoolTicketsData,
priceGraph *dbtypes.PoolTicketsData, donutChart *dbtypes.PoolTicketsData, actualHeight int64, intervalFound, isStale bool) {
ticketPoolGraphsCache.RLock()
defer ticketPoolGraphsCache.RUnlock()
var tFound, pFo... | [
"func",
"TicketPoolData",
"(",
"interval",
"dbtypes",
".",
"TimeBasedGrouping",
",",
"height",
"int64",
")",
"(",
"timeGraph",
"*",
"dbtypes",
".",
"PoolTicketsData",
",",
"priceGraph",
"*",
"dbtypes",
".",
"PoolTicketsData",
",",
"donutChart",
"*",
"dbtypes",
"... | // TicketPoolData is a thread-safe way to access the ticketpool graphs data
// stored in the cache. | [
"TicketPoolData",
"is",
"a",
"thread",
"-",
"safe",
"way",
"to",
"access",
"the",
"ticketpool",
"graphs",
"data",
"stored",
"in",
"the",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/pgblockchain.go#L81-L96 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.