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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
142,200 | decred/dcrdata | db/dcrpg/system.go | RetrieveSysSettingSyncCommit | func RetrieveSysSettingSyncCommit(db *sql.DB) (syncCommit string, err error) {
err = db.QueryRow(internal.RetrieveSyncCommitSetting).Scan(&syncCommit)
return
} | go | func RetrieveSysSettingSyncCommit(db *sql.DB) (syncCommit string, err error) {
err = db.QueryRow(internal.RetrieveSyncCommitSetting).Scan(&syncCommit)
return
} | [
"func",
"RetrieveSysSettingSyncCommit",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"syncCommit",
"string",
",",
"err",
"error",
")",
"{",
"err",
"=",
"db",
".",
"QueryRow",
"(",
"internal",
".",
"RetrieveSyncCommitSetting",
")",
".",
"Scan",
"(",
"&",
"... | // RetrieveSysSettingSyncCommit retrieves the synchronous_commit setting. | [
"RetrieveSysSettingSyncCommit",
"retrieves",
"the",
"synchronous_commit",
"setting",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L220-L223 |
142,201 | decred/dcrdata | db/dcrpg/system.go | SetSynchronousCommit | func SetSynchronousCommit(db *sql.DB, syncCommit string) error {
_, err := db.Exec(fmt.Sprintf(`SET synchronous_commit TO %s;`, syncCommit))
return err
} | go | func SetSynchronousCommit(db *sql.DB, syncCommit string) error {
_, err := db.Exec(fmt.Sprintf(`SET synchronous_commit TO %s;`, syncCommit))
return err
} | [
"func",
"SetSynchronousCommit",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"syncCommit",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"db",
".",
"Exec",
"(",
"fmt",
".",
"Sprintf",
"(",
"`SET synchronous_commit TO %s;`",
",",
"syncCommit",
")",
")",
"... | // SetSynchronousCommit sets the synchronous_commit setting. | [
"SetSynchronousCommit",
"sets",
"the",
"synchronous_commit",
"setting",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L226-L229 |
142,202 | decred/dcrdata | db/dcrpg/system.go | CheckCurrentTimeZone | func CheckCurrentTimeZone(db *sql.DB) (currentTZ string, err error) {
if err = db.QueryRow(`SHOW TIME ZONE`).Scan(¤tTZ); err != nil {
err = fmt.Errorf("unable to query current time zone: %v", err)
}
return
} | go | func CheckCurrentTimeZone(db *sql.DB) (currentTZ string, err error) {
if err = db.QueryRow(`SHOW TIME ZONE`).Scan(¤tTZ); err != nil {
err = fmt.Errorf("unable to query current time zone: %v", err)
}
return
} | [
"func",
"CheckCurrentTimeZone",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"currentTZ",
"string",
",",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"db",
".",
"QueryRow",
"(",
"`SHOW TIME ZONE`",
")",
".",
"Scan",
"(",
"&",
"currentTZ",
")",
";",
"er... | // CheckCurrentTimeZone queries for the currently set postgres time zone. | [
"CheckCurrentTimeZone",
"queries",
"for",
"the",
"currently",
"set",
"postgres",
"time",
"zone",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L232-L237 |
142,203 | decred/dcrdata | db/dcrpg/system.go | CheckDefaultTimeZone | func CheckDefaultTimeZone(db *sql.DB) (defaultTZ, currentTZ string, err error) {
// Remember the current time zone before switching to default.
currentTZ, err = CheckCurrentTimeZone(db)
if err != nil {
return
}
// Switch to DEFAULT/LOCAL.
_, err = db.Exec(`SET TIME ZONE DEFAULT`)
if err != nil {
err = fmt.E... | go | func CheckDefaultTimeZone(db *sql.DB) (defaultTZ, currentTZ string, err error) {
// Remember the current time zone before switching to default.
currentTZ, err = CheckCurrentTimeZone(db)
if err != nil {
return
}
// Switch to DEFAULT/LOCAL.
_, err = db.Exec(`SET TIME ZONE DEFAULT`)
if err != nil {
err = fmt.E... | [
"func",
"CheckDefaultTimeZone",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"defaultTZ",
",",
"currentTZ",
"string",
",",
"err",
"error",
")",
"{",
"// Remember the current time zone before switching to default.",
"currentTZ",
",",
"err",
"=",
"CheckCurrentTimeZone",
... | // CheckDefaultTimeZone queries for the default postgres time zone. This is the
// value that would be observed if postgres were restarted using its current
// configuration. The currently set time zone is also returned. | [
"CheckDefaultTimeZone",
"queries",
"for",
"the",
"default",
"postgres",
"time",
"zone",
".",
"This",
"is",
"the",
"value",
"that",
"would",
"be",
"observed",
"if",
"postgres",
"were",
"restarted",
"using",
"its",
"current",
"configuration",
".",
"The",
"currentl... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/system.go#L242-L268 |
142,204 | decred/dcrdata | signal.go | withShutdownCancel | func withShutdownCancel(ctx context.Context) context.Context {
ctx, cancel := context.WithCancel(ctx)
go func() {
<-shutdownSignal
cancel()
}()
return ctx
} | go | func withShutdownCancel(ctx context.Context) context.Context {
ctx, cancel := context.WithCancel(ctx)
go func() {
<-shutdownSignal
cancel()
}()
return ctx
} | [
"func",
"withShutdownCancel",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"ctx",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"<-",
"shutdownSignal",
"\n",
"cancel"... | // withShutdownCancel creates a copy of a context that is cancelled whenever
// shutdown is invoked through an interrupt signal or from an JSON-RPC stop
// request. | [
"withShutdownCancel",
"creates",
"a",
"copy",
"of",
"a",
"context",
"that",
"is",
"cancelled",
"whenever",
"shutdown",
"is",
"invoked",
"through",
"an",
"interrupt",
"signal",
"or",
"from",
"an",
"JSON",
"-",
"RPC",
"stop",
"request",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/signal.go#L43-L50 |
142,205 | decred/dcrdata | signal.go | shutdownListener | func shutdownListener() {
interruptChannel := make(chan os.Signal, 1)
signal.Notify(interruptChannel, signals...)
// Listen for the initial shutdown signal
select {
case sig := <-interruptChannel:
log.Infof("Received signal (%s). Shutting down...", sig)
case <-shutdownRequest:
log.Info("Shutdown requested. S... | go | func shutdownListener() {
interruptChannel := make(chan os.Signal, 1)
signal.Notify(interruptChannel, signals...)
// Listen for the initial shutdown signal
select {
case sig := <-interruptChannel:
log.Infof("Received signal (%s). Shutting down...", sig)
case <-shutdownRequest:
log.Info("Shutdown requested. S... | [
"func",
"shutdownListener",
"(",
")",
"{",
"interruptChannel",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"signal",
".",
"Notify",
"(",
"interruptChannel",
",",
"signals",
"...",
")",
"\n\n",
"// Listen for the initial shutdown signal",... | // shutdownListener listens for shutdown requests and cancels all contexts
// created from withShutdownCancel. This function never returns and is intended
// to be spawned in a new goroutine. | [
"shutdownListener",
"listens",
"for",
"shutdown",
"requests",
"and",
"cancels",
"all",
"contexts",
"created",
"from",
"withShutdownCancel",
".",
"This",
"function",
"never",
"returns",
"and",
"is",
"intended",
"to",
"be",
"spawned",
"in",
"a",
"new",
"goroutine",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/signal.go#L61-L85 |
142,206 | decred/dcrdata | pubsub/types/pubsub_types.go | IsWSClosedErr | func IsWSClosedErr(err error) (closedErr bool) {
// Must use strings.Contains to catch errors like "write tcp
// 127.0.0.1:7777->127.0.0.1:39196: use of closed network connection".
return err != nil && strings.Contains(err.Error(), ErrWsClosed)
} | go | func IsWSClosedErr(err error) (closedErr bool) {
// Must use strings.Contains to catch errors like "write tcp
// 127.0.0.1:7777->127.0.0.1:39196: use of closed network connection".
return err != nil && strings.Contains(err.Error(), ErrWsClosed)
} | [
"func",
"IsWSClosedErr",
"(",
"err",
"error",
")",
"(",
"closedErr",
"bool",
")",
"{",
"// Must use strings.Contains to catch errors like \"write tcp",
"// 127.0.0.1:7777->127.0.0.1:39196: use of closed network connection\".",
"return",
"err",
"!=",
"nil",
"&&",
"strings",
".",... | // IsWSClosedErr checks if the passed error indicates a closed websocket
// connection. | [
"IsWSClosedErr",
"checks",
"if",
"the",
"passed",
"error",
"indicates",
"a",
"closed",
"websocket",
"connection",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/types/pubsub_types.go#L20-L24 |
142,207 | decred/dcrdata | pubsub/types/pubsub_types.go | IsTemporaryErr | func IsTemporaryErr(err error) bool {
t, ok := err.(net.Error)
return ok && t.Temporary()
} | go | func IsTemporaryErr(err error) bool {
t, ok := err.(net.Error)
return ok && t.Temporary()
} | [
"func",
"IsTemporaryErr",
"(",
"err",
"error",
")",
"bool",
"{",
"t",
",",
"ok",
":=",
"err",
".",
"(",
"net",
".",
"Error",
")",
"\n",
"return",
"ok",
"&&",
"t",
".",
"Temporary",
"(",
")",
"\n",
"}"
] | // IsTemporaryErr checks if the passed error indicates a transient error. | [
"IsTemporaryErr",
"checks",
"if",
"the",
"passed",
"error",
"indicates",
"a",
"transient",
"error",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/types/pubsub_types.go#L33-L36 |
142,208 | decred/dcrdata | mempool/mptypes.go | Swap | func (tix TicketsDetails) Swap(i, j int) {
tix[i], tix[j] = tix[j], tix[i]
} | go | func (tix TicketsDetails) Swap(i, j int) {
tix[i], tix[j] = tix[j], tix[i]
} | [
"func",
"(",
"tix",
"TicketsDetails",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"tix",
"[",
"i",
"]",
",",
"tix",
"[",
"j",
"]",
"=",
"tix",
"[",
"j",
"]",
",",
"tix",
"[",
"i",
"]",
"\n",
"}"
] | // Swap swaps TicketsDetails elements at i and j | [
"Swap",
"swaps",
"TicketsDetails",
"elements",
"at",
"i",
"and",
"j"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mptypes.go#L55-L57 |
142,209 | decred/dcrdata | mempool/mptypes.go | Less | func (tix ByFeeRate) Less(i, j int) bool {
return tix.TicketsDetails[i].FeeRate < tix.TicketsDetails[j].FeeRate
} | go | func (tix ByFeeRate) Less(i, j int) bool {
return tix.TicketsDetails[i].FeeRate < tix.TicketsDetails[j].FeeRate
} | [
"func",
"(",
"tix",
"ByFeeRate",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"tix",
".",
"TicketsDetails",
"[",
"i",
"]",
".",
"FeeRate",
"<",
"tix",
".",
"TicketsDetails",
"[",
"j",
"]",
".",
"FeeRate",
"\n",
"}"
] | // Less compares fee rates by rate_i < rate_j | [
"Less",
"compares",
"fee",
"rates",
"by",
"rate_i",
"<",
"rate_j"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mptypes.go#L65-L67 |
142,210 | decred/dcrdata | mempool/mptypes.go | Less | func (tix ByAbsoluteFee) Less(i, j int) bool {
return tix.TicketsDetails[i].Fee < tix.TicketsDetails[j].Fee
} | go | func (tix ByAbsoluteFee) Less(i, j int) bool {
return tix.TicketsDetails[i].Fee < tix.TicketsDetails[j].Fee
} | [
"func",
"(",
"tix",
"ByAbsoluteFee",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"tix",
".",
"TicketsDetails",
"[",
"i",
"]",
".",
"Fee",
"<",
"tix",
".",
"TicketsDetails",
"[",
"j",
"]",
".",
"Fee",
"\n",
"}"
] | // Less compares fee rates by fee_i < fee_j | [
"Less",
"compares",
"fee",
"rates",
"by",
"fee_i",
"<",
"fee_j"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mptypes.go#L75-L77 |
142,211 | decred/dcrdata | db/dcrsqlite/sqlite.go | InitDB | func InitDB(dbInfo *DBInfo, shutdown func()) (*DB, error) {
dbPath, err := filepath.Abs(dbInfo.FileName)
if err != nil {
return nil, err
}
// Ensures target DB-file has a parent folder
parent := filepath.Dir(dbPath)
err = os.MkdirAll(parent, 0755)
if err != nil {
return nil, err
}
// "shared-cache" mode ... | go | func InitDB(dbInfo *DBInfo, shutdown func()) (*DB, error) {
dbPath, err := filepath.Abs(dbInfo.FileName)
if err != nil {
return nil, err
}
// Ensures target DB-file has a parent folder
parent := filepath.Dir(dbPath)
err = os.MkdirAll(parent, 0755)
if err != nil {
return nil, err
}
// "shared-cache" mode ... | [
"func",
"InitDB",
"(",
"dbInfo",
"*",
"DBInfo",
",",
"shutdown",
"func",
"(",
")",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"dbPath",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"dbInfo",
".",
"FileName",
")",
"\n",
"if",
"err",
"!=",
"nil... | // InitDB creates a new DB instance from a DBInfo containing the name of the
// file used to back the underlying sql database. | [
"InitDB",
"creates",
"a",
"new",
"DB",
"instance",
"from",
"a",
"DBInfo",
"containing",
"the",
"name",
"of",
"the",
"file",
"used",
"to",
"back",
"the",
"underlying",
"sql",
"database",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L324-L433 |
142,212 | decred/dcrdata | db/dcrsqlite/sqlite.go | Store | func (db *DBDataSaver) Store(data *blockdata.BlockData, msgBlock *wire.MsgBlock) error {
summary := data.ToBlockSummary()
var err error
// Store is assumed to be called with a mainchain block
lastIsValid := msgBlock.Header.VoteBits&1 != 0
if !lastIsValid {
// Update the is_valid flag in the blocks table.
// N... | go | func (db *DBDataSaver) Store(data *blockdata.BlockData, msgBlock *wire.MsgBlock) error {
summary := data.ToBlockSummary()
var err error
// Store is assumed to be called with a mainchain block
lastIsValid := msgBlock.Header.VoteBits&1 != 0
if !lastIsValid {
// Update the is_valid flag in the blocks table.
// N... | [
"func",
"(",
"db",
"*",
"DBDataSaver",
")",
"Store",
"(",
"data",
"*",
"blockdata",
".",
"BlockData",
",",
"msgBlock",
"*",
"wire",
".",
"MsgBlock",
")",
"error",
"{",
"summary",
":=",
"data",
".",
"ToBlockSummary",
"(",
")",
"\n",
"var",
"err",
"error... | // Store satisfies the blockdata.BlockDataSaver interface. This function is only
// to be used for storing main chain block data. Use StoreSideBlock or
// StoreBlock directly to store side chain block data. | [
"Store",
"satisfies",
"the",
"blockdata",
".",
"BlockDataSaver",
"interface",
".",
"This",
"function",
"is",
"only",
"to",
"be",
"used",
"for",
"storing",
"main",
"chain",
"block",
"data",
".",
"Use",
"StoreSideBlock",
"or",
"StoreBlock",
"directly",
"to",
"st... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L459-L505 |
142,213 | decred/dcrdata | db/dcrsqlite/sqlite.go | DeleteBlock | func (db *DB) DeleteBlock(blockhash string) (NSummaryRows, NStakeInfoRows int64, err error) {
// Attempt to purge the block data.
NSummaryRows, NStakeInfoRows, err = db.deleteBlock(blockhash)
if err != nil {
return
}
err = db.updateHeights()
return
} | go | func (db *DB) DeleteBlock(blockhash string) (NSummaryRows, NStakeInfoRows int64, err error) {
// Attempt to purge the block data.
NSummaryRows, NStakeInfoRows, err = db.deleteBlock(blockhash)
if err != nil {
return
}
err = db.updateHeights()
return
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"DeleteBlock",
"(",
"blockhash",
"string",
")",
"(",
"NSummaryRows",
",",
"NStakeInfoRows",
"int64",
",",
"err",
"error",
")",
"{",
"// Attempt to purge the block data.",
"NSummaryRows",
",",
"NStakeInfoRows",
",",
"err",
"=",
... | // DeleteBlock purges the summary data and stake info for the block with the
// given hash. The number of rows deleted is returned. | [
"DeleteBlock",
"purges",
"the",
"summary",
"data",
"and",
"stake",
"info",
"for",
"the",
"block",
"with",
"the",
"given",
"hash",
".",
"The",
"number",
"of",
"rows",
"deleted",
"is",
"returned",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L565-L574 |
142,214 | decred/dcrdata | db/dcrsqlite/sqlite.go | DeleteBlocksAboveHeight | func (db *DB) DeleteBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error) {
// Attempt to purge the block data.
NSummaryRows, NStakeInfoRows, err = db.deleteBlocksAboveHeight(height)
if err != nil {
return
}
err = db.updateHeights()
return
} | go | func (db *DB) DeleteBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error) {
// Attempt to purge the block data.
NSummaryRows, NStakeInfoRows, err = db.deleteBlocksAboveHeight(height)
if err != nil {
return
}
err = db.updateHeights()
return
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"DeleteBlocksAboveHeight",
"(",
"height",
"int64",
")",
"(",
"NSummaryRows",
",",
"NStakeInfoRows",
"int64",
",",
"err",
"error",
")",
"{",
"// Attempt to purge the block data.",
"NSummaryRows",
",",
"NStakeInfoRows",
",",
"err",... | // DeleteBlocksAboveHeight purges the summary data and stake info for the blocks
// above the given height, including side chain blocks. | [
"DeleteBlocksAboveHeight",
"purges",
"the",
"summary",
"data",
"and",
"stake",
"info",
"for",
"the",
"blocks",
"above",
"the",
"given",
"height",
"including",
"side",
"chain",
"blocks",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L610-L619 |
142,215 | decred/dcrdata | db/dcrsqlite/sqlite.go | invalidateBlock | func (db *DB) invalidateBlock(blockhash string) error {
_, err := db.Exec(db.invalidateBlockSQL, blockhash)
return db.filterError(err)
} | go | func (db *DB) invalidateBlock(blockhash string) error {
_, err := db.Exec(db.invalidateBlockSQL, blockhash)
return db.filterError(err)
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"invalidateBlock",
"(",
"blockhash",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"db",
".",
"Exec",
"(",
"db",
".",
"invalidateBlockSQL",
",",
"blockhash",
")",
"\n",
"return",
"db",
".",
"filterError",
"(",
... | // Invalidate block with the given hash. | [
"Invalidate",
"block",
"with",
"the",
"given",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L632-L635 |
142,216 | decred/dcrdata | db/dcrsqlite/sqlite.go | setHeightToSideChain | func (db *DB) setHeightToSideChain(height int64) error {
_, err := db.Exec(db.setHeightToSideChainSQL, height)
return db.filterError(err)
} | go | func (db *DB) setHeightToSideChain(height int64) error {
_, err := db.Exec(db.setHeightToSideChainSQL, height)
return db.filterError(err)
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"setHeightToSideChain",
"(",
"height",
"int64",
")",
"error",
"{",
"_",
",",
"err",
":=",
"db",
".",
"Exec",
"(",
"db",
".",
"setHeightToSideChainSQL",
",",
"height",
")",
"\n",
"return",
"db",
".",
"filterError",
"("... | // Sets the is_mainchain field to false for the given block in the database. | [
"Sets",
"the",
"is_mainchain",
"field",
"to",
"false",
"for",
"the",
"given",
"block",
"in",
"the",
"database",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L638-L641 |
142,217 | decred/dcrdata | db/dcrsqlite/sqlite.go | getMainchainStatus | func (db *DB) getMainchainStatus(blockhash string) (bool, error) {
var isMainchain bool
err := db.QueryRow(db.getMainchainStatusSQL, blockhash).Scan(&isMainchain)
return isMainchain, err
} | go | func (db *DB) getMainchainStatus(blockhash string) (bool, error) {
var isMainchain bool
err := db.QueryRow(db.getMainchainStatusSQL, blockhash).Scan(&isMainchain)
return isMainchain, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"getMainchainStatus",
"(",
"blockhash",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"isMainchain",
"bool",
"\n",
"err",
":=",
"db",
".",
"QueryRow",
"(",
"db",
".",
"getMainchainStatusSQL",
",",
"blockhas... | // Returns the is_mainchain value from the database for the given hash. | [
"Returns",
"the",
"is_mainchain",
"value",
"from",
"the",
"database",
"for",
"the",
"given",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L644-L648 |
142,218 | decred/dcrdata | db/dcrsqlite/sqlite.go | StoreBlock | func (db *DB) StoreBlock(bd *apitypes.BlockDataBasic, isMainchain bool, isValid bool) error {
// Cache mainchain blocks.
if isMainchain && db.BlockCache != nil && db.BlockCache.IsEnabled() {
if err := db.BlockCache.StoreBlockSummary(bd); err != nil {
return fmt.Errorf("APICache failed to store block: %v", err)
... | go | func (db *DB) StoreBlock(bd *apitypes.BlockDataBasic, isMainchain bool, isValid bool) error {
// Cache mainchain blocks.
if isMainchain && db.BlockCache != nil && db.BlockCache.IsEnabled() {
if err := db.BlockCache.StoreBlockSummary(bd); err != nil {
return fmt.Errorf("APICache failed to store block: %v", err)
... | [
"func",
"(",
"db",
"*",
"DB",
")",
"StoreBlock",
"(",
"bd",
"*",
"apitypes",
".",
"BlockDataBasic",
",",
"isMainchain",
"bool",
",",
"isValid",
"bool",
")",
"error",
"{",
"// Cache mainchain blocks.",
"if",
"isMainchain",
"&&",
"db",
".",
"BlockCache",
"!=",... | // StoreBlock attempts to store the block data in the database, and
// returns an error on failure. | [
"StoreBlock",
"attempts",
"to",
"store",
"the",
"block",
"data",
"in",
"the",
"database",
"and",
"returns",
"an",
"error",
"on",
"failure",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L652-L696 |
142,219 | decred/dcrdata | db/dcrsqlite/sqlite.go | StoreBlockSummary | func (db *DB) StoreBlockSummary(bd *apitypes.BlockDataBasic) error {
return db.StoreBlock(bd, true, true)
} | go | func (db *DB) StoreBlockSummary(bd *apitypes.BlockDataBasic) error {
return db.StoreBlock(bd, true, true)
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"StoreBlockSummary",
"(",
"bd",
"*",
"apitypes",
".",
"BlockDataBasic",
")",
"error",
"{",
"return",
"db",
".",
"StoreBlock",
"(",
"bd",
",",
"true",
",",
"true",
")",
"\n",
"}"
] | // StoreBlockSummary is called with new mainchain blocks. | [
"StoreBlockSummary",
"is",
"called",
"with",
"new",
"mainchain",
"blocks",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L699-L701 |
142,220 | decred/dcrdata | db/dcrsqlite/sqlite.go | StoreSideBlockSummary | func (db *DB) StoreSideBlockSummary(bd *apitypes.BlockDataBasic) error {
return db.StoreBlock(bd, false, true)
} | go | func (db *DB) StoreSideBlockSummary(bd *apitypes.BlockDataBasic) error {
return db.StoreBlock(bd, false, true)
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"StoreSideBlockSummary",
"(",
"bd",
"*",
"apitypes",
".",
"BlockDataBasic",
")",
"error",
"{",
"return",
"db",
".",
"StoreBlock",
"(",
"bd",
",",
"false",
",",
"true",
")",
"\n",
"}"
] | // StoreSideBlockSummary is for storing side chain. | [
"StoreSideBlockSummary",
"is",
"for",
"storing",
"side",
"chain",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L704-L706 |
142,221 | decred/dcrdata | db/dcrsqlite/sqlite.go | GetBestBlockHash | func (db *DB) GetBestBlockHash() string {
hash, err := db.RetrieveBestBlockHash()
if err != nil {
log.Errorf("RetrieveBestBlockHash failed: %v", err)
return ""
}
return hash
} | go | func (db *DB) GetBestBlockHash() string {
hash, err := db.RetrieveBestBlockHash()
if err != nil {
log.Errorf("RetrieveBestBlockHash failed: %v", err)
return ""
}
return hash
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"GetBestBlockHash",
"(",
")",
"string",
"{",
"hash",
",",
"err",
":=",
"db",
".",
"RetrieveBestBlockHash",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"... | // GetBestBlockHash returns the hash of the best block. | [
"GetBestBlockHash",
"returns",
"the",
"hash",
"of",
"the",
"best",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L709-L716 |
142,222 | decred/dcrdata | db/dcrsqlite/sqlite.go | GetBlockSummaryHeight | func (db *DB) GetBlockSummaryHeight() (int64, error) {
db.mtx.RLock()
defer db.mtx.RUnlock()
if db.dbSummaryHeight < 0 {
h, err := db.getBlockSummaryHeight()
if err == nil {
db.dbSummaryHeight = h
}
return h, err
}
return db.dbSummaryHeight, nil
} | go | func (db *DB) GetBlockSummaryHeight() (int64, error) {
db.mtx.RLock()
defer db.mtx.RUnlock()
if db.dbSummaryHeight < 0 {
h, err := db.getBlockSummaryHeight()
if err == nil {
db.dbSummaryHeight = h
}
return h, err
}
return db.dbSummaryHeight, nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"GetBlockSummaryHeight",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"db",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"db",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"db",
".",
"dbSummaryHeig... | // GetBlockSummaryHeight returns the largest block height for which the database
// can provide a block summary. A cached best block summary height will be
// returned when available to avoid unnecessary DB queries. | [
"GetBlockSummaryHeight",
"returns",
"the",
"largest",
"block",
"height",
"for",
"which",
"the",
"database",
"can",
"provide",
"a",
"block",
"summary",
".",
"A",
"cached",
"best",
"block",
"summary",
"height",
"will",
"be",
"returned",
"when",
"available",
"to",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L765-L776 |
142,223 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrievePoolInfoRange | func (db *DB) RetrievePoolInfoRange(ind0, ind1 int64) ([]apitypes.TicketPoolInfo, []string, error) {
N := ind1 - ind0 + 1
if N == 0 {
return []apitypes.TicketPoolInfo{}, []string{}, nil
}
if N < 0 {
return nil, nil, fmt.Errorf("Cannot retrieve pool info range (%d>%d)",
ind0, ind1)
}
db.mtx.RLock()
if ind1... | go | func (db *DB) RetrievePoolInfoRange(ind0, ind1 int64) ([]apitypes.TicketPoolInfo, []string, error) {
N := ind1 - ind0 + 1
if N == 0 {
return []apitypes.TicketPoolInfo{}, []string{}, nil
}
if N < 0 {
return nil, nil, fmt.Errorf("Cannot retrieve pool info range (%d>%d)",
ind0, ind1)
}
db.mtx.RLock()
if ind1... | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrievePoolInfoRange",
"(",
"ind0",
",",
"ind1",
"int64",
")",
"(",
"[",
"]",
"apitypes",
".",
"TicketPoolInfo",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"N",
":=",
"ind1",
"-",
"ind0",
"+",
"1",
"\n",
... | // RetrievePoolInfoRange returns an array of apitypes.TicketPoolInfo for block
// range ind0 to ind1 and a non-nil error on success | [
"RetrievePoolInfoRange",
"returns",
"an",
"array",
"of",
"apitypes",
".",
"TicketPoolInfo",
"for",
"block",
"range",
"ind0",
"to",
"ind1",
"and",
"a",
"non",
"-",
"nil",
"error",
"on",
"success"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L834-L883 |
142,224 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrievePoolInfo | func (db *DB) RetrievePoolInfo(ind int64) (*apitypes.TicketPoolInfo, error) {
tpi := &apitypes.TicketPoolInfo{
Height: uint32(ind),
}
var hash, winners string
err := db.QueryRow(db.getPoolSQL, ind).Scan(&hash, &tpi.Size,
&tpi.Value, &tpi.ValAvg, &winners)
tpi.Winners = splitToArray(winners)
return tpi, err
} | go | func (db *DB) RetrievePoolInfo(ind int64) (*apitypes.TicketPoolInfo, error) {
tpi := &apitypes.TicketPoolInfo{
Height: uint32(ind),
}
var hash, winners string
err := db.QueryRow(db.getPoolSQL, ind).Scan(&hash, &tpi.Size,
&tpi.Value, &tpi.ValAvg, &winners)
tpi.Winners = splitToArray(winners)
return tpi, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrievePoolInfo",
"(",
"ind",
"int64",
")",
"(",
"*",
"apitypes",
".",
"TicketPoolInfo",
",",
"error",
")",
"{",
"tpi",
":=",
"&",
"apitypes",
".",
"TicketPoolInfo",
"{",
"Height",
":",
"uint32",
"(",
"ind",
")",
... | // RetrievePoolInfo returns ticket pool info for block height ind | [
"RetrievePoolInfo",
"returns",
"ticket",
"pool",
"info",
"for",
"block",
"height",
"ind"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L886-L895 |
142,225 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveWinnersByHash | func (db *DB) RetrieveWinnersByHash(hash string) ([]string, uint32, error) {
var winners string
var height uint32
err := db.QueryRow(db.getWinnersByHashSQL, hash).Scan(&height, &winners)
if err != nil {
return nil, 0, err
}
return splitToArray(winners), height, err
} | go | func (db *DB) RetrieveWinnersByHash(hash string) ([]string, uint32, error) {
var winners string
var height uint32
err := db.QueryRow(db.getWinnersByHashSQL, hash).Scan(&height, &winners)
if err != nil {
return nil, 0, err
}
return splitToArray(winners), height, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveWinnersByHash",
"(",
"hash",
"string",
")",
"(",
"[",
"]",
"string",
",",
"uint32",
",",
"error",
")",
"{",
"var",
"winners",
"string",
"\n",
"var",
"height",
"uint32",
"\n",
"err",
":=",
"db",
".",
"QueryR... | // RetrieveWinnersByHash returns the winning ticket tx IDs drawn after
// connecting the block with the given hash. The block height corresponding to
// the input block hash is also returned. | [
"RetrieveWinnersByHash",
"returns",
"the",
"winning",
"ticket",
"tx",
"IDs",
"drawn",
"after",
"connecting",
"the",
"block",
"with",
"the",
"given",
"hash",
".",
"The",
"block",
"height",
"corresponding",
"to",
"the",
"input",
"block",
"hash",
"is",
"also",
"r... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L912-L920 |
142,226 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrievePoolInfoByHash | func (db *DB) RetrievePoolInfoByHash(hash string) (*apitypes.TicketPoolInfo, error) {
tpi := new(apitypes.TicketPoolInfo)
var winners string
err := db.QueryRow(db.getPoolByHashSQL, hash).Scan(&tpi.Height, &tpi.Size,
&tpi.Value, &tpi.ValAvg, &winners)
tpi.Winners = splitToArray(winners)
return tpi, err
} | go | func (db *DB) RetrievePoolInfoByHash(hash string) (*apitypes.TicketPoolInfo, error) {
tpi := new(apitypes.TicketPoolInfo)
var winners string
err := db.QueryRow(db.getPoolByHashSQL, hash).Scan(&tpi.Height, &tpi.Size,
&tpi.Value, &tpi.ValAvg, &winners)
tpi.Winners = splitToArray(winners)
return tpi, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrievePoolInfoByHash",
"(",
"hash",
"string",
")",
"(",
"*",
"apitypes",
".",
"TicketPoolInfo",
",",
"error",
")",
"{",
"tpi",
":=",
"new",
"(",
"apitypes",
".",
"TicketPoolInfo",
")",
"\n",
"var",
"winners",
"string... | // RetrievePoolInfoByHash returns ticket pool info for blockhash hash. | [
"RetrievePoolInfoByHash",
"returns",
"ticket",
"pool",
"info",
"for",
"blockhash",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L923-L930 |
142,227 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrievePoolValAndSizeRange | func (db *DB) RetrievePoolValAndSizeRange(ind0, ind1 int64) ([]float64, []float64, error) {
N := ind1 - ind0 + 1
if N == 0 {
return []float64{}, []float64{}, nil
}
if N < 0 {
return nil, nil, fmt.Errorf("Cannot retrieve pool val and size range (%d>%d)",
ind0, ind1)
}
db.mtx.RLock()
if ind1 > db.dbSummaryH... | go | func (db *DB) RetrievePoolValAndSizeRange(ind0, ind1 int64) ([]float64, []float64, error) {
N := ind1 - ind0 + 1
if N == 0 {
return []float64{}, []float64{}, nil
}
if N < 0 {
return nil, nil, fmt.Errorf("Cannot retrieve pool val and size range (%d>%d)",
ind0, ind1)
}
db.mtx.RLock()
if ind1 > db.dbSummaryH... | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrievePoolValAndSizeRange",
"(",
"ind0",
",",
"ind1",
"int64",
")",
"(",
"[",
"]",
"float64",
",",
"[",
"]",
"float64",
",",
"error",
")",
"{",
"N",
":=",
"ind1",
"-",
"ind0",
"+",
"1",
"\n",
"if",
"N",
"==",... | // RetrievePoolValAndSizeRange returns an array each of the pool values and
// sizes for block range ind0 to ind1. | [
"RetrievePoolValAndSizeRange",
"returns",
"an",
"array",
"each",
"of",
"the",
"pool",
"values",
"and",
"sizes",
"for",
"block",
"range",
"ind0",
"to",
"ind1",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L934-L985 |
142,228 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrievePoolAllValueAndSize | func (db *DB) RetrievePoolAllValueAndSize(charts *cache.ChartData) (*sql.Rows, func(), error) {
stmt, err := db.Prepare(db.getAllPoolValSize)
if err != nil {
return nil, dummyCancel, err
}
defer stmt.Close()
rows, err := stmt.Query(charts.PoolSizeTip())
if err != nil {
log.Errorf("Query failed: %v", err)
r... | go | func (db *DB) RetrievePoolAllValueAndSize(charts *cache.ChartData) (*sql.Rows, func(), error) {
stmt, err := db.Prepare(db.getAllPoolValSize)
if err != nil {
return nil, dummyCancel, err
}
defer stmt.Close()
rows, err := stmt.Query(charts.PoolSizeTip())
if err != nil {
log.Errorf("Query failed: %v", err)
r... | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrievePoolAllValueAndSize",
"(",
"charts",
"*",
"cache",
".",
"ChartData",
")",
"(",
"*",
"sql",
".",
"Rows",
",",
"func",
"(",
")",
",",
"error",
")",
"{",
"stmt",
",",
"err",
":=",
"db",
".",
"Prepare",
"(",
... | // RetrievePoolAllValueAndSize returns all the pool value and the pool size
// charts data needed to plot ticket-pool-size and ticket-pool value charts on
// the charts page. This is the Fetcher half of a pair that make up a
// cache.ChartUpdater. | [
"RetrievePoolAllValueAndSize",
"returns",
"all",
"the",
"pool",
"value",
"and",
"the",
"pool",
"size",
"charts",
"data",
"needed",
"to",
"plot",
"ticket",
"-",
"pool",
"-",
"size",
"and",
"ticket",
"-",
"pool",
"value",
"charts",
"on",
"the",
"charts",
"page... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L993-L1006 |
142,229 | decred/dcrdata | db/dcrsqlite/sqlite.go | AppendPoolAllValueAndSize | func (db *DB) AppendPoolAllValueAndSize(charts *cache.ChartData, rows *sql.Rows) error {
defer rows.Close()
blocks := charts.Blocks
for rows.Next() {
var pval, psize float64
var timestamp int64
if err := rows.Scan(&psize, &pval, ×tamp); err != nil {
log.Errorf("Unable to scan for TicketPoolInfo fields:... | go | func (db *DB) AppendPoolAllValueAndSize(charts *cache.ChartData, rows *sql.Rows) error {
defer rows.Close()
blocks := charts.Blocks
for rows.Next() {
var pval, psize float64
var timestamp int64
if err := rows.Scan(&psize, &pval, ×tamp); err != nil {
log.Errorf("Unable to scan for TicketPoolInfo fields:... | [
"func",
"(",
"db",
"*",
"DB",
")",
"AppendPoolAllValueAndSize",
"(",
"charts",
"*",
"cache",
".",
"ChartData",
",",
"rows",
"*",
"sql",
".",
"Rows",
")",
"error",
"{",
"defer",
"rows",
".",
"Close",
"(",
")",
"\n",
"blocks",
":=",
"charts",
".",
"Blo... | // Append the result from RetrievePoolAllValueAndSize to the provided ChartData.
// This is the Appender half of a pair that make up a cache.ChartUpdater. | [
"Append",
"the",
"result",
"from",
"RetrievePoolAllValueAndSize",
"to",
"the",
"provided",
"ChartData",
".",
"This",
"is",
"the",
"Appender",
"half",
"of",
"a",
"pair",
"that",
"make",
"up",
"a",
"cache",
".",
"ChartUpdater",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1010-L1030 |
142,230 | decred/dcrdata | db/dcrsqlite/sqlite.go | AppendBlockFeeRows | func (db *DB) AppendBlockFeeRows(charts *cache.ChartData, rows *sql.Rows) error {
defer rows.Close()
blocks := charts.Blocks
for rows.Next() {
var feeMed float64
var blockHeight uint64
if err := rows.Scan(&blockHeight, &feeMed); err != nil {
log.Errorf("Unable to scan for FeeInfoPerBlock fields: %v", err)
... | go | func (db *DB) AppendBlockFeeRows(charts *cache.ChartData, rows *sql.Rows) error {
defer rows.Close()
blocks := charts.Blocks
for rows.Next() {
var feeMed float64
var blockHeight uint64
if err := rows.Scan(&blockHeight, &feeMed); err != nil {
log.Errorf("Unable to scan for FeeInfoPerBlock fields: %v", err)
... | [
"func",
"(",
"db",
"*",
"DB",
")",
"AppendBlockFeeRows",
"(",
"charts",
"*",
"cache",
".",
"ChartData",
",",
"rows",
"*",
"sql",
".",
"Rows",
")",
"error",
"{",
"defer",
"rows",
".",
"Close",
"(",
")",
"\n",
"blocks",
":=",
"charts",
".",
"Blocks",
... | // Append the result from RetrieveBlockFeeRows to the provided ChartData. This
// is the Appender half of a pair that make up a cache.ChartUpdater. | [
"Append",
"the",
"result",
"from",
"RetrieveBlockFeeRows",
"to",
"the",
"provided",
"ChartData",
".",
"This",
"is",
"the",
"Appender",
"half",
"of",
"a",
"pair",
"that",
"make",
"up",
"a",
"cache",
".",
"ChartUpdater",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1053-L1069 |
142,231 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveSDiffRange | func (db *DB) RetrieveSDiffRange(ind0, ind1 int64) ([]float64, error) {
N := ind1 - ind0 + 1
if N == 0 {
return []float64{}, nil
}
if N < 0 {
return nil, fmt.Errorf("Cannot retrieve sdiff range (%d>%d)",
ind0, ind1)
}
db.mtx.RLock()
if ind1 > db.dbSummaryHeight || ind0 < 0 {
defer db.mtx.RUnlock()
ret... | go | func (db *DB) RetrieveSDiffRange(ind0, ind1 int64) ([]float64, error) {
N := ind1 - ind0 + 1
if N == 0 {
return []float64{}, nil
}
if N < 0 {
return nil, fmt.Errorf("Cannot retrieve sdiff range (%d>%d)",
ind0, ind1)
}
db.mtx.RLock()
if ind1 > db.dbSummaryHeight || ind0 < 0 {
defer db.mtx.RUnlock()
ret... | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveSDiffRange",
"(",
"ind0",
",",
"ind1",
"int64",
")",
"(",
"[",
"]",
"float64",
",",
"error",
")",
"{",
"N",
":=",
"ind1",
"-",
"ind0",
"+",
"1",
"\n",
"if",
"N",
"==",
"0",
"{",
"return",
"[",
"]",
... | // RetrieveSDiffRange returns an array of stake difficulties for block range ind0 to
// ind1 | [
"RetrieveSDiffRange",
"returns",
"an",
"array",
"of",
"stake",
"difficulties",
"for",
"block",
"range",
"ind0",
"to",
"ind1"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1073-L1117 |
142,232 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveDiff | func (db *DB) RetrieveDiff(timestamp int64) (float64, error) {
var diff float64
err := db.QueryRow(db.getDifficulty, timestamp).Scan(&diff)
return diff, err
} | go | func (db *DB) RetrieveDiff(timestamp int64) (float64, error) {
var diff float64
err := db.QueryRow(db.getDifficulty, timestamp).Scan(&diff)
return diff, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveDiff",
"(",
"timestamp",
"int64",
")",
"(",
"float64",
",",
"error",
")",
"{",
"var",
"diff",
"float64",
"\n",
"err",
":=",
"db",
".",
"QueryRow",
"(",
"db",
".",
"getDifficulty",
",",
"timestamp",
")",
"."... | // RetrieveDiff returns the difficulty in the last 24hrs or immediately after
// 24hrs. | [
"RetrieveDiff",
"returns",
"the",
"difficulty",
"in",
"the",
"last",
"24hrs",
"or",
"immediately",
"after",
"24hrs",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1157-L1161 |
142,233 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveSDiff | func (db *DB) RetrieveSDiff(ind int64) (float64, error) {
var sdiff float64
err := db.QueryRow(db.getSDiffSQL, ind).Scan(&sdiff)
return sdiff, err
} | go | func (db *DB) RetrieveSDiff(ind int64) (float64, error) {
var sdiff float64
err := db.QueryRow(db.getSDiffSQL, ind).Scan(&sdiff)
return sdiff, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveSDiff",
"(",
"ind",
"int64",
")",
"(",
"float64",
",",
"error",
")",
"{",
"var",
"sdiff",
"float64",
"\n",
"err",
":=",
"db",
".",
"QueryRow",
"(",
"db",
".",
"getSDiffSQL",
",",
"ind",
")",
".",
"Scan",
... | // RetrieveSDiff returns the stake difficulty for block at the specified chain
// height. | [
"RetrieveSDiff",
"returns",
"the",
"stake",
"difficulty",
"for",
"block",
"at",
"the",
"specified",
"chain",
"height",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1165-L1169 |
142,234 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveBlockHash | func (db *DB) RetrieveBlockHash(ind int64) (string, error) {
// First try the block summary cache.
usingBlockCache := db.BlockCache != nil && db.BlockCache.IsEnabled()
if usingBlockCache {
hash := db.BlockCache.GetBlockHash(ind)
if hash != "" {
// Cache hit!
return hash, nil
}
// Cache miss necessitate... | go | func (db *DB) RetrieveBlockHash(ind int64) (string, error) {
// First try the block summary cache.
usingBlockCache := db.BlockCache != nil && db.BlockCache.IsEnabled()
if usingBlockCache {
hash := db.BlockCache.GetBlockHash(ind)
if hash != "" {
// Cache hit!
return hash, nil
}
// Cache miss necessitate... | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveBlockHash",
"(",
"ind",
"int64",
")",
"(",
"string",
",",
"error",
")",
"{",
"// First try the block summary cache.",
"usingBlockCache",
":=",
"db",
".",
"BlockCache",
"!=",
"nil",
"&&",
"db",
".",
"BlockCache",
".... | // RetrieveBlockHash returns the block hash for block ind | [
"RetrieveBlockHash",
"returns",
"the",
"block",
"hash",
"for",
"block",
"ind"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1191-L1206 |
142,235 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveBlockHeight | func (db *DB) RetrieveBlockHeight(hash string) (int64, error) {
var blockHeight int64
err := db.QueryRow(db.getBlockHeightSQL, hash).Scan(&blockHeight)
return blockHeight, err
} | go | func (db *DB) RetrieveBlockHeight(hash string) (int64, error) {
var blockHeight int64
err := db.QueryRow(db.getBlockHeightSQL, hash).Scan(&blockHeight)
return blockHeight, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveBlockHeight",
"(",
"hash",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"blockHeight",
"int64",
"\n",
"err",
":=",
"db",
".",
"QueryRow",
"(",
"db",
".",
"getBlockHeightSQL",
",",
"hash",
")",
... | // RetrieveBlockHeight returns the block height for blockhash hash | [
"RetrieveBlockHeight",
"returns",
"the",
"block",
"height",
"for",
"blockhash",
"hash"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1209-L1213 |
142,236 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveHighestBlockHash | func (db *DB) RetrieveHighestBlockHash() (string, error) {
var blockHash string
err := db.QueryRow(db.getHighestBlockHashSQL).Scan(&blockHash)
return blockHash, err
} | go | func (db *DB) RetrieveHighestBlockHash() (string, error) {
var blockHash string
err := db.QueryRow(db.getHighestBlockHashSQL).Scan(&blockHash)
return blockHash, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveHighestBlockHash",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"blockHash",
"string",
"\n",
"err",
":=",
"db",
".",
"QueryRow",
"(",
"db",
".",
"getHighestBlockHashSQL",
")",
".",
"Scan",
"(",
"&"... | // RetrieveHighestBlockHash returns the block hash for the highest block,
// regardless of mainchain status. | [
"RetrieveHighestBlockHash",
"returns",
"the",
"block",
"hash",
"for",
"the",
"highest",
"block",
"regardless",
"of",
"mainchain",
"status",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1224-L1228 |
142,237 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveBestBlockHeight | func (db *DB) RetrieveBestBlockHeight() (int64, error) {
var blockHeight int64
err := db.QueryRow(db.getBestBlockHeightSQL).Scan(&blockHeight)
return blockHeight, err
} | go | func (db *DB) RetrieveBestBlockHeight() (int64, error) {
var blockHeight int64
err := db.QueryRow(db.getBestBlockHeightSQL).Scan(&blockHeight)
return blockHeight, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveBestBlockHeight",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"blockHeight",
"int64",
"\n",
"err",
":=",
"db",
".",
"QueryRow",
"(",
"db",
".",
"getBestBlockHeightSQL",
")",
".",
"Scan",
"(",
"&",
... | // RetrieveBestBlockHeight returns the block height for the best block | [
"RetrieveBestBlockHeight",
"returns",
"the",
"block",
"height",
"for",
"the",
"best",
"block"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1231-L1235 |
142,238 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveHighestBlockHeight | func (db *DB) RetrieveHighestBlockHeight() (int64, error) {
var blockHeight int64
err := db.QueryRow(db.getHighestBlockHeightSQL).Scan(&blockHeight)
return blockHeight, err
} | go | func (db *DB) RetrieveHighestBlockHeight() (int64, error) {
var blockHeight int64
err := db.QueryRow(db.getHighestBlockHeightSQL).Scan(&blockHeight)
return blockHeight, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveHighestBlockHeight",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"blockHeight",
"int64",
"\n",
"err",
":=",
"db",
".",
"QueryRow",
"(",
"db",
".",
"getHighestBlockHeightSQL",
")",
".",
"Scan",
"(",
... | // RetrieveHighestBlockHeight returns the block height for the highest block,
// regardless of mainchain status. | [
"RetrieveHighestBlockHeight",
"returns",
"the",
"block",
"height",
"for",
"the",
"highest",
"block",
"regardless",
"of",
"mainchain",
"status",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1239-L1243 |
142,239 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveBlockSummaryByHash | func (db *DB) RetrieveBlockSummaryByHash(hash string) (*apitypes.BlockDataBasic, error) {
// First try the block summary cache.
usingBlockCache := db.BlockCache != nil && db.BlockCache.IsEnabled()
if usingBlockCache {
if bd := db.BlockCache.GetBlockSummaryByHash(hash); bd != nil {
// Cache hit!
return bd, ni... | go | func (db *DB) RetrieveBlockSummaryByHash(hash string) (*apitypes.BlockDataBasic, error) {
// First try the block summary cache.
usingBlockCache := db.BlockCache != nil && db.BlockCache.IsEnabled()
if usingBlockCache {
if bd := db.BlockCache.GetBlockSummaryByHash(hash); bd != nil {
// Cache hit!
return bd, ni... | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveBlockSummaryByHash",
"(",
"hash",
"string",
")",
"(",
"*",
"apitypes",
".",
"BlockDataBasic",
",",
"error",
")",
"{",
"// First try the block summary cache.",
"usingBlockCache",
":=",
"db",
".",
"BlockCache",
"!=",
"ni... | // RetrieveBlockSummaryByHash returns basic block data for a block given its hash | [
"RetrieveBlockSummaryByHash",
"returns",
"basic",
"block",
"data",
"for",
"a",
"block",
"given",
"its",
"hash"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1246-L1282 |
142,240 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveBlockSize | func (db *DB) RetrieveBlockSize(ind int64) (int32, error) {
// First try the block summary cache.
usingBlockCache := db.BlockCache != nil && db.BlockCache.IsEnabled()
if usingBlockCache {
sz := db.BlockCache.GetBlockSize(ind)
if sz != -1 {
// Cache hit!
return sz, nil
}
// Cache miss necessitates a DB ... | go | func (db *DB) RetrieveBlockSize(ind int64) (int32, error) {
// First try the block summary cache.
usingBlockCache := db.BlockCache != nil && db.BlockCache.IsEnabled()
if usingBlockCache {
sz := db.BlockCache.GetBlockSize(ind)
if sz != -1 {
// Cache hit!
return sz, nil
}
// Cache miss necessitates a DB ... | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveBlockSize",
"(",
"ind",
"int64",
")",
"(",
"int32",
",",
"error",
")",
"{",
"// First try the block summary cache.",
"usingBlockCache",
":=",
"db",
".",
"BlockCache",
"!=",
"nil",
"&&",
"db",
".",
"BlockCache",
"."... | // RetrieveBlockSize return the size of block at height ind. | [
"RetrieveBlockSize",
"return",
"the",
"size",
"of",
"block",
"at",
"height",
"ind",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1359-L1386 |
142,241 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveBlockSizeRange | func (db *DB) RetrieveBlockSizeRange(ind0, ind1 int64) ([]int32, error) {
N := ind1 - ind0 + 1
if N == 0 {
return []int32{}, nil
}
if N < 0 {
return nil, fmt.Errorf("Cannot retrieve block size range (%d>%d)",
ind0, ind1)
}
db.mtx.RLock()
if ind1 > db.dbSummaryHeight || ind0 < 0 {
defer db.mtx.RUnlock()
... | go | func (db *DB) RetrieveBlockSizeRange(ind0, ind1 int64) ([]int32, error) {
N := ind1 - ind0 + 1
if N == 0 {
return []int32{}, nil
}
if N < 0 {
return nil, fmt.Errorf("Cannot retrieve block size range (%d>%d)",
ind0, ind1)
}
db.mtx.RLock()
if ind1 > db.dbSummaryHeight || ind0 < 0 {
defer db.mtx.RUnlock()
... | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveBlockSizeRange",
"(",
"ind0",
",",
"ind1",
"int64",
")",
"(",
"[",
"]",
"int32",
",",
"error",
")",
"{",
"N",
":=",
"ind1",
"-",
"ind0",
"+",
"1",
"\n",
"if",
"N",
"==",
"0",
"{",
"return",
"[",
"]",
... | // RetrieveBlockSizeRange returns an array of block sizes for block range ind0 to ind1 | [
"RetrieveBlockSizeRange",
"returns",
"an",
"array",
"of",
"block",
"sizes",
"for",
"block",
"range",
"ind0",
"to",
"ind1"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1389-L1433 |
142,242 | decred/dcrdata | db/dcrsqlite/sqlite.go | StoreStakeInfoExtended | func (db *DB) StoreStakeInfoExtended(si *apitypes.StakeInfoExtended) error {
if db.BlockCache != nil && db.BlockCache.IsEnabled() {
if err := db.BlockCache.StoreStakeInfo(si); err != nil {
return fmt.Errorf("APICache failed to store stake info: %v", err)
}
}
stmt, err := db.Prepare(db.insertStakeInfoExtended... | go | func (db *DB) StoreStakeInfoExtended(si *apitypes.StakeInfoExtended) error {
if db.BlockCache != nil && db.BlockCache.IsEnabled() {
if err := db.BlockCache.StoreStakeInfo(si); err != nil {
return fmt.Errorf("APICache failed to store stake info: %v", err)
}
}
stmt, err := db.Prepare(db.insertStakeInfoExtended... | [
"func",
"(",
"db",
"*",
"DB",
")",
"StoreStakeInfoExtended",
"(",
"si",
"*",
"apitypes",
".",
"StakeInfoExtended",
")",
"error",
"{",
"if",
"db",
".",
"BlockCache",
"!=",
"nil",
"&&",
"db",
".",
"BlockCache",
".",
"IsEnabled",
"(",
")",
"{",
"if",
"err... | // StoreStakeInfoExtended stores the extended stake info in the database. | [
"StoreStakeInfoExtended",
"stores",
"the",
"extended",
"stake",
"info",
"in",
"the",
"database",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1436-L1476 |
142,243 | decred/dcrdata | db/dcrsqlite/sqlite.go | deleteStakeInfo | func (db *DB) deleteStakeInfo(blockhash string) (int64, error) {
res, err := db.Exec(db.deleteBlockByHashSQL, blockhash)
if err != nil {
return 0, db.filterError(err)
}
return res.RowsAffected()
} | go | func (db *DB) deleteStakeInfo(blockhash string) (int64, error) {
res, err := db.Exec(db.deleteBlockByHashSQL, blockhash)
if err != nil {
return 0, db.filterError(err)
}
return res.RowsAffected()
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"deleteStakeInfo",
"(",
"blockhash",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"db",
".",
"Exec",
"(",
"db",
".",
"deleteBlockByHashSQL",
",",
"blockhash",
")",
"\n",
"if",
"err",... | // Delete stake info for block with the given hash. The number of rows deleted
// is returned. | [
"Delete",
"stake",
"info",
"for",
"block",
"with",
"the",
"given",
"hash",
".",
"The",
"number",
"of",
"rows",
"deleted",
"is",
"returned",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1480-L1486 |
142,244 | decred/dcrdata | db/dcrsqlite/sqlite.go | deleteStakeInfoHeightMainchain | func (db *DB) deleteStakeInfoHeightMainchain(height int64) (int64, error) {
res, err := db.Exec(db.deleteBlockByHeightMainChainSQL, height)
if err != nil {
return 0, db.filterError(err)
}
return res.RowsAffected()
} | go | func (db *DB) deleteStakeInfoHeightMainchain(height int64) (int64, error) {
res, err := db.Exec(db.deleteBlockByHeightMainChainSQL, height)
if err != nil {
return 0, db.filterError(err)
}
return res.RowsAffected()
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"deleteStakeInfoHeightMainchain",
"(",
"height",
"int64",
")",
"(",
"int64",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"db",
".",
"Exec",
"(",
"db",
".",
"deleteBlockByHeightMainChainSQL",
",",
"height",
")",
"\n... | // Delete stake info for block at the given height on the main chain. The number
// of rows deleted is returned. | [
"Delete",
"stake",
"info",
"for",
"block",
"at",
"the",
"given",
"height",
"on",
"the",
"main",
"chain",
".",
"The",
"number",
"of",
"rows",
"deleted",
"is",
"returned",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1490-L1496 |
142,245 | decred/dcrdata | db/dcrsqlite/sqlite.go | RetrieveHighestStakeHeight | func (db *DB) RetrieveHighestStakeHeight() (int64, error) {
var height int64
err := db.QueryRow(db.getHighestStakeHeightSQL).Scan(&height)
if err != nil {
return -1, err
}
return height, nil
} | go | func (db *DB) RetrieveHighestStakeHeight() (int64, error) {
var height int64
err := db.QueryRow(db.getHighestStakeHeightSQL).Scan(&height)
if err != nil {
return -1, err
}
return height, nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"RetrieveHighestStakeHeight",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"height",
"int64",
"\n",
"err",
":=",
"db",
".",
"QueryRow",
"(",
"db",
".",
"getHighestStakeHeightSQL",
")",
".",
"Scan",
"(",
"&",... | // RetrieveHighestStakeHeight retrieves the height of the highest block in the
// stake table without regard to mainchain status. | [
"RetrieveHighestStakeHeight",
"retrieves",
"the",
"height",
"of",
"the",
"highest",
"block",
"in",
"the",
"stake",
"table",
"without",
"regard",
"to",
"mainchain",
"status",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1545-L1552 |
142,246 | decred/dcrdata | db/dcrsqlite/sqlite.go | getTip | func (db *DB) getTip() (*apitypes.BlockDataBasic, error) {
db.mtx.RLock()
defer db.mtx.RUnlock()
if db.lastStoredBlock != nil {
return db.lastStoredBlock, nil
}
return db.RetrieveLatestBlockSummary()
} | go | func (db *DB) getTip() (*apitypes.BlockDataBasic, error) {
db.mtx.RLock()
defer db.mtx.RUnlock()
if db.lastStoredBlock != nil {
return db.lastStoredBlock, nil
}
return db.RetrieveLatestBlockSummary()
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"getTip",
"(",
")",
"(",
"*",
"apitypes",
".",
"BlockDataBasic",
",",
"error",
")",
"{",
"db",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"db",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"db",
... | // getTip returns the last block stored using StoreBlockSummary.
// If no block has been stored yet, it returns the best block in the database. | [
"getTip",
"returns",
"the",
"last",
"block",
"stored",
"using",
"StoreBlockSummary",
".",
"If",
"no",
"block",
"has",
"been",
"stored",
"yet",
"it",
"returns",
"the",
"best",
"block",
"in",
"the",
"database",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sqlite.go#L1783-L1790 |
142,247 | decred/dcrdata | stakedb/stakedb.go | NewPoolInfoCache | func NewPoolInfoCache(size int) (*PoolInfoCache, error) {
if size < 2 {
return nil, fmt.Errorf("size %d is less than 2", size)
}
return &PoolInfoCache{
poolInfo: make(map[chainhash.Hash]*apitypes.TicketPoolInfo, size),
expireQueue: make([]chainhash.Hash, 0, size),
maxSize: size,
}, nil
} | go | func NewPoolInfoCache(size int) (*PoolInfoCache, error) {
if size < 2 {
return nil, fmt.Errorf("size %d is less than 2", size)
}
return &PoolInfoCache{
poolInfo: make(map[chainhash.Hash]*apitypes.TicketPoolInfo, size),
expireQueue: make([]chainhash.Hash, 0, size),
maxSize: size,
}, nil
} | [
"func",
"NewPoolInfoCache",
"(",
"size",
"int",
")",
"(",
"*",
"PoolInfoCache",
",",
"error",
")",
"{",
"if",
"size",
"<",
"2",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"size",
")",
"\n",
"}",
"\n",
"return",
"&",
"P... | // NewPoolInfoCache constructs a new PoolInfoCache, and is needed to initialize
// the internal map. | [
"NewPoolInfoCache",
"constructs",
"a",
"new",
"PoolInfoCache",
"and",
"is",
"needed",
"to",
"initialize",
"the",
"internal",
"map",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L39-L48 |
142,248 | decred/dcrdata | stakedb/stakedb.go | Set | func (c *PoolInfoCache) Set(hash chainhash.Hash, p *apitypes.TicketPoolInfo) {
c.mtx.Lock()
defer c.mtx.Unlock()
c.poolInfo[hash] = p
if len(c.expireQueue)+1 >= c.maxSize {
expireHash := c.expireQueue[0]
c.expireQueue = c.expireQueue[1:]
delete(c.poolInfo, expireHash)
}
c.expireQueue = append(c.expireQueue,... | go | func (c *PoolInfoCache) Set(hash chainhash.Hash, p *apitypes.TicketPoolInfo) {
c.mtx.Lock()
defer c.mtx.Unlock()
c.poolInfo[hash] = p
if len(c.expireQueue)+1 >= c.maxSize {
expireHash := c.expireQueue[0]
c.expireQueue = c.expireQueue[1:]
delete(c.poolInfo, expireHash)
}
c.expireQueue = append(c.expireQueue,... | [
"func",
"(",
"c",
"*",
"PoolInfoCache",
")",
"Set",
"(",
"hash",
"chainhash",
".",
"Hash",
",",
"p",
"*",
"apitypes",
".",
"TicketPoolInfo",
")",
"{",
"c",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"Unlock",
"(",
")"... | // Set stores the ticket pool info for the given hash in the pool info cache. | [
"Set",
"stores",
"the",
"ticket",
"pool",
"info",
"for",
"the",
"given",
"hash",
"in",
"the",
"pool",
"info",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L61-L71 |
142,249 | decred/dcrdata | stakedb/stakedb.go | SetCapacity | func (c *PoolInfoCache) SetCapacity(size int) error {
if size < 2 {
return fmt.Errorf("size %d is less than 2", size)
}
c.mtx.Lock()
defer c.mtx.Unlock()
c.maxSize = size
for len(c.expireQueue) >= c.maxSize {
expireHash := c.expireQueue[0]
c.expireQueue = c.expireQueue[1:]
delete(c.poolInfo, expireHash)
... | go | func (c *PoolInfoCache) SetCapacity(size int) error {
if size < 2 {
return fmt.Errorf("size %d is less than 2", size)
}
c.mtx.Lock()
defer c.mtx.Unlock()
c.maxSize = size
for len(c.expireQueue) >= c.maxSize {
expireHash := c.expireQueue[0]
c.expireQueue = c.expireQueue[1:]
delete(c.poolInfo, expireHash)
... | [
"func",
"(",
"c",
"*",
"PoolInfoCache",
")",
"SetCapacity",
"(",
"size",
"int",
")",
"error",
"{",
"if",
"size",
"<",
"2",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"size",
")",
"\n",
"}",
"\n\n",
"c",
".",
"mtx",
".",
"Lock",
... | // SetCapacity sets the cache capacity to the specified number of elements. If
// the new capacity is smaller than the current cache size, elements are
// automatically evicted until the desired size is reached. | [
"SetCapacity",
"sets",
"the",
"cache",
"capacity",
"to",
"the",
"specified",
"number",
"of",
"elements",
".",
"If",
"the",
"new",
"capacity",
"is",
"smaller",
"than",
"the",
"current",
"cache",
"size",
"elements",
"are",
"automatically",
"evicted",
"until",
"t... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L76-L90 |
142,250 | decred/dcrdata | stakedb/stakedb.go | PopulateLiveTicketCache | func (db *StakeDatabase) PopulateLiveTicketCache() error {
var err error
// Live tickets from dcrdata's stake Node's perspective
liveTickets := db.BestNode.LiveTickets()
log.Info("Pre-populating live ticket cache and computing pool value...")
// Send all the live ticket requests
type promiseGetRawTransaction st... | go | func (db *StakeDatabase) PopulateLiveTicketCache() error {
var err error
// Live tickets from dcrdata's stake Node's perspective
liveTickets := db.BestNode.LiveTickets()
log.Info("Pre-populating live ticket cache and computing pool value...")
// Send all the live ticket requests
type promiseGetRawTransaction st... | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"PopulateLiveTicketCache",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"// Live tickets from dcrdata's stake Node's perspective",
"liveTickets",
":=",
"db",
".",
"BestNode",
".",
"LiveTickets",
"(",
")",
"\n\n",... | // PopulateLiveTicketCache loads the hashes of all tickets in BestNode into the
// cache and computes the internally-stored pool value. | [
"PopulateLiveTicketCache",
"loads",
"the",
"hashes",
"of",
"all",
"tickets",
"in",
"BestNode",
"into",
"the",
"cache",
"and",
"computes",
"the",
"internally",
"-",
"stored",
"pool",
"value",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L327-L373 |
142,251 | decred/dcrdata | stakedb/stakedb.go | Rewind | func (db *StakeDatabase) Rewind(to int64, neglectCache bool) error {
var heightTicketPool int64
heightStakeDB := int64(db.Height())
for to < heightStakeDB {
if err := db.DisconnectBlock(neglectCache); err != nil {
return fmt.Errorf("failed to disconnect block: %v", err)
}
heightStakeDB, heightTicketPool = i... | go | func (db *StakeDatabase) Rewind(to int64, neglectCache bool) error {
var heightTicketPool int64
heightStakeDB := int64(db.Height())
for to < heightStakeDB {
if err := db.DisconnectBlock(neglectCache); err != nil {
return fmt.Errorf("failed to disconnect block: %v", err)
}
heightStakeDB, heightTicketPool = i... | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"Rewind",
"(",
"to",
"int64",
",",
"neglectCache",
"bool",
")",
"error",
"{",
"var",
"heightTicketPool",
"int64",
"\n",
"heightStakeDB",
":=",
"int64",
"(",
"db",
".",
"Height",
"(",
")",
")",
"\n",
"for",
... | // Rewind disconnects blocks until the new height is the specified height.
// During disconnect, the ticket pool cache and value are kept accurate, unless
// neglectCache is true. | [
"Rewind",
"disconnects",
"blocks",
"until",
"the",
"new",
"height",
"is",
"the",
"specified",
"height",
".",
"During",
"disconnect",
"the",
"ticket",
"pool",
"cache",
"and",
"value",
"are",
"kept",
"accurate",
"unless",
"neglectCache",
"is",
"true",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L378-L393 |
142,252 | decred/dcrdata | stakedb/stakedb.go | WaitForHeight | func (db *StakeDatabase) WaitForHeight(height int64) chan *chainhash.Hash {
dbHeight := int64(db.Height())
waitChan := make(chan *chainhash.Hash, 1)
if dbHeight > height {
defer func() { waitChan <- nil }()
return waitChan
} else if dbHeight == height {
block, _ := db.block(height)
if block == nil {
pani... | go | func (db *StakeDatabase) WaitForHeight(height int64) chan *chainhash.Hash {
dbHeight := int64(db.Height())
waitChan := make(chan *chainhash.Hash, 1)
if dbHeight > height {
defer func() { waitChan <- nil }()
return waitChan
} else if dbHeight == height {
block, _ := db.block(height)
if block == nil {
pani... | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"WaitForHeight",
"(",
"height",
"int64",
")",
"chan",
"*",
"chainhash",
".",
"Hash",
"{",
"dbHeight",
":=",
"int64",
"(",
"db",
".",
"Height",
"(",
")",
")",
"\n",
"waitChan",
":=",
"make",
"(",
"chan",
"... | // WaitForHeight provides a notification channel to which the hash of the block
// at the requested height will be sent when it becomes available. | [
"WaitForHeight",
"provides",
"a",
"notification",
"channel",
"to",
"which",
"the",
"hash",
"of",
"the",
"block",
"at",
"the",
"requested",
"height",
"will",
"be",
"sent",
"when",
"it",
"becomes",
"available",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L407-L424 |
142,253 | decred/dcrdata | stakedb/stakedb.go | BlockCached | func (db *StakeDatabase) BlockCached(ind int64) (*dcrutil.Block, bool) {
db.blkMtx.RLock()
defer db.blkMtx.RUnlock()
block, found := db.blockCache[ind]
return block, found
} | go | func (db *StakeDatabase) BlockCached(ind int64) (*dcrutil.Block, bool) {
db.blkMtx.RLock()
defer db.blkMtx.RUnlock()
block, found := db.blockCache[ind]
return block, found
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"BlockCached",
"(",
"ind",
"int64",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"bool",
")",
"{",
"db",
".",
"blkMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"db",
".",
"blkMtx",
".",
"RUnlock",
"(",
... | // BlockCached attempts to find the block at the specified height in the block
// cache. The returned boolean indicates if it was found. | [
"BlockCached",
"attempts",
"to",
"find",
"the",
"block",
"at",
"the",
"specified",
"height",
"in",
"the",
"block",
"cache",
".",
"The",
"returned",
"boolean",
"indicates",
"if",
"it",
"was",
"found",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L456-L461 |
142,254 | decred/dcrdata | stakedb/stakedb.go | block | func (db *StakeDatabase) block(ind int64) (*dcrutil.Block, bool) {
block, ok := db.BlockCached(ind)
if !ok {
var err error
block, _, err = rpcutils.GetBlock(ind, db.NodeClient)
if err != nil {
log.Error(err)
return nil, false
}
}
return block, ok
} | go | func (db *StakeDatabase) block(ind int64) (*dcrutil.Block, bool) {
block, ok := db.BlockCached(ind)
if !ok {
var err error
block, _, err = rpcutils.GetBlock(ind, db.NodeClient)
if err != nil {
log.Error(err)
return nil, false
}
}
return block, ok
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"block",
"(",
"ind",
"int64",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"bool",
")",
"{",
"block",
",",
"ok",
":=",
"db",
".",
"BlockCached",
"(",
"ind",
")",
"\n",
"if",
"!",
"ok",
"{",
"var",
"... | // block first tries to find the block at the input height in cache, and if that
// fails it will request it from the node RPC client. Don't use this casually
// since reorganization may redefine a block at a given height. | [
"block",
"first",
"tries",
"to",
"find",
"the",
"block",
"at",
"the",
"input",
"height",
"in",
"cache",
"and",
"if",
"that",
"fails",
"it",
"will",
"request",
"it",
"from",
"the",
"node",
"RPC",
"client",
".",
"Don",
"t",
"use",
"this",
"casually",
"si... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L466-L477 |
142,255 | decred/dcrdata | stakedb/stakedb.go | ForgetBlock | func (db *StakeDatabase) ForgetBlock(ind int64) {
db.blkMtx.Lock()
defer db.blkMtx.Unlock()
delete(db.blockCache, ind)
} | go | func (db *StakeDatabase) ForgetBlock(ind int64) {
db.blkMtx.Lock()
defer db.blkMtx.Unlock()
delete(db.blockCache, ind)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"ForgetBlock",
"(",
"ind",
"int64",
")",
"{",
"db",
".",
"blkMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"blkMtx",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"db",
".",
"blockCache",
",",
... | // ForgetBlock deletes the block with the input height from the block cache. | [
"ForgetBlock",
"deletes",
"the",
"block",
"with",
"the",
"input",
"height",
"from",
"the",
"block",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L480-L484 |
142,256 | decred/dcrdata | stakedb/stakedb.go | ConnectBlockHash | func (db *StakeDatabase) ConnectBlockHash(hash *chainhash.Hash) (*dcrutil.Block, error) {
msgBlock, err := db.NodeClient.GetBlock(hash)
if err != nil {
return nil, err
}
block := dcrutil.NewBlock(msgBlock)
return block, db.ConnectBlock(block)
} | go | func (db *StakeDatabase) ConnectBlockHash(hash *chainhash.Hash) (*dcrutil.Block, error) {
msgBlock, err := db.NodeClient.GetBlock(hash)
if err != nil {
return nil, err
}
block := dcrutil.NewBlock(msgBlock)
return block, db.ConnectBlock(block)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"ConnectBlockHash",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"msgBlock",
",",
"err",
":=",
"db",
".",
"NodeClient",
".",
"GetBlock",
"(",
... | // ConnectBlockHash is a wrapper for ConnectBlock. For the input block hash, it
// gets the block from the node RPC client and calls ConnectBlock. | [
"ConnectBlockHash",
"is",
"a",
"wrapper",
"for",
"ConnectBlock",
".",
"For",
"the",
"input",
"block",
"hash",
"it",
"gets",
"the",
"block",
"from",
"the",
"node",
"RPC",
"client",
"and",
"calls",
"ConnectBlock",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L488-L495 |
142,257 | decred/dcrdata | stakedb/stakedb.go | ConnectBlock | func (db *StakeDatabase) ConnectBlock(block *dcrutil.Block) error {
height := block.Height()
maturingHeight := height - int64(db.params.TicketMaturity)
var maturingTickets []chainhash.Hash
if maturingHeight >= 0 {
maturingBlock, wasCached := db.block(maturingHeight)
if wasCached {
db.ForgetBlock(maturingHei... | go | func (db *StakeDatabase) ConnectBlock(block *dcrutil.Block) error {
height := block.Height()
maturingHeight := height - int64(db.params.TicketMaturity)
var maturingTickets []chainhash.Hash
if maturingHeight >= 0 {
maturingBlock, wasCached := db.block(maturingHeight)
if wasCached {
db.ForgetBlock(maturingHei... | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"ConnectBlock",
"(",
"block",
"*",
"dcrutil",
".",
"Block",
")",
"error",
"{",
"height",
":=",
"block",
".",
"Height",
"(",
")",
"\n",
"maturingHeight",
":=",
"height",
"-",
"int64",
"(",
"db",
".",
"params... | // ConnectBlock connects the input block to the tip of the stake DB and updates
// the best stake node. This exported function gets any revoked and spend
// tickets from the input block, and any maturing tickets from the past block in
// which those tickets would be found, and passes them to connectBlock. | [
"ConnectBlock",
"connects",
"the",
"input",
"block",
"to",
"the",
"tip",
"of",
"the",
"stake",
"DB",
"and",
"updates",
"the",
"best",
"stake",
"node",
".",
"This",
"exported",
"function",
"gets",
"any",
"revoked",
"and",
"spend",
"tickets",
"from",
"the",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L501-L576 |
142,258 | decred/dcrdata | stakedb/stakedb.go | applyDiff | func (db *StakeDatabase) applyDiff(poolDiff PoolDiff) {
db.liveTicketMtx.Lock()
for _, hash := range poolDiff.In {
_, ok := db.liveTicketCache[hash]
if ok {
log.Warnf("Just tried to add a ticket (%v) to the pool, but it was already there!", hash)
continue
}
tx, err := db.NodeClient.GetRawTransaction(&h... | go | func (db *StakeDatabase) applyDiff(poolDiff PoolDiff) {
db.liveTicketMtx.Lock()
for _, hash := range poolDiff.In {
_, ok := db.liveTicketCache[hash]
if ok {
log.Warnf("Just tried to add a ticket (%v) to the pool, but it was already there!", hash)
continue
}
tx, err := db.NodeClient.GetRawTransaction(&h... | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"applyDiff",
"(",
"poolDiff",
"PoolDiff",
")",
"{",
"db",
".",
"liveTicketMtx",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"hash",
":=",
"range",
"poolDiff",
".",
"In",
"{",
"_",
",",
"ok",
":=",
"db... | // applyDiff updates liveTicketCache and poolValue for the given PoolDiff. | [
"applyDiff",
"updates",
"liveTicketCache",
"and",
"poolValue",
"for",
"the",
"given",
"PoolDiff",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L601-L632 |
142,259 | decred/dcrdata | stakedb/stakedb.go | undoDiff | func (db *StakeDatabase) undoDiff(poolDiff PoolDiff) {
db.applyDiff(PoolDiff{
In: poolDiff.Out,
Out: poolDiff.In,
})
} | go | func (db *StakeDatabase) undoDiff(poolDiff PoolDiff) {
db.applyDiff(PoolDiff{
In: poolDiff.Out,
Out: poolDiff.In,
})
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"undoDiff",
"(",
"poolDiff",
"PoolDiff",
")",
"{",
"db",
".",
"applyDiff",
"(",
"PoolDiff",
"{",
"In",
":",
"poolDiff",
".",
"Out",
",",
"Out",
":",
"poolDiff",
".",
"In",
",",
"}",
")",
"\n",
"}"
] | // undoDiff is like applyDiff except it swaps In and Out in the specified
// PoolDiff. | [
"undoDiff",
"is",
"like",
"applyDiff",
"except",
"it",
"swaps",
"In",
"and",
"Out",
"in",
"the",
"specified",
"PoolDiff",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L636-L641 |
142,260 | decred/dcrdata | stakedb/stakedb.go | SetPoolInfo | func (db *StakeDatabase) SetPoolInfo(blockHash chainhash.Hash, tpi *apitypes.TicketPoolInfo) {
db.poolInfo.Set(blockHash, tpi)
} | go | func (db *StakeDatabase) SetPoolInfo(blockHash chainhash.Hash, tpi *apitypes.TicketPoolInfo) {
db.poolInfo.Set(blockHash, tpi)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"SetPoolInfo",
"(",
"blockHash",
"chainhash",
".",
"Hash",
",",
"tpi",
"*",
"apitypes",
".",
"TicketPoolInfo",
")",
"{",
"db",
".",
"poolInfo",
".",
"Set",
"(",
"blockHash",
",",
"tpi",
")",
"\n",
"}"
] | // SetPoolInfo stores the ticket pool info for the given hash in the pool info
// cache. | [
"SetPoolInfo",
"stores",
"the",
"ticket",
"pool",
"info",
"for",
"the",
"given",
"hash",
"in",
"the",
"pool",
"info",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L645-L647 |
142,261 | decred/dcrdata | stakedb/stakedb.go | SetPoolCacheCapacity | func (db *StakeDatabase) SetPoolCacheCapacity(cap int) error {
return db.poolInfo.SetCapacity(cap)
} | go | func (db *StakeDatabase) SetPoolCacheCapacity(cap int) error {
return db.poolInfo.SetCapacity(cap)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"SetPoolCacheCapacity",
"(",
"cap",
"int",
")",
"error",
"{",
"return",
"db",
".",
"poolInfo",
".",
"SetCapacity",
"(",
"cap",
")",
"\n",
"}"
] | // SetPoolCacheCapacity sets the pool info cache capacity to the specified
// number of elements. | [
"SetPoolCacheCapacity",
"sets",
"the",
"pool",
"info",
"cache",
"capacity",
"to",
"the",
"specified",
"number",
"of",
"elements",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L651-L653 |
142,262 | decred/dcrdata | stakedb/stakedb.go | DisconnectBlock | func (db *StakeDatabase) DisconnectBlock(neglectCache bool) error {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
return db.disconnectBlock(neglectCache)
} | go | func (db *StakeDatabase) DisconnectBlock(neglectCache bool) error {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
return db.disconnectBlock(neglectCache)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"DisconnectBlock",
"(",
"neglectCache",
"bool",
")",
"error",
"{",
"db",
".",
"nodeMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"nodeMtx",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"db",
".",
"... | // DisconnectBlock attempts to disconnect the current best block from the stake
// DB and updates the best stake node. If the ticket pool db is advanced to the
// tip, it is trimmed, and the cache and pool value are updated. If neglectCache
// is true, the trim is performed, but cache and pool value are not updated.
//... | [
"DisconnectBlock",
"attempts",
"to",
"disconnect",
"the",
"current",
"best",
"block",
"from",
"the",
"stake",
"DB",
"and",
"updates",
"the",
"best",
"stake",
"node",
".",
"If",
"the",
"ticket",
"pool",
"db",
"is",
"advanced",
"to",
"the",
"tip",
"it",
"is"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L660-L665 |
142,263 | decred/dcrdata | stakedb/stakedb.go | disconnectBlock | func (db *StakeDatabase) disconnectBlock(neglectCache bool) error {
childHeight := db.BestNode.Height()
parentBlock, err := db.dbPrevBlock()
if err != nil {
return err
}
if parentBlock.Height() != int64(childHeight)-1 {
panic("BestNode and stake DB are inconsistent")
}
// Trim the ticket pool db to the same... | go | func (db *StakeDatabase) disconnectBlock(neglectCache bool) error {
childHeight := db.BestNode.Height()
parentBlock, err := db.dbPrevBlock()
if err != nil {
return err
}
if parentBlock.Height() != int64(childHeight)-1 {
panic("BestNode and stake DB are inconsistent")
}
// Trim the ticket pool db to the same... | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"disconnectBlock",
"(",
"neglectCache",
"bool",
")",
"error",
"{",
"childHeight",
":=",
"db",
".",
"BestNode",
".",
"Height",
"(",
")",
"\n",
"parentBlock",
",",
"err",
":=",
"db",
".",
"dbPrevBlock",
"(",
")... | // disconnectBlock is the non-thread-safe version of DisconnectBlock. | [
"disconnectBlock",
"is",
"the",
"non",
"-",
"thread",
"-",
"safe",
"version",
"of",
"DisconnectBlock",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L668-L725 |
142,264 | decred/dcrdata | stakedb/stakedb.go | DisconnectBlocks | func (db *StakeDatabase) DisconnectBlocks(count int64) error {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
for i := int64(0); i < count; i++ {
if err := db.disconnectBlock(false); err != nil {
return err
}
}
return nil
} | go | func (db *StakeDatabase) DisconnectBlocks(count int64) error {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
for i := int64(0); i < count; i++ {
if err := db.disconnectBlock(false); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"DisconnectBlocks",
"(",
"count",
"int64",
")",
"error",
"{",
"db",
".",
"nodeMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"nodeMtx",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"i",
":=",
"int64",
... | // DisconnectBlocks disconnects N blocks from the head of the chain. | [
"DisconnectBlocks",
"disconnects",
"N",
"blocks",
"from",
"the",
"head",
"of",
"the",
"chain",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L728-L739 |
142,265 | decred/dcrdata | stakedb/stakedb.go | Open | func (db *StakeDatabase) Open(dbName string) error {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
// Create a new database to store the accepted stake node data into.
var isFreshDB bool
var err error
db.StakeDB, err = database.Open(dbType, dbName, db.params.Net)
if err != nil {
if strings.Contains(err.Error(),... | go | func (db *StakeDatabase) Open(dbName string) error {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
// Create a new database to store the accepted stake node data into.
var isFreshDB bool
var err error
db.StakeDB, err = database.Open(dbType, dbName, db.params.Net)
if err != nil {
if strings.Contains(err.Error(),... | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"Open",
"(",
"dbName",
"string",
")",
"error",
"{",
"db",
".",
"nodeMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"nodeMtx",
".",
"Unlock",
"(",
")",
"\n\n",
"// Create a new database to store the acce... | // Open attempts to open an existing stake database, and will create a new one
// if one does not exist. | [
"Open",
"attempts",
"to",
"open",
"an",
"existing",
"stake",
"database",
"and",
"will",
"create",
"a",
"new",
"one",
"if",
"one",
"does",
"not",
"exist",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L743-L809 |
142,266 | decred/dcrdata | stakedb/stakedb.go | Close | func (db *StakeDatabase) Close() error {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
err1 := db.PoolDB.Close()
err2 := db.StakeDB.Close()
if err1 == nil {
return err2
}
if err2 == nil {
return err1
}
return fmt.Errorf("%v + %v", err1, err2)
} | go | func (db *StakeDatabase) Close() error {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
err1 := db.PoolDB.Close()
err2 := db.StakeDB.Close()
if err1 == nil {
return err2
}
if err2 == nil {
return err1
}
return fmt.Errorf("%v + %v", err1, err2)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"Close",
"(",
")",
"error",
"{",
"db",
".",
"nodeMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"nodeMtx",
".",
"Unlock",
"(",
")",
"\n",
"err1",
":=",
"db",
".",
"PoolDB",
".",
"Close",
"(",
... | // Close will close the ticket pool and stake databases. | [
"Close",
"will",
"close",
"the",
"ticket",
"pool",
"and",
"stake",
"databases",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L812-L824 |
142,267 | decred/dcrdata | stakedb/stakedb.go | PoolInfoBest | func (db *StakeDatabase) PoolInfoBest() *apitypes.TicketPoolInfo {
db.nodeMtx.RLock()
if db.BestNode == nil {
db.nodeMtx.RUnlock()
log.Errorf("PoolInfoBest: BestNode is nil!")
return nil
}
poolSize := db.BestNode.PoolSize()
//liveTickets := db.BestNode.LiveTickets()
winningTickets := db.BestNode.Winners()
... | go | func (db *StakeDatabase) PoolInfoBest() *apitypes.TicketPoolInfo {
db.nodeMtx.RLock()
if db.BestNode == nil {
db.nodeMtx.RUnlock()
log.Errorf("PoolInfoBest: BestNode is nil!")
return nil
}
poolSize := db.BestNode.PoolSize()
//liveTickets := db.BestNode.LiveTickets()
winningTickets := db.BestNode.Winners()
... | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"PoolInfoBest",
"(",
")",
"*",
"apitypes",
".",
"TicketPoolInfo",
"{",
"db",
".",
"nodeMtx",
".",
"RLock",
"(",
")",
"\n",
"if",
"db",
".",
"BestNode",
"==",
"nil",
"{",
"db",
".",
"nodeMtx",
".",
"RUnloc... | // PoolInfoBest computes ticket pool value using the database and, if needed, the
// node RPC client to fetch ticket values that are not cached. Returned are a
// structure including ticket pool value, size, and average value. | [
"PoolInfoBest",
"computes",
"ticket",
"pool",
"value",
"using",
"the",
"database",
"and",
"if",
"needed",
"the",
"node",
"RPC",
"client",
"to",
"fetch",
"ticket",
"values",
"that",
"are",
"not",
"cached",
".",
"Returned",
"are",
"a",
"structure",
"including",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L852-L867 |
142,268 | decred/dcrdata | stakedb/stakedb.go | PoolInfo | func (db *StakeDatabase) PoolInfo(hash chainhash.Hash) (*apitypes.TicketPoolInfo, bool) {
return db.poolInfo.Get(hash)
} | go | func (db *StakeDatabase) PoolInfo(hash chainhash.Hash) (*apitypes.TicketPoolInfo, bool) {
return db.poolInfo.Get(hash)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"PoolInfo",
"(",
"hash",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"apitypes",
".",
"TicketPoolInfo",
",",
"bool",
")",
"{",
"return",
"db",
".",
"poolInfo",
".",
"Get",
"(",
"hash",
")",
"\n",
"}"
] | // PoolInfo attempts to fetch the ticket pool info for the specified block hash
// from an internal pool info cache. If it is not found, you should attempt to
// use PoolInfoBest if the target block is at the tip of the chain. | [
"PoolInfo",
"attempts",
"to",
"fetch",
"the",
"ticket",
"pool",
"info",
"for",
"the",
"specified",
"block",
"hash",
"from",
"an",
"internal",
"pool",
"info",
"cache",
".",
"If",
"it",
"is",
"not",
"found",
"you",
"should",
"attempt",
"to",
"use",
"PoolInfo... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L935-L937 |
142,269 | decred/dcrdata | stakedb/stakedb.go | PoolSize | func (db *StakeDatabase) PoolSize() int {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
return db.BestNode.PoolSize()
} | go | func (db *StakeDatabase) PoolSize() int {
db.nodeMtx.Lock()
defer db.nodeMtx.Unlock()
return db.BestNode.PoolSize()
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"PoolSize",
"(",
")",
"int",
"{",
"db",
".",
"nodeMtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"db",
".",
"nodeMtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"db",
".",
"BestNode",
".",
"PoolSize",
"(",
... | // PoolSize returns the ticket pool size in the best node of the stake database | [
"PoolSize",
"returns",
"the",
"ticket",
"pool",
"size",
"in",
"the",
"best",
"node",
"of",
"the",
"stake",
"database"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L940-L944 |
142,270 | decred/dcrdata | stakedb/stakedb.go | PoolAtHeight | func (db *StakeDatabase) PoolAtHeight(height int64) ([]chainhash.Hash, error) {
return db.PoolDB.Pool(height)
} | go | func (db *StakeDatabase) PoolAtHeight(height int64) ([]chainhash.Hash, error) {
return db.PoolDB.Pool(height)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"PoolAtHeight",
"(",
"height",
"int64",
")",
"(",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"error",
")",
"{",
"return",
"db",
".",
"PoolDB",
".",
"Pool",
"(",
"height",
")",
"\n",
"}"
] | // PoolAtHeight gets the entire list of live tickets at the given chain height. | [
"PoolAtHeight",
"gets",
"the",
"entire",
"list",
"of",
"live",
"tickets",
"at",
"the",
"given",
"chain",
"height",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L947-L949 |
142,271 | decred/dcrdata | stakedb/stakedb.go | PoolAtHash | func (db *StakeDatabase) PoolAtHash(hash chainhash.Hash) ([]chainhash.Hash, error) {
header, err := db.NodeClient.GetBlockHeader(&hash)
if err != nil {
return nil, fmt.Errorf("GetBlockHeader failed: %v", err)
}
return db.PoolDB.Pool(int64(header.Height))
} | go | func (db *StakeDatabase) PoolAtHash(hash chainhash.Hash) ([]chainhash.Hash, error) {
header, err := db.NodeClient.GetBlockHeader(&hash)
if err != nil {
return nil, fmt.Errorf("GetBlockHeader failed: %v", err)
}
return db.PoolDB.Pool(int64(header.Height))
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"PoolAtHash",
"(",
"hash",
"chainhash",
".",
"Hash",
")",
"(",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"error",
")",
"{",
"header",
",",
"err",
":=",
"db",
".",
"NodeClient",
".",
"GetBlockHeader",
"(",
... | // PoolAtHash gets the entire list of live tickets at the given block hash. | [
"PoolAtHash",
"gets",
"the",
"entire",
"list",
"of",
"live",
"tickets",
"at",
"the",
"given",
"block",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L952-L958 |
142,272 | decred/dcrdata | stakedb/stakedb.go | DBState | func (db *StakeDatabase) DBState() (uint32, *chainhash.Hash, error) {
db.nodeMtx.RLock()
defer db.nodeMtx.RUnlock()
return db.dbState()
} | go | func (db *StakeDatabase) DBState() (uint32, *chainhash.Hash, error) {
db.nodeMtx.RLock()
defer db.nodeMtx.RUnlock()
return db.dbState()
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"DBState",
"(",
")",
"(",
"uint32",
",",
"*",
"chainhash",
".",
"Hash",
",",
"error",
")",
"{",
"db",
".",
"nodeMtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"db",
".",
"nodeMtx",
".",
"RUnlock",
"(",
... | // DBState queries the stake database for the best block height and hash. | [
"DBState",
"queries",
"the",
"stake",
"database",
"for",
"the",
"best",
"block",
"height",
"and",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L961-L966 |
142,273 | decred/dcrdata | stakedb/stakedb.go | DBTipBlockHeader | func (db *StakeDatabase) DBTipBlockHeader() (*wire.BlockHeader, error) {
_, hash, err := db.DBState()
if err != nil {
return nil, err
}
return db.NodeClient.GetBlockHeader(hash)
} | go | func (db *StakeDatabase) DBTipBlockHeader() (*wire.BlockHeader, error) {
_, hash, err := db.DBState()
if err != nil {
return nil, err
}
return db.NodeClient.GetBlockHeader(hash)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"DBTipBlockHeader",
"(",
")",
"(",
"*",
"wire",
".",
"BlockHeader",
",",
"error",
")",
"{",
"_",
",",
"hash",
",",
"err",
":=",
"db",
".",
"DBState",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // DBTipBlockHeader gets the block header for the current best block in the
// stake database. It used DBState to get the best block hash, and the node RPC
// client to get the header. | [
"DBTipBlockHeader",
"gets",
"the",
"block",
"header",
"for",
"the",
"current",
"best",
"block",
"in",
"the",
"stake",
"database",
".",
"It",
"used",
"DBState",
"to",
"get",
"the",
"best",
"block",
"hash",
"and",
"the",
"node",
"RPC",
"client",
"to",
"get",... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L989-L996 |
142,274 | decred/dcrdata | stakedb/stakedb.go | DBPrevBlockHeader | func (db *StakeDatabase) DBPrevBlockHeader() (*wire.BlockHeader, error) {
_, hash, err := db.DBState()
if err != nil {
return nil, err
}
parentHeader, err := db.NodeClient.GetBlockHeader(hash)
if err != nil {
return nil, err
}
return db.NodeClient.GetBlockHeader(&parentHeader.PrevBlock)
} | go | func (db *StakeDatabase) DBPrevBlockHeader() (*wire.BlockHeader, error) {
_, hash, err := db.DBState()
if err != nil {
return nil, err
}
parentHeader, err := db.NodeClient.GetBlockHeader(hash)
if err != nil {
return nil, err
}
return db.NodeClient.GetBlockHeader(&parentHeader.PrevBlock)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"DBPrevBlockHeader",
"(",
")",
"(",
"*",
"wire",
".",
"BlockHeader",
",",
"error",
")",
"{",
"_",
",",
"hash",
",",
"err",
":=",
"db",
".",
"DBState",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // DBPrevBlockHeader gets the block header for the previous best block in the
// stake database. It used DBState to get the best block hash, and the node RPC
// client to get the header. | [
"DBPrevBlockHeader",
"gets",
"the",
"block",
"header",
"for",
"the",
"previous",
"best",
"block",
"in",
"the",
"stake",
"database",
".",
"It",
"used",
"DBState",
"to",
"get",
"the",
"best",
"block",
"hash",
"and",
"the",
"node",
"RPC",
"client",
"to",
"get... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L1001-L1013 |
142,275 | decred/dcrdata | stakedb/stakedb.go | DBTipBlock | func (db *StakeDatabase) DBTipBlock() (*dcrutil.Block, error) {
_, hash, err := db.DBState()
if err != nil {
return nil, err
}
return db.getBlock(hash)
} | go | func (db *StakeDatabase) DBTipBlock() (*dcrutil.Block, error) {
_, hash, err := db.DBState()
if err != nil {
return nil, err
}
return db.getBlock(hash)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"DBTipBlock",
"(",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"_",
",",
"hash",
",",
"err",
":=",
"db",
".",
"DBState",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // DBTipBlock gets the dcrutil.Block for the current best block in the stake
// database. It used DBState to get the best block hash, and the node RPC client
// to get the block itself. | [
"DBTipBlock",
"gets",
"the",
"dcrutil",
".",
"Block",
"for",
"the",
"current",
"best",
"block",
"in",
"the",
"stake",
"database",
".",
"It",
"used",
"DBState",
"to",
"get",
"the",
"best",
"block",
"hash",
"and",
"the",
"node",
"RPC",
"client",
"to",
"get... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L1018-L1025 |
142,276 | decred/dcrdata | stakedb/stakedb.go | DBPrevBlock | func (db *StakeDatabase) DBPrevBlock() (*dcrutil.Block, error) {
_, hash, err := db.DBState()
if err != nil {
return nil, err
}
parentHeader, err := db.NodeClient.GetBlockHeader(hash)
if err != nil {
return nil, err
}
return db.getBlock(&parentHeader.PrevBlock)
} | go | func (db *StakeDatabase) DBPrevBlock() (*dcrutil.Block, error) {
_, hash, err := db.DBState()
if err != nil {
return nil, err
}
parentHeader, err := db.NodeClient.GetBlockHeader(hash)
if err != nil {
return nil, err
}
return db.getBlock(&parentHeader.PrevBlock)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"DBPrevBlock",
"(",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"_",
",",
"hash",
",",
"err",
":=",
"db",
".",
"DBState",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // DBPrevBlock gets the dcrutil.Block for the previous best block in the stake
// database. It used DBState to get the best block hash, and the node RPC client
// to get the block itself. | [
"DBPrevBlock",
"gets",
"the",
"dcrutil",
".",
"Block",
"for",
"the",
"previous",
"best",
"block",
"in",
"the",
"stake",
"database",
".",
"It",
"used",
"DBState",
"to",
"get",
"the",
"best",
"block",
"hash",
"and",
"the",
"node",
"RPC",
"client",
"to",
"g... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L1030-L1042 |
142,277 | decred/dcrdata | stakedb/stakedb.go | dbPrevBlock | func (db *StakeDatabase) dbPrevBlock() (*dcrutil.Block, error) {
_, hash, err := db.dbState()
if err != nil {
return nil, err
}
parentHeader, err := db.NodeClient.GetBlockHeader(hash)
if err != nil {
return nil, err
}
return db.getBlock(&parentHeader.PrevBlock)
} | go | func (db *StakeDatabase) dbPrevBlock() (*dcrutil.Block, error) {
_, hash, err := db.dbState()
if err != nil {
return nil, err
}
parentHeader, err := db.NodeClient.GetBlockHeader(hash)
if err != nil {
return nil, err
}
return db.getBlock(&parentHeader.PrevBlock)
} | [
"func",
"(",
"db",
"*",
"StakeDatabase",
")",
"dbPrevBlock",
"(",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"_",
",",
"hash",
",",
"err",
":=",
"db",
".",
"dbState",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // dbPrevBlock is the non-thread-safe version of DBPrevBlock. | [
"dbPrevBlock",
"is",
"the",
"non",
"-",
"thread",
"-",
"safe",
"version",
"of",
"DBPrevBlock",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/stakedb.go#L1045-L1057 |
142,278 | decred/dcrdata | rpcutils/blockgate.go | NewBlockGate | func NewBlockGate(client BlockFetcher, capacity int) *BlockGate {
return &BlockGate{
client: client,
height: -1,
fetchToHeight: -1,
hashAtHeight: make(map[int64]chainhash.Hash),
blockWithHash: make(map[chainhash.Hash]*dcrutil.Block),
heightWaiters: make(map[int64][]chan chainhash.Hash),
ha... | go | func NewBlockGate(client BlockFetcher, capacity int) *BlockGate {
return &BlockGate{
client: client,
height: -1,
fetchToHeight: -1,
hashAtHeight: make(map[int64]chainhash.Hash),
blockWithHash: make(map[chainhash.Hash]*dcrutil.Block),
heightWaiters: make(map[int64][]chan chainhash.Hash),
ha... | [
"func",
"NewBlockGate",
"(",
"client",
"BlockFetcher",
",",
"capacity",
"int",
")",
"*",
"BlockGate",
"{",
"return",
"&",
"BlockGate",
"{",
"client",
":",
"client",
",",
"height",
":",
"-",
"1",
",",
"fetchToHeight",
":",
"-",
"1",
",",
"hashAtHeight",
"... | // NewBlockGate constructs a new BlockGate, wrapping an RPC client, with a
// specified block cache capacity. | [
"NewBlockGate",
"constructs",
"a",
"new",
"BlockGate",
"wrapping",
"an",
"RPC",
"client",
"with",
"a",
"specified",
"block",
"cache",
"capacity",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L83-L96 |
142,279 | decred/dcrdata | rpcutils/blockgate.go | SetFetchToHeight | func (g *BlockGate) SetFetchToHeight(height int64) {
g.mtx.RLock()
defer g.mtx.RUnlock()
g.fetchToHeight = height
} | go | func (g *BlockGate) SetFetchToHeight(height int64) {
g.mtx.RLock()
defer g.mtx.RUnlock()
g.fetchToHeight = height
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"SetFetchToHeight",
"(",
"height",
"int64",
")",
"{",
"g",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"g",
".",
"fetchToHeight",
"=",
"height",
"\n",
... | // SetFetchToHeight sets the height up to which WaitForHeight will trigger an
// RPC to retrieve the block immediately. For the given height and up,
// WaitForHeight will only return a notification channel. | [
"SetFetchToHeight",
"sets",
"the",
"height",
"up",
"to",
"which",
"WaitForHeight",
"will",
"trigger",
"an",
"RPC",
"to",
"retrieve",
"the",
"block",
"immediately",
".",
"For",
"the",
"given",
"height",
"and",
"up",
"WaitForHeight",
"will",
"only",
"return",
"a... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L101-L105 |
142,280 | decred/dcrdata | rpcutils/blockgate.go | NodeHeight | func (g *BlockGate) NodeHeight() (int64, error) {
_, height, err := g.client.GetBestBlock()
return height, err
} | go | func (g *BlockGate) NodeHeight() (int64, error) {
_, height, err := g.client.GetBestBlock()
return height, err
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"NodeHeight",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"_",
",",
"height",
",",
"err",
":=",
"g",
".",
"client",
".",
"GetBestBlock",
"(",
")",
"\n",
"return",
"height",
",",
"err",
"\n",
"}"
] | // NodeHeight gets the chain height from dcrd. | [
"NodeHeight",
"gets",
"the",
"chain",
"height",
"from",
"dcrd",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L108-L111 |
142,281 | decred/dcrdata | rpcutils/blockgate.go | BestBlockHeight | func (g *BlockGate) BestBlockHeight() int64 {
g.mtx.RLock()
defer g.mtx.RUnlock()
return g.height
} | go | func (g *BlockGate) BestBlockHeight() int64 {
g.mtx.RLock()
defer g.mtx.RUnlock()
return g.height
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"BestBlockHeight",
"(",
")",
"int64",
"{",
"g",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"g",
".",
"height",
"\n",
"}"
] | // BestBlockHeight gets the best block height in the block cache. | [
"BestBlockHeight",
"gets",
"the",
"best",
"block",
"height",
"in",
"the",
"block",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L114-L118 |
142,282 | decred/dcrdata | rpcutils/blockgate.go | BestBlockHash | func (g *BlockGate) BestBlockHash() (chainhash.Hash, int64, error) {
g.mtx.RLock()
defer g.mtx.RUnlock()
var err error
hash, ok := g.hashAtHeight[g.height]
if !ok {
err = fmt.Errorf("hash of best block %d not found", g.height)
}
return hash, g.height, err
} | go | func (g *BlockGate) BestBlockHash() (chainhash.Hash, int64, error) {
g.mtx.RLock()
defer g.mtx.RUnlock()
var err error
hash, ok := g.hashAtHeight[g.height]
if !ok {
err = fmt.Errorf("hash of best block %d not found", g.height)
}
return hash, g.height, err
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"BestBlockHash",
"(",
")",
"(",
"chainhash",
".",
"Hash",
",",
"int64",
",",
"error",
")",
"{",
"g",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"v... | // BestBlockHash gets the hash and height of the best block in cache. | [
"BestBlockHash",
"gets",
"the",
"hash",
"and",
"height",
"of",
"the",
"best",
"block",
"in",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L121-L130 |
142,283 | decred/dcrdata | rpcutils/blockgate.go | BestBlock | func (g *BlockGate) BestBlock() (*dcrutil.Block, error) {
g.mtx.RLock()
defer g.mtx.RUnlock()
var err error
hash, ok := g.hashAtHeight[g.height]
if !ok {
err = fmt.Errorf("hash of best block %d not found", g.height)
}
block, ok := g.blockWithHash[hash]
if !ok {
err = fmt.Errorf("block %d at height %d not fo... | go | func (g *BlockGate) BestBlock() (*dcrutil.Block, error) {
g.mtx.RLock()
defer g.mtx.RUnlock()
var err error
hash, ok := g.hashAtHeight[g.height]
if !ok {
err = fmt.Errorf("hash of best block %d not found", g.height)
}
block, ok := g.blockWithHash[hash]
if !ok {
err = fmt.Errorf("block %d at height %d not fo... | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"BestBlock",
"(",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"g",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"var",
"err",
... | // BestBlock gets the best block in cache. | [
"BestBlock",
"gets",
"the",
"best",
"block",
"in",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L133-L146 |
142,284 | decred/dcrdata | rpcutils/blockgate.go | CachedBlock | func (g *BlockGate) CachedBlock(hash chainhash.Hash) (*dcrutil.Block, error) {
g.mtx.RLock()
defer g.mtx.RUnlock()
block, ok := g.blockWithHash[hash]
if !ok {
return nil, fmt.Errorf("block %d not found", hash)
}
return block, nil
} | go | func (g *BlockGate) CachedBlock(hash chainhash.Hash) (*dcrutil.Block, error) {
g.mtx.RLock()
defer g.mtx.RUnlock()
block, ok := g.blockWithHash[hash]
if !ok {
return nil, fmt.Errorf("block %d not found", hash)
}
return block, nil
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"CachedBlock",
"(",
"hash",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"g",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"RUnlock"... | // CachedBlock attempts to get the block with the specified hash from cache. | [
"CachedBlock",
"attempts",
"to",
"get",
"the",
"block",
"with",
"the",
"specified",
"hash",
"from",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L149-L157 |
142,285 | decred/dcrdata | rpcutils/blockgate.go | Block | func (g *BlockGate) Block(hash chainhash.Hash) (*dcrutil.Block, error) {
// Try block cache first.
block, err := g.CachedBlock(hash)
if err == nil {
return block, nil
}
// Cache miss. Retrieve from dcrd RPC.
block, err = GetBlockByHash(&hash, g.client)
if err != nil {
return nil, fmt.Errorf("GetBlock (%v) f... | go | func (g *BlockGate) Block(hash chainhash.Hash) (*dcrutil.Block, error) {
// Try block cache first.
block, err := g.CachedBlock(hash)
if err == nil {
return block, nil
}
// Cache miss. Retrieve from dcrd RPC.
block, err = GetBlockByHash(&hash, g.client)
if err != nil {
return nil, fmt.Errorf("GetBlock (%v) f... | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"Block",
"(",
"hash",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"// Try block cache first.",
"block",
",",
"err",
":=",
"g",
".",
"CachedBlock",
"(",
"hash",
")",
... | // Block first attempts to get the block with the specified hash from cache. In
// the event of a cache miss, the block is retrieved from dcrd via RPC. | [
"Block",
"first",
"attempts",
"to",
"get",
"the",
"block",
"with",
"the",
"specified",
"hash",
"from",
"cache",
".",
"In",
"the",
"event",
"of",
"a",
"cache",
"miss",
"the",
"block",
"is",
"retrieved",
"from",
"dcrd",
"via",
"RPC",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L161-L179 |
142,286 | decred/dcrdata | rpcutils/blockgate.go | UpdateToBestBlock | func (g *BlockGate) UpdateToBestBlock() (*dcrutil.Block, error) {
_, height, err := g.client.GetBestBlock()
if err != nil {
return nil, fmt.Errorf("GetBestBlockHash failed: %v", err)
}
return g.UpdateToBlock(height)
} | go | func (g *BlockGate) UpdateToBestBlock() (*dcrutil.Block, error) {
_, height, err := g.client.GetBestBlock()
if err != nil {
return nil, fmt.Errorf("GetBestBlockHash failed: %v", err)
}
return g.UpdateToBlock(height)
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"UpdateToBestBlock",
"(",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"_",
",",
"height",
",",
"err",
":=",
"g",
".",
"client",
".",
"GetBestBlock",
"(",
")",
"\n",
"if",
"err",
"!=",
"... | // UpdateToBestBlock gets the best block via RPC and updates the cache. | [
"UpdateToBestBlock",
"gets",
"the",
"best",
"block",
"via",
"RPC",
"and",
"updates",
"the",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L182-L189 |
142,287 | decred/dcrdata | rpcutils/blockgate.go | UpdateToNextBlock | func (g *BlockGate) UpdateToNextBlock() (*dcrutil.Block, error) {
g.mtx.Lock()
height := g.height + 1
g.mtx.Unlock()
return g.UpdateToBlock(height)
} | go | func (g *BlockGate) UpdateToNextBlock() (*dcrutil.Block, error) {
g.mtx.Lock()
height := g.height + 1
g.mtx.Unlock()
return g.UpdateToBlock(height)
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"UpdateToNextBlock",
"(",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"height",
":=",
"g",
".",
"height",
"+",
"1",
"\n",
"g",
".",
"mtx"... | // UpdateToNextBlock gets the next block following the best in cache via RPC and
// updates the cache. | [
"UpdateToNextBlock",
"gets",
"the",
"next",
"block",
"following",
"the",
"best",
"in",
"cache",
"via",
"RPC",
"and",
"updates",
"the",
"cache",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L193-L198 |
142,288 | decred/dcrdata | rpcutils/blockgate.go | UpdateToBlock | func (g *BlockGate) UpdateToBlock(height int64) (*dcrutil.Block, error) {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.updateToBlock(height)
} | go | func (g *BlockGate) UpdateToBlock(height int64) (*dcrutil.Block, error) {
g.mtx.Lock()
defer g.mtx.Unlock()
return g.updateToBlock(height)
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"UpdateToBlock",
"(",
"height",
"int64",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"... | // UpdateToBlock gets the block at the specified height on the main chain from
// dcrd, stores it in cache, and signals any waiters. This is the thread-safe
// version of updateToBlock. | [
"UpdateToBlock",
"gets",
"the",
"block",
"at",
"the",
"specified",
"height",
"on",
"the",
"main",
"chain",
"from",
"dcrd",
"stores",
"it",
"in",
"cache",
"and",
"signals",
"any",
"waiters",
".",
"This",
"is",
"the",
"thread",
"-",
"safe",
"version",
"of",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L203-L207 |
142,289 | decred/dcrdata | rpcutils/blockgate.go | updateToBlock | func (g *BlockGate) updateToBlock(height int64) (*dcrutil.Block, error) {
block, hash, err := GetBlock(height, g.client)
if err != nil {
return nil, fmt.Errorf("GetBlock (%d) failed: %v", height, err)
}
if block.Height() != height {
return nil, fmt.Errorf("GetBlock (%d) returned block at height %d",
height,... | go | func (g *BlockGate) updateToBlock(height int64) (*dcrutil.Block, error) {
block, hash, err := GetBlock(height, g.client)
if err != nil {
return nil, fmt.Errorf("GetBlock (%d) failed: %v", height, err)
}
if block.Height() != height {
return nil, fmt.Errorf("GetBlock (%d) returned block at height %d",
height,... | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"updateToBlock",
"(",
"height",
"int64",
")",
"(",
"*",
"dcrutil",
".",
"Block",
",",
"error",
")",
"{",
"block",
",",
"hash",
",",
"err",
":=",
"GetBlock",
"(",
"height",
",",
"g",
".",
"client",
")",
"\n",... | // updateToBlock gets the block at the specified height on the main chain from
// dcrd. It is not thread-safe. It wrapped by UpdateToBlock for thread-safety,
// and used directly by WaitForHeight which locks the BlockGate. | [
"updateToBlock",
"gets",
"the",
"block",
"at",
"the",
"specified",
"height",
"on",
"the",
"main",
"chain",
"from",
"dcrd",
".",
"It",
"is",
"not",
"thread",
"-",
"safe",
".",
"It",
"wrapped",
"by",
"UpdateToBlock",
"for",
"thread",
"-",
"safety",
"and",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L212-L240 |
142,290 | decred/dcrdata | rpcutils/blockgate.go | WaitForHeight | func (g *BlockGate) WaitForHeight(height int64) chan chainhash.Hash {
g.mtx.Lock()
defer g.mtx.Unlock()
if height < 0 {
return nil
}
waitChan := make(chan chainhash.Hash, 1)
// Queue for future send.
g.heightWaiters[height] = append(g.heightWaiters[height], waitChan)
// If the block is already cached, send... | go | func (g *BlockGate) WaitForHeight(height int64) chan chainhash.Hash {
g.mtx.Lock()
defer g.mtx.Unlock()
if height < 0 {
return nil
}
waitChan := make(chan chainhash.Hash, 1)
// Queue for future send.
g.heightWaiters[height] = append(g.heightWaiters[height], waitChan)
// If the block is already cached, send... | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"WaitForHeight",
"(",
"height",
"int64",
")",
"chan",
"chainhash",
".",
"Hash",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"height",
... | // WaitForHeight provides a notification channel for signaling to the caller
// when the block at the specified height is available. | [
"WaitForHeight",
"provides",
"a",
"notification",
"channel",
"for",
"signaling",
"to",
"the",
"caller",
"when",
"the",
"block",
"at",
"the",
"specified",
"height",
"is",
"available",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L324-L351 |
142,291 | decred/dcrdata | rpcutils/blockgate.go | WaitForHash | func (g *BlockGate) WaitForHash(hash chainhash.Hash) chan int64 {
g.mtx.Lock()
defer g.mtx.Unlock()
waitChan := make(chan int64, 1)
// Queue for future send.
g.hashWaiters[hash] = append(g.hashWaiters[hash], waitChan)
// If the block is already cached, send now.
if block, ok := g.blockWithHash[hash]; ok {
g... | go | func (g *BlockGate) WaitForHash(hash chainhash.Hash) chan int64 {
g.mtx.Lock()
defer g.mtx.Unlock()
waitChan := make(chan int64, 1)
// Queue for future send.
g.hashWaiters[hash] = append(g.hashWaiters[hash], waitChan)
// If the block is already cached, send now.
if block, ok := g.blockWithHash[hash]; ok {
g... | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"WaitForHash",
"(",
"hash",
"chainhash",
".",
"Hash",
")",
"chan",
"int64",
"{",
"g",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"g",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"waitChan",
":=",
"... | // WaitForHash provides a notification channel for signaling to the caller
// when the block with the specified hash is available. | [
"WaitForHash",
"provides",
"a",
"notification",
"channel",
"for",
"signaling",
"to",
"the",
"caller",
"when",
"the",
"block",
"with",
"the",
"specified",
"hash",
"is",
"available",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L355-L370 |
142,292 | decred/dcrdata | rpcutils/blockgate.go | GetChainWork | func (g *BlockGate) GetChainWork(hash *chainhash.Hash) (string, error) {
return GetChainWork(g.client, hash)
} | go | func (g *BlockGate) GetChainWork(hash *chainhash.Hash) (string, error) {
return GetChainWork(g.client, hash)
} | [
"func",
"(",
"g",
"*",
"BlockGate",
")",
"GetChainWork",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"GetChainWork",
"(",
"g",
".",
"client",
",",
"hash",
")",
"\n",
"}"
] | // GetChainWork fetches the dcrjson.BlockHeaderVerbose and returns only the
// ChainWork attribute as a string. | [
"GetChainWork",
"fetches",
"the",
"dcrjson",
".",
"BlockHeaderVerbose",
"and",
"returns",
"only",
"the",
"ChainWork",
"attribute",
"as",
"a",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/rpcutils/blockgate.go#L374-L376 |
142,293 | decred/dcrdata | stakedb/ticketpool.go | Infof | func (l *badgerLogger) Infof(format string, v ...interface{}) {
l.logf(logLevelInfo, format, v...)
} | go | func (l *badgerLogger) Infof(format string, v ...interface{}) {
l.logf(logLevelInfo, format, v...)
} | [
"func",
"(",
"l",
"*",
"badgerLogger",
")",
"Infof",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"logf",
"(",
"logLevelInfo",
",",
"format",
",",
"v",
"...",
")",
"\n",
"}"
] | // Infof filters messages through logf with logLevelInfo before sending the
// message to the slog.Logger. | [
"Infof",
"filters",
"messages",
"through",
"logf",
"with",
"logLevelInfo",
"before",
"sending",
"the",
"message",
"to",
"the",
"slog",
".",
"Logger",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L118-L120 |
142,294 | decred/dcrdata | stakedb/ticketpool.go | Warningf | func (l *badgerLogger) Warningf(format string, v ...interface{}) {
l.logf(logLevelWarn, format, v...)
} | go | func (l *badgerLogger) Warningf(format string, v ...interface{}) {
l.logf(logLevelWarn, format, v...)
} | [
"func",
"(",
"l",
"*",
"badgerLogger",
")",
"Warningf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"logf",
"(",
"logLevelWarn",
",",
"format",
",",
"v",
"...",
")",
"\n",
"}"
] | // Warningf filters messages through logf with logLevelWarn before sending the
// message to the slog.Logger. | [
"Warningf",
"filters",
"messages",
"through",
"logf",
"with",
"logLevelWarn",
"before",
"sending",
"the",
"message",
"to",
"the",
"slog",
".",
"Logger",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L124-L126 |
142,295 | decred/dcrdata | stakedb/ticketpool.go | Errorf | func (l *badgerLogger) Errorf(format string, v ...interface{}) {
l.logf(logLevelError, format, v...)
} | go | func (l *badgerLogger) Errorf(format string, v ...interface{}) {
l.logf(logLevelError, format, v...)
} | [
"func",
"(",
"l",
"*",
"badgerLogger",
")",
"Errorf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"logf",
"(",
"logLevelError",
",",
"format",
",",
"v",
"...",
")",
"\n",
"}"
] | // Errorf filters messages through logf with logLevelError before sending the
// message to the slog.Logger. | [
"Errorf",
"filters",
"messages",
"through",
"logf",
"with",
"logLevelError",
"before",
"sending",
"the",
"message",
"to",
"the",
"slog",
".",
"Logger",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L130-L132 |
142,296 | decred/dcrdata | stakedb/ticketpool.go | NewTicketPool | func NewTicketPool(dataDir, dbSubDir string) (tp *TicketPool, err error) {
// Open ticket pool diffs database
badgerDbPath := filepath.Join(dataDir, dbSubDir)
opts := badger.DefaultOptions
opts.Dir = badgerDbPath
opts.ValueDir = badgerDbPath
opts.Logger = &badgerLogger{log}
db, err := badger.Open(opts)
if err =... | go | func NewTicketPool(dataDir, dbSubDir string) (tp *TicketPool, err error) {
// Open ticket pool diffs database
badgerDbPath := filepath.Join(dataDir, dbSubDir)
opts := badger.DefaultOptions
opts.Dir = badgerDbPath
opts.ValueDir = badgerDbPath
opts.Logger = &badgerLogger{log}
db, err := badger.Open(opts)
if err =... | [
"func",
"NewTicketPool",
"(",
"dataDir",
",",
"dbSubDir",
"string",
")",
"(",
"tp",
"*",
"TicketPool",
",",
"err",
"error",
")",
"{",
"// Open ticket pool diffs database",
"badgerDbPath",
":=",
"filepath",
".",
"Join",
"(",
"dataDir",
",",
"dbSubDir",
")",
"\n... | // NewTicketPool constructs a TicketPool by opening the persistent diff db,
// loading all known diffs, initializing the TicketPool values. | [
"NewTicketPool",
"constructs",
"a",
"TicketPool",
"by",
"opening",
"the",
"persistent",
"diff",
"db",
"loading",
"all",
"known",
"diffs",
"initializing",
"the",
"TicketPool",
"values",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L136-L209 |
142,297 | decred/dcrdata | stakedb/ticketpool.go | MigrateFromStorm | func MigrateFromStorm(stormDBFile string, db *badger.DB) (bool, error) {
// Check for the storm DB file
finfo, err := os.Stat(stormDBFile)
if os.IsNotExist(err) {
return false, nil
}
if err != nil {
return false, err
}
if finfo.Size() == 0 {
return false, nil
}
// Open the storm DB file
dbOld, err := s... | go | func MigrateFromStorm(stormDBFile string, db *badger.DB) (bool, error) {
// Check for the storm DB file
finfo, err := os.Stat(stormDBFile)
if os.IsNotExist(err) {
return false, nil
}
if err != nil {
return false, err
}
if finfo.Size() == 0 {
return false, nil
}
// Open the storm DB file
dbOld, err := s... | [
"func",
"MigrateFromStorm",
"(",
"stormDBFile",
"string",
",",
"db",
"*",
"badger",
".",
"DB",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// Check for the storm DB file",
"finfo",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"stormDBFile",
")",
"\n",
"if",
... | // MigrateFromStorm attempts to load the storm DB specified by the given file
// name, and migrate all ticket pool diffs to the badger db. | [
"MigrateFromStorm",
"attempts",
"to",
"load",
"the",
"storm",
"DB",
"specified",
"by",
"the",
"given",
"file",
"name",
"and",
"migrate",
"all",
"ticket",
"pool",
"diffs",
"to",
"the",
"badger",
"db",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L213-L270 |
142,298 | decred/dcrdata | stakedb/ticketpool.go | LoadAllPoolDiffs | func LoadAllPoolDiffs(db *badger.DB) ([]PoolDiff, error) {
var poolDiffs []PoolDiff
err := db.View(func(txn *badger.Txn) error {
// Create the badger iterator
opts := badger.IteratorOptions{
PrefetchValues: true,
PrefetchSize: 1000,
Reverse: false,
AllVersions: false,
}
it := txn.NewIt... | go | func LoadAllPoolDiffs(db *badger.DB) ([]PoolDiff, error) {
var poolDiffs []PoolDiff
err := db.View(func(txn *badger.Txn) error {
// Create the badger iterator
opts := badger.IteratorOptions{
PrefetchValues: true,
PrefetchSize: 1000,
Reverse: false,
AllVersions: false,
}
it := txn.NewIt... | [
"func",
"LoadAllPoolDiffs",
"(",
"db",
"*",
"badger",
".",
"DB",
")",
"(",
"[",
"]",
"PoolDiff",
",",
"error",
")",
"{",
"var",
"poolDiffs",
"[",
"]",
"PoolDiff",
"\n",
"err",
":=",
"db",
".",
"View",
"(",
"func",
"(",
"txn",
"*",
"badger",
".",
... | // LoadAllPoolDiffs loads all found ticket pool diffs from badger DB. | [
"LoadAllPoolDiffs",
"loads",
"all",
"found",
"ticket",
"pool",
"diffs",
"from",
"badger",
"DB",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L273-L327 |
142,299 | decred/dcrdata | stakedb/ticketpool.go | Tip | func (tp *TicketPool) Tip() int64 {
tp.mtx.RLock()
defer tp.mtx.RUnlock()
return tp.tip
} | go | func (tp *TicketPool) Tip() int64 {
tp.mtx.RLock()
defer tp.mtx.RUnlock()
return tp.tip
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"Tip",
"(",
")",
"int64",
"{",
"tp",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"tp",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"tp",
".",
"tip",
"\n",
"}"
] | // Tip returns the current length of the diffs slice. | [
"Tip",
"returns",
"the",
"current",
"length",
"of",
"the",
"diffs",
"slice",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L335-L339 |
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.