repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
decred/dcrdata
api/insight/converter.go
DcrToInsightBlock
func (iapi *InsightApi) DcrToInsightBlock(inBlocks []*dcrjson.GetBlockVerboseResult) ([]*apitypes.InsightBlockResult, error) { RewardAtBlock := func(blocknum int64, voters uint16) float64 { subsidyCache := blockchain.NewSubsidyCache(0, iapi.params) work := blockchain.CalcBlockWorkSubsidy(subsidyCache, blocknum, vo...
go
func (iapi *InsightApi) DcrToInsightBlock(inBlocks []*dcrjson.GetBlockVerboseResult) ([]*apitypes.InsightBlockResult, error) { RewardAtBlock := func(blocknum int64, voters uint16) float64 { subsidyCache := blockchain.NewSubsidyCache(0, iapi.params) work := blockchain.CalcBlockWorkSubsidy(subsidyCache, blocknum, vo...
[ "func", "(", "iapi", "*", "InsightApi", ")", "DcrToInsightBlock", "(", "inBlocks", "[", "]", "*", "dcrjson", ".", "GetBlockVerboseResult", ")", "(", "[", "]", "*", "apitypes", ".", "InsightBlockResult", ",", "error", ")", "{", "RewardAtBlock", ":=", "func", ...
// DcrToInsightBlock converts a dcrjson.GetBlockVerboseResult to Insight block.
[ "DcrToInsightBlock", "converts", "a", "dcrjson", ".", "GetBlockVerboseResult", "to", "Insight", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/converter.go#L143-L174
train
decred/dcrdata
notification/ntfnchans.go
MakeNtfnChans
func MakeNtfnChans() { // If we're monitoring for blocks OR collecting block data, these channels // are necessary to handle new block notifications. Otherwise, leave them // as nil so that both a send (below) blocks and a receive (in // blockConnectedHandler) block. default case makes non-blocking below. // quit ...
go
func MakeNtfnChans() { // If we're monitoring for blocks OR collecting block data, these channels // are necessary to handle new block notifications. Otherwise, leave them // as nil so that both a send (below) blocks and a receive (in // blockConnectedHandler) block. default case makes non-blocking below. // quit ...
[ "func", "MakeNtfnChans", "(", ")", "{", "// If we're monitoring for blocks OR collecting block data, these channels", "// are necessary to handle new block notifications. Otherwise, leave them", "// as nil so that both a send (below) blocks and a receive (in", "// blockConnectedHandler) block. defau...
// MakeNtfnChans create notification channels based on config
[ "MakeNtfnChans", "create", "notification", "channels", "based", "on", "config" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/notification/ntfnchans.go#L52-L91
train
decred/dcrdata
notification/ntfnchans.go
CloseNtfnChans
func CloseNtfnChans() { if NtfnChans.ConnectChan != nil { close(NtfnChans.ConnectChan) } if NtfnChans.ConnectChanWiredDB != nil { close(NtfnChans.ConnectChanWiredDB) } if NtfnChans.ConnectChanStakeDB != nil { close(NtfnChans.ConnectChanStakeDB) } if NtfnChans.ConnectChanDcrpgDB != nil { close(NtfnChans.C...
go
func CloseNtfnChans() { if NtfnChans.ConnectChan != nil { close(NtfnChans.ConnectChan) } if NtfnChans.ConnectChanWiredDB != nil { close(NtfnChans.ConnectChanWiredDB) } if NtfnChans.ConnectChanStakeDB != nil { close(NtfnChans.ConnectChanStakeDB) } if NtfnChans.ConnectChanDcrpgDB != nil { close(NtfnChans.C...
[ "func", "CloseNtfnChans", "(", ")", "{", "if", "NtfnChans", ".", "ConnectChan", "!=", "nil", "{", "close", "(", "NtfnChans", ".", "ConnectChan", ")", "\n", "}", "\n", "if", "NtfnChans", ".", "ConnectChanWiredDB", "!=", "nil", "{", "close", "(", "NtfnChans"...
// CloseNtfnChans close all notification channels
[ "CloseNtfnChans", "close", "all", "notification", "channels" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/notification/ntfnchans.go#L94-L149
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
String
func (v CompatibilityAction) String() string { actions := map[CompatibilityAction]string{ compatRebuild: "rebuild", compatUpgrade: "upgrade", compatReindex: "reindex", compatOK: "ok", } if actionStr, ok := actions[v]; ok { return actionStr } return "unknown" }
go
func (v CompatibilityAction) String() string { actions := map[CompatibilityAction]string{ compatRebuild: "rebuild", compatUpgrade: "upgrade", compatReindex: "reindex", compatOK: "ok", } if actionStr, ok := actions[v]; ok { return actionStr } return "unknown" }
[ "func", "(", "v", "CompatibilityAction", ")", "String", "(", ")", "string", "{", "actions", ":=", "map", "[", "CompatibilityAction", "]", "string", "{", "compatRebuild", ":", "\"", "\"", ",", "compatUpgrade", ":", "\"", "\"", ",", "compatReindex", ":", "\"...
// String implements Stringer for CompatibilityAction.
[ "String", "implements", "Stringer", "for", "CompatibilityAction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L93-L104
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
NewTableVersion
func NewTableVersion(major, minor, patch uint32) TableVersion { return TableVersion{major, minor, patch} }
go
func NewTableVersion(major, minor, patch uint32) TableVersion { return TableVersion{major, minor, patch} }
[ "func", "NewTableVersion", "(", "major", ",", "minor", ",", "patch", "uint32", ")", "TableVersion", "{", "return", "TableVersion", "{", "major", ",", "minor", ",", "patch", "}", "\n", "}" ]
// NewTableVersion returns a new TableVersion with the version major.minor.patch
[ "NewTableVersion", "returns", "a", "new", "TableVersion", "with", "the", "version", "major", ".", "minor", ".", "patch" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L107-L109
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
CreateTablesLegacy
func CreateTablesLegacy(db *sql.DB) error { var err error for tableName, createCommand := range createLegacyTableStatements { var exists bool exists, err = TableExists(db, tableName) if err != nil { return err } tableVersion, ok := requiredVersions[tableName] if !ok { return fmt.Errorf("no version ...
go
func CreateTablesLegacy(db *sql.DB) error { var err error for tableName, createCommand := range createLegacyTableStatements { var exists bool exists, err = TableExists(db, tableName) if err != nil { return err } tableVersion, ok := requiredVersions[tableName] if !ok { return fmt.Errorf("no version ...
[ "func", "CreateTablesLegacy", "(", "db", "*", "sql", ".", "DB", ")", "error", "{", "var", "err", "error", "\n", "for", "tableName", ",", "createCommand", ":=", "range", "createLegacyTableStatements", "{", "var", "exists", "bool", "\n", "exists", ",", "err", ...
// CreateTablesLegacy creates all tables required by dcrdata if they do not // already exist.
[ "CreateTablesLegacy", "creates", "all", "tables", "required", "by", "dcrdata", "if", "they", "do", "not", "already", "exist", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L142-L173
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
TableUpgradesRequired
func TableUpgradesRequired(versions map[string]TableVersion) []TableUpgrade { var tableUpgrades []TableUpgrade for t := range createLegacyTableStatements { var ok bool var req, act TableVersion if req, ok = requiredVersions[t]; !ok { log.Errorf("required version unknown for table %s", t) tableUpgrades = a...
go
func TableUpgradesRequired(versions map[string]TableVersion) []TableUpgrade { var tableUpgrades []TableUpgrade for t := range createLegacyTableStatements { var ok bool var req, act TableVersion if req, ok = requiredVersions[t]; !ok { log.Errorf("required version unknown for table %s", t) tableUpgrades = a...
[ "func", "TableUpgradesRequired", "(", "versions", "map", "[", "string", "]", "TableVersion", ")", "[", "]", "TableUpgrade", "{", "var", "tableUpgrades", "[", "]", "TableUpgrade", "\n", "for", "t", ":=", "range", "createLegacyTableStatements", "{", "var", "ok", ...
// TableUpgradesRequired builds a list of table upgrade information for each // of the supported auxiliary db tables. The upgrade information includes the // table name, its current & required table versions and the action to be taken // after comparing the current & required versions.
[ "TableUpgradesRequired", "builds", "a", "list", "of", "table", "upgrade", "information", "for", "each", "of", "the", "supported", "auxiliary", "db", "tables", ".", "The", "upgrade", "information", "includes", "the", "table", "name", "its", "current", "&", "requi...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L215-L246
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
TableVersions
func TableVersions(db *sql.DB) map[string]TableVersion { versions := map[string]TableVersion{} for tableName := range createLegacyTableStatements { // Retrieve the table description. var desc string err := db.QueryRow(`select obj_description($1::regclass);`, tableName).Scan(&desc) if err != nil { log.Error...
go
func TableVersions(db *sql.DB) map[string]TableVersion { versions := map[string]TableVersion{} for tableName := range createLegacyTableStatements { // Retrieve the table description. var desc string err := db.QueryRow(`select obj_description($1::regclass);`, tableName).Scan(&desc) if err != nil { log.Error...
[ "func", "TableVersions", "(", "db", "*", "sql", ".", "DB", ")", "map", "[", "string", "]", "TableVersion", "{", "versions", ":=", "map", "[", "string", "]", "TableVersion", "{", "}", "\n", "for", "tableName", ":=", "range", "createLegacyTableStatements", "...
// TableVersions retrieve and maps the tables names in the auxiliary db to their // current table versions.
[ "TableVersions", "retrieve", "and", "maps", "the", "tables", "names", "in", "the", "auxiliary", "db", "to", "their", "current", "table", "versions", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L250-L272
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
VersionCheck
func (pgb *ChainDB) VersionCheck(client BlockGetter) error { vers := TableVersions(pgb.db) for tab, ver := range vers { log.Debugf("Table %s: v%s", tab, ver) } var needsUpgrade []TableUpgrade tableUpgrades := TableUpgradesRequired(vers) for _, val := range tableUpgrades { switch val.UpgradeType { case com...
go
func (pgb *ChainDB) VersionCheck(client BlockGetter) error { vers := TableVersions(pgb.db) for tab, ver := range vers { log.Debugf("Table %s: v%s", tab, ver) } var needsUpgrade []TableUpgrade tableUpgrades := TableUpgradesRequired(vers) for _, val := range tableUpgrades { switch val.UpgradeType { case com...
[ "func", "(", "pgb", "*", "ChainDB", ")", "VersionCheck", "(", "client", "BlockGetter", ")", "error", "{", "vers", ":=", "TableVersions", "(", "pgb", ".", "db", ")", "\n", "for", "tab", ",", "ver", ":=", "range", "vers", "{", "log", ".", "Debugf", "("...
// VersionCheck checks the current version of all known tables and notifies when // an upgrade is required. If there is no automatic upgrade supported, an error // is returned when any table is not of the correct version. An RPC client is // passed to implement the supported upgrades if need be.
[ "VersionCheck", "checks", "the", "current", "version", "of", "all", "known", "tables", "and", "notifies", "when", "an", "upgrade", "is", "required", ".", "If", "there", "is", "no", "automatic", "upgrade", "supported", "an", "error", "is", "returned", "when", ...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L328-L364
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
initiatePgUpgrade
func (pgb *ChainDB) initiatePgUpgrade(client BlockGetter, theseUpgrades []TableUpgradeType) (bool, error) { for it := range theseUpgrades { upgradeSuccess, err := pgb.handleUpgrades(client, theseUpgrades[it].upgradeType) if err != nil || !upgradeSuccess { return false, fmt.Errorf("failed to upgrade %s table to ...
go
func (pgb *ChainDB) initiatePgUpgrade(client BlockGetter, theseUpgrades []TableUpgradeType) (bool, error) { for it := range theseUpgrades { upgradeSuccess, err := pgb.handleUpgrades(client, theseUpgrades[it].upgradeType) if err != nil || !upgradeSuccess { return false, fmt.Errorf("failed to upgrade %s table to ...
[ "func", "(", "pgb", "*", "ChainDB", ")", "initiatePgUpgrade", "(", "client", "BlockGetter", ",", "theseUpgrades", "[", "]", "TableUpgradeType", ")", "(", "bool", ",", "error", ")", "{", "for", "it", ":=", "range", "theseUpgrades", "{", "upgradeSuccess", ",",...
// initiatePgUpgrade starts the specific auxiliary database.
[ "initiatePgUpgrade", "starts", "the", "specific", "auxiliary", "database", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L724-L738
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
dropBlockTimeIndexes
func (pgb *ChainDB) dropBlockTimeIndexes() { log.Info("Dropping block time indexes") err := DeindexBlockTimeOnTableAddress(pgb.db) if err != nil { log.Warnf("DeindexBlockTimeOnTableAddress failed: error: %v", err) } }
go
func (pgb *ChainDB) dropBlockTimeIndexes() { log.Info("Dropping block time indexes") err := DeindexBlockTimeOnTableAddress(pgb.db) if err != nil { log.Warnf("DeindexBlockTimeOnTableAddress failed: error: %v", err) } }
[ "func", "(", "pgb", "*", "ChainDB", ")", "dropBlockTimeIndexes", "(", ")", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "err", ":=", "DeindexBlockTimeOnTableAddress", "(", "pgb", ".", "db", ")", "\n", "if", "err", "!=", "nil", "{", "log", "."...
// dropBlockTimeIndexes drops all indexes that are likely to slow down the db // upgrade.
[ "dropBlockTimeIndexes", "drops", "all", "indexes", "that", "are", "likely", "to", "slow", "down", "the", "db", "upgrade", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1097-L1103
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
createBlockTimeIndexes
func (pgb *ChainDB) createBlockTimeIndexes() { log.Info("Creating the dropped block time indexes") err := IndexBlockTimeOnTableAddress(pgb.db) if err != nil { log.Warnf("IndexBlockTimeOnTableAddress failed: error: %v", err) } }
go
func (pgb *ChainDB) createBlockTimeIndexes() { log.Info("Creating the dropped block time indexes") err := IndexBlockTimeOnTableAddress(pgb.db) if err != nil { log.Warnf("IndexBlockTimeOnTableAddress failed: error: %v", err) } }
[ "func", "(", "pgb", "*", "ChainDB", ")", "createBlockTimeIndexes", "(", ")", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "err", ":=", "IndexBlockTimeOnTableAddress", "(", "pgb", ".", "db", ")", "\n", "if", "err", "!=", "nil", "{", "log", "."...
// CreateBlockTimeIndexes creates back all the dropped indexes.
[ "CreateBlockTimeIndexes", "creates", "back", "all", "the", "dropped", "indexes", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1106-L1112
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAllVotesMainchain
func updateAllVotesMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateVotesMainchainAll, "failed to update votes and mainchain status") }
go
func updateAllVotesMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateVotesMainchainAll, "failed to update votes and mainchain status") }
[ "func", "updateAllVotesMainchain", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateVotesMainchainAll", ",", "\"", "\"", ")", "\n", "}" ]
// updateAllVotesMainchain sets is_mainchain for all votes according to their // containing block.
[ "updateAllVotesMainchain", "sets", "is_mainchain", "for", "all", "votes", "according", "to", "their", "containing", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1360-L1363
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAllTicketsMainchain
func updateAllTicketsMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateTicketsMainchainAll, "failed to update tickets and mainchain status") }
go
func updateAllTicketsMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateTicketsMainchainAll, "failed to update tickets and mainchain status") }
[ "func", "updateAllTicketsMainchain", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateTicketsMainchainAll", ",", "\"", "\"", ")", "\n", "}" ]
// updateAllTicketsMainchain sets is_mainchain for all tickets according to // their containing block.
[ "updateAllTicketsMainchain", "sets", "is_mainchain", "for", "all", "tickets", "according", "to", "their", "containing", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1367-L1370
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAllTxnsValidMainchain
func updateAllTxnsValidMainchain(db *sql.DB) (rowsUpdated int64, err error) { rowsUpdated, err = sqlExec(db, internal.UpdateRegularTxnsValidAll, "failed to update regular transactions' validity status") if err != nil { return } return sqlExec(db, internal.UpdateTxnsMainchainAll, "failed to update all transact...
go
func updateAllTxnsValidMainchain(db *sql.DB) (rowsUpdated int64, err error) { rowsUpdated, err = sqlExec(db, internal.UpdateRegularTxnsValidAll, "failed to update regular transactions' validity status") if err != nil { return } return sqlExec(db, internal.UpdateTxnsMainchainAll, "failed to update all transact...
[ "func", "updateAllTxnsValidMainchain", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "rowsUpdated", ",", "err", "=", "sqlExec", "(", "db", ",", "internal", ".", "UpdateRegularTxnsValidAll", ",", "\"", "\...
// updateAllTxnsValidMainchain sets is_mainchain and is_valid for all // transactions according to their containing block.
[ "updateAllTxnsValidMainchain", "sets", "is_mainchain", "and", "is_valid", "for", "all", "transactions", "according", "to", "their", "containing", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1374-L1382
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAllAddressesValidMainchain
func updateAllAddressesValidMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateValidMainchainFromTransactions, "failed to update addresses rows valid_mainchain status") }
go
func updateAllAddressesValidMainchain(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateValidMainchainFromTransactions, "failed to update addresses rows valid_mainchain status") }
[ "func", "updateAllAddressesValidMainchain", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateValidMainchainFromTransactions", ",", "\"", "\"", ")", ...
// updateAllAddressesValidMainchain sets valid_mainchain for all addresses table // rows according to their corresponding transaction.
[ "updateAllAddressesValidMainchain", "sets", "valid_mainchain", "for", "all", "addresses", "table", "rows", "according", "to", "their", "corresponding", "transaction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1386-L1389
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAddressesValidMainchainPatch
func updateAddressesValidMainchainPatch(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateAddressesGloballyInvalid, "failed to update addresses rows valid_mainchain status") }
go
func updateAddressesValidMainchainPatch(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateAddressesGloballyInvalid, "failed to update addresses rows valid_mainchain status") }
[ "func", "updateAddressesValidMainchainPatch", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateAddressesGloballyInvalid", ",", "\"", "\"", ")", "\n...
// updateAddressesValidMainchainPatch selectively sets valid_mainchain for // addresses table rows that are set incorrectly according to their // corresponding transaction.
[ "updateAddressesValidMainchainPatch", "selectively", "sets", "valid_mainchain", "for", "addresses", "table", "rows", "that", "are", "set", "incorrectly", "according", "to", "their", "corresponding", "transaction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1394-L1397
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
updateAddressesMatchingTxHashPatch
func updateAddressesMatchingTxHashPatch(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateAddressesFundingMatchingHash, "failed to update addresses rows matching_tx_hash") }
go
func updateAddressesMatchingTxHashPatch(db *sql.DB) (rowsUpdated int64, err error) { return sqlExec(db, internal.UpdateAddressesFundingMatchingHash, "failed to update addresses rows matching_tx_hash") }
[ "func", "updateAddressesMatchingTxHashPatch", "(", "db", "*", "sql", ".", "DB", ")", "(", "rowsUpdated", "int64", ",", "err", "error", ")", "{", "return", "sqlExec", "(", "db", ",", "internal", ".", "UpdateAddressesFundingMatchingHash", ",", "\"", "\"", ")", ...
// updateAddressesMatchingTxHashPatch selectively sets matching_tx_hash for // addresses table rows that are set incorrectly according to their // corresponding transaction.
[ "updateAddressesMatchingTxHashPatch", "selectively", "sets", "matching_tx_hash", "for", "addresses", "table", "rows", "that", "are", "set", "incorrectly", "according", "to", "their", "corresponding", "transaction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1402-L1405
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
handleBlocksTableMainchainUpgrade
func (pgb *ChainDB) handleBlocksTableMainchainUpgrade(bestBlock string) (int64, error) { // Start at best block, upgrade, and move to previous block. Stop after // genesis, which previous block hash is the zero hash. var blocksUpdated int64 previousHash, thisBlockHash := bestBlock, bestBlock for !bytes.Equal(zeroH...
go
func (pgb *ChainDB) handleBlocksTableMainchainUpgrade(bestBlock string) (int64, error) { // Start at best block, upgrade, and move to previous block. Stop after // genesis, which previous block hash is the zero hash. var blocksUpdated int64 previousHash, thisBlockHash := bestBlock, bestBlock for !bytes.Equal(zeroH...
[ "func", "(", "pgb", "*", "ChainDB", ")", "handleBlocksTableMainchainUpgrade", "(", "bestBlock", "string", ")", "(", "int64", ",", "error", ")", "{", "// Start at best block, upgrade, and move to previous block. Stop after", "// genesis, which previous block hash is the zero hash....
// handleBlocksTableMainchainUpgrade sets is_mainchain=true for all blocks in // the main chain, starting with the best block and working back to genesis.
[ "handleBlocksTableMainchainUpgrade", "sets", "is_mainchain", "=", "true", "for", "all", "blocks", "in", "the", "main", "chain", "starting", "with", "the", "best", "block", "and", "working", "back", "to", "genesis", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1409-L1438
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
handlevinsTableCoinSupplyUpgrade
func (pgb *ChainDB) handlevinsTableCoinSupplyUpgrade(msgBlock *wire.MsgBlock) (int64, error) { var isValid bool var rowsUpdated int64 var err = pgb.db.QueryRow(`SELECT is_valid, is_mainchain FROM blocks WHERE hash = $1 ;`, msgBlock.BlockHash().String()).Scan(&isValid) if err != nil { return 0, err } // isMa...
go
func (pgb *ChainDB) handlevinsTableCoinSupplyUpgrade(msgBlock *wire.MsgBlock) (int64, error) { var isValid bool var rowsUpdated int64 var err = pgb.db.QueryRow(`SELECT is_valid, is_mainchain FROM blocks WHERE hash = $1 ;`, msgBlock.BlockHash().String()).Scan(&isValid) if err != nil { return 0, err } // isMa...
[ "func", "(", "pgb", "*", "ChainDB", ")", "handlevinsTableCoinSupplyUpgrade", "(", "msgBlock", "*", "wire", ".", "MsgBlock", ")", "(", "int64", ",", "error", ")", "{", "var", "isValid", "bool", "\n", "var", "rowsUpdated", "int64", "\n\n", "var", "err", "=",...
// handlevinsTableCoinSupplyUpgrade implements the upgrade to the new newly added columns // in the vins table. The new columns are mainly used for the coin supply chart. // If all the new columns are not added, quit the db upgrade.
[ "handlevinsTableCoinSupplyUpgrade", "implements", "the", "upgrade", "to", "the", "new", "newly", "added", "columns", "in", "the", "vins", "table", ".", "The", "new", "columns", "are", "mainly", "used", "for", "the", "coin", "supply", "chart", ".", "If", "all",...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1450-L1485
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
handleAgendasTableUpgrade
func (pgb *ChainDB) handleAgendasTableUpgrade(msgBlock *wire.MsgBlock) (int64, error) { // neither isValid or isMainchain are important dbTxns, _, _ := dbtypes.ExtractBlockTransactions(msgBlock, wire.TxTreeStake, pgb.chainParams, true, false) var rowsUpdated int64 for i, tx := range dbTxns { if tx.TxType != in...
go
func (pgb *ChainDB) handleAgendasTableUpgrade(msgBlock *wire.MsgBlock) (int64, error) { // neither isValid or isMainchain are important dbTxns, _, _ := dbtypes.ExtractBlockTransactions(msgBlock, wire.TxTreeStake, pgb.chainParams, true, false) var rowsUpdated int64 for i, tx := range dbTxns { if tx.TxType != in...
[ "func", "(", "pgb", "*", "ChainDB", ")", "handleAgendasTableUpgrade", "(", "msgBlock", "*", "wire", ".", "MsgBlock", ")", "(", "int64", ",", "error", ")", "{", "// neither isValid or isMainchain are important", "dbTxns", ",", "_", ",", "_", ":=", "dbtypes", "....
// handleAgendasTableUpgrade implements the upgrade to the newly added agenda table.
[ "handleAgendasTableUpgrade", "implements", "the", "upgrade", "to", "the", "newly", "added", "agenda", "table", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1488-L1531
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
handleAgendaAndAgendaVotesTablesUpgrade
func (pgb *ChainDB) handleAgendaAndAgendaVotesTablesUpgrade(msgBlock *wire.MsgBlock) (int64, error) { // neither isValid or isMainchain are important dbTxns, _, _ := dbtypes.ExtractBlockTransactions(msgBlock, wire.TxTreeStake, pgb.chainParams, true, false) var rowsUpdated int64 query := `UPDATE votes SET block_t...
go
func (pgb *ChainDB) handleAgendaAndAgendaVotesTablesUpgrade(msgBlock *wire.MsgBlock) (int64, error) { // neither isValid or isMainchain are important dbTxns, _, _ := dbtypes.ExtractBlockTransactions(msgBlock, wire.TxTreeStake, pgb.chainParams, true, false) var rowsUpdated int64 query := `UPDATE votes SET block_t...
[ "func", "(", "pgb", "*", "ChainDB", ")", "handleAgendaAndAgendaVotesTablesUpgrade", "(", "msgBlock", "*", "wire", ".", "MsgBlock", ")", "(", "int64", ",", "error", ")", "{", "// neither isValid or isMainchain are important", "dbTxns", ",", "_", ",", "_", ":=", "...
// handleAgendaAndAgendaVotesTableUpgrade restructures the agendas table, creates // a new agenda_votes table and adds a new block time column to votes table.
[ "handleAgendaAndAgendaVotesTableUpgrade", "restructures", "the", "agendas", "table", "creates", "a", "new", "agenda_votes", "table", "and", "adds", "a", "new", "block", "time", "column", "to", "votes", "table", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1535-L1590
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
haveEmptyAgendasTable
func haveEmptyAgendasTable(db *sql.DB) (bool, error) { var isExists int var err = db.QueryRow(`SELECT COUNT(*) FROM agendas;`).Scan(&isExists) if err != nil { return false, err } if isExists != 0 { return false, nil } return true, nil }
go
func haveEmptyAgendasTable(db *sql.DB) (bool, error) { var isExists int var err = db.QueryRow(`SELECT COUNT(*) FROM agendas;`).Scan(&isExists) if err != nil { return false, err } if isExists != 0 { return false, nil } return true, nil }
[ "func", "haveEmptyAgendasTable", "(", "db", "*", "sql", ".", "DB", ")", "(", "bool", ",", "error", ")", "{", "var", "isExists", "int", "\n", "var", "err", "=", "db", ".", "QueryRow", "(", "`SELECT COUNT(*) FROM agendas;`", ")", ".", "Scan", "(", "&", "...
// haveEmptyAgendasTable checks if the agendas table is empty. If the agenda // table exists bool false is returned otherwise bool true is returned. // If the table is not empty then this upgrade doesn't proceed.
[ "haveEmptyAgendasTable", "checks", "if", "the", "agendas", "table", "is", "empty", ".", "If", "the", "agenda", "table", "exists", "bool", "false", "is", "returned", "otherwise", "bool", "true", "is", "returned", ".", "If", "the", "table", "is", "not", "empty...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1595-L1607
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
versionAllTables
func versionAllTables(db *sql.DB, version TableVersion) error { for tableName := range createLegacyTableStatements { _, err := db.Exec(fmt.Sprintf(`COMMENT ON TABLE %s IS 'v%s';`, tableName, version)) if err != nil { return err } log.Infof("Modified the %v table version to %v", tableName, version) } r...
go
func versionAllTables(db *sql.DB, version TableVersion) error { for tableName := range createLegacyTableStatements { _, err := db.Exec(fmt.Sprintf(`COMMENT ON TABLE %s IS 'v%s';`, tableName, version)) if err != nil { return err } log.Infof("Modified the %v table version to %v", tableName, version) } r...
[ "func", "versionAllTables", "(", "db", "*", "sql", ".", "DB", ",", "version", "TableVersion", ")", "error", "{", "for", "tableName", ":=", "range", "createLegacyTableStatements", "{", "_", ",", "err", ":=", "db", ".", "Exec", "(", "fmt", ".", "Sprintf", ...
// versionAllTables comments the tables with the upgraded table version.
[ "versionAllTables", "comments", "the", "tables", "with", "the", "upgraded", "table", "version", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1865-L1876
train
decred/dcrdata
db/dcrpg/upgrades_legacy.go
verifyChainWork
func verifyChainWork(client BlockGetter, db *sql.DB) (int64, error) { // Count rows with missing chainWork. var count int64 countRow := db.QueryRow(`SELECT COUNT(hash) FROM blocks WHERE chainwork = '0';`) err := countRow.Scan(&count) if err != nil { log.Error("Failed to count null chainwork columns: %v", err) ...
go
func verifyChainWork(client BlockGetter, db *sql.DB) (int64, error) { // Count rows with missing chainWork. var count int64 countRow := db.QueryRow(`SELECT COUNT(hash) FROM blocks WHERE chainwork = '0';`) err := countRow.Scan(&count) if err != nil { log.Error("Failed to count null chainwork columns: %v", err) ...
[ "func", "verifyChainWork", "(", "client", "BlockGetter", ",", "db", "*", "sql", ".", "DB", ")", "(", "int64", ",", "error", ")", "{", "// Count rows with missing chainWork.", "var", "count", "int64", "\n", "countRow", ":=", "db", ".", "QueryRow", "(", "`SELE...
// verifyChainWork fetches and inserts missing chainwork values. // This addresses a table update done at DB version 3.7.0.
[ "verifyChainWork", "fetches", "and", "inserts", "missing", "chainwork", "values", ".", "This", "addresses", "a", "table", "update", "done", "at", "DB", "version", "3", ".", "7", ".", "0", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades_legacy.go#L1880-L1959
train
decred/dcrdata
gov/politeia/types/types.go
VotesStatuses
func VotesStatuses() map[VoteStatusType]string { m := make(map[VoteStatusType]string) for k, val := range ShorterDesc { if k == piapi.PropVoteStatusInvalid || k == piapi.PropVoteStatusDoesntExist { continue } m[VoteStatusType(k)] = val } return m }
go
func VotesStatuses() map[VoteStatusType]string { m := make(map[VoteStatusType]string) for k, val := range ShorterDesc { if k == piapi.PropVoteStatusInvalid || k == piapi.PropVoteStatusDoesntExist { continue } m[VoteStatusType(k)] = val } return m }
[ "func", "VotesStatuses", "(", ")", "map", "[", "VoteStatusType", "]", "string", "{", "m", ":=", "make", "(", "map", "[", "VoteStatusType", "]", "string", ")", "\n", "for", "k", ",", "val", ":=", "range", "ShorterDesc", "{", "if", "k", "==", "piapi", ...
// VotesStatuses returns the ShorterDesc map contents exclusive of Invalid and // Doesn't exist statuses.
[ "VotesStatuses", "returns", "the", "ShorterDesc", "map", "contents", "exclusive", "of", "Invalid", "and", "Doesn", "t", "exist", "statuses", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/types/types.go#L181-L191
train
decred/dcrdata
gov/politeia/types/types.go
IsEqual
func (a *ProposalInfo) IsEqual(b *ProposalInfo) bool { if a.CensorshipRecord != b.CensorshipRecord || a.Name != b.Name || a.State != b.State || a.NumComments != b.NumComments || a.StatusChangeMsg != b.StatusChangeMsg || a.Status != b.Status || a.Timestamp != b.Timestamp || a.Token != b.Token || a.CensoredDate !=...
go
func (a *ProposalInfo) IsEqual(b *ProposalInfo) bool { if a.CensorshipRecord != b.CensorshipRecord || a.Name != b.Name || a.State != b.State || a.NumComments != b.NumComments || a.StatusChangeMsg != b.StatusChangeMsg || a.Status != b.Status || a.Timestamp != b.Timestamp || a.Token != b.Token || a.CensoredDate !=...
[ "func", "(", "a", "*", "ProposalInfo", ")", "IsEqual", "(", "b", "*", "ProposalInfo", ")", "bool", "{", "if", "a", ".", "CensorshipRecord", "!=", "b", ".", "CensorshipRecord", "||", "a", ".", "Name", "!=", "b", ".", "Name", "||", "a", ".", "State", ...
// IsEqual compares CensorshipRecord, Name, State, NumComments, StatusChangeMsg, // Timestamp, CensoredDate, AbandonedDate, PublishedDate, Token, VoteStatus, // TotalVotes and count of VoteResults between the two ProposalsInfo structs passed.
[ "IsEqual", "compares", "CensorshipRecord", "Name", "State", "NumComments", "StatusChangeMsg", "Timestamp", "CensoredDate", "AbandonedDate", "PublishedDate", "Token", "VoteStatus", "TotalVotes", "and", "count", "of", "VoteResults", "between", "the", "two", "ProposalsInfo", ...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/types/types.go#L196-L206
train
decred/dcrdata
main.go
FileServer
func FileServer(r chi.Router, pathRoot, fsRoot string, cacheControlMaxAge int64) { if strings.ContainsAny(pathRoot, "{}*") { panic("FileServer does not permit URL parameters.") } // Define a http.HandlerFunc to serve files but not directory indexes. hf := func(w http.ResponseWriter, r *http.Request) { // Ensur...
go
func FileServer(r chi.Router, pathRoot, fsRoot string, cacheControlMaxAge int64) { if strings.ContainsAny(pathRoot, "{}*") { panic("FileServer does not permit URL parameters.") } // Define a http.HandlerFunc to serve files but not directory indexes. hf := func(w http.ResponseWriter, r *http.Request) { // Ensur...
[ "func", "FileServer", "(", "r", "chi", ".", "Router", ",", "pathRoot", ",", "fsRoot", "string", ",", "cacheControlMaxAge", "int64", ")", "{", "if", "strings", ".", "ContainsAny", "(", "pathRoot", ",", "\"", "\"", ")", "{", "panic", "(", "\"", "\"", ")"...
// FileServer conveniently sets up a http.FileServer handler to serve static // files from path on the file system. Directory listings are denied, as are URL // paths containing "..".
[ "FileServer", "conveniently", "sets", "up", "a", "http", ".", "FileServer", "handler", "to", "serve", "static", "files", "from", "path", "on", "the", "file", "system", ".", "Directory", "listings", "are", "denied", "as", "are", "URL", "paths", "containing", ...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/main.go#L1350-L1404
train
decred/dcrdata
api/insight/apimiddleware.go
StatusInfoCtx
func (iapi *InsightApi) StatusInfoCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := m.StatusInfoCtx(r, iapi.BlockData.ChainDB) next.ServeHTTP(w, r.WithContext(ctx)) }) }
go
func (iapi *InsightApi) StatusInfoCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := m.StatusInfoCtx(r, iapi.BlockData.ChainDB) next.ServeHTTP(w, r.WithContext(ctx)) }) }
[ "func", "(", "iapi", "*", "InsightApi", ")", "StatusInfoCtx", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".",...
// StatusInfoCtx is a middleware that embeds into the request context the data // for the "?q=x" URL query, where x is "getInfo" or "getDifficulty" or // "getBestBlockHash" or "getLastBlockHash".
[ "StatusInfoCtx", "is", "a", "middleware", "that", "embeds", "into", "the", "request", "context", "the", "data", "for", "the", "?q", "=", "x", "URL", "query", "where", "x", "is", "getInfo", "or", "getDifficulty", "or", "getBestBlockHash", "or", "getLastBlockHas...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L46-L52
train
decred/dcrdata
api/insight/apimiddleware.go
ValidatePostCtx
func (iapi *InsightApi) ValidatePostCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { contentLengthString := r.Header.Get("Content-Length") contentLength, err := strconv.Atoi(contentLengthString) if err != nil { writeInsightError(w, "Content-Length He...
go
func (iapi *InsightApi) ValidatePostCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { contentLengthString := r.Header.Get("Content-Length") contentLength, err := strconv.Atoi(contentLengthString) if err != nil { writeInsightError(w, "Content-Length He...
[ "func", "(", "iapi", "*", "InsightApi", ")", "ValidatePostCtx", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", "....
// ValidatePostCtx will confirm Post content length is valid.
[ "ValidatePostCtx", "will", "confirm", "Post", "content", "length", "is", "valid", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L148-L166
train
decred/dcrdata
api/insight/apimiddleware.go
PostAddrsTxsCtx
func PostAddrsTxsCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var req apitypes.InsightMultiAddrsTx var from, to, noAsm, noScriptSig, noSpent int64 body, err := ioutil.ReadAll(r.Body) r.Body.Close() if err != nil { writeInsightError(w, fmt.Sp...
go
func PostAddrsTxsCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var req apitypes.InsightMultiAddrsTx var from, to, noAsm, noScriptSig, noSpent int64 body, err := ioutil.ReadAll(r.Body) r.Body.Close() if err != nil { writeInsightError(w, fmt.Sp...
[ "func", "PostAddrsTxsCtx", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "req",...
// PostAddrsTxsCtx middleware processes parameters given in the POST request // body for an addrs endpoint.
[ "PostAddrsTxsCtx", "middleware", "processes", "parameters", "given", "in", "the", "POST", "request", "body", "for", "an", "addrs", "endpoint", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L170-L223
train
decred/dcrdata
api/insight/apimiddleware.go
PostAddrsUtxoCtx
func PostAddrsUtxoCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { req := apitypes.InsightAddr{} body, err := ioutil.ReadAll(r.Body) r.Body.Close() if err != nil { writeInsightError(w, fmt.Sprintf("error reading JSON message: %v", err)) return ...
go
func PostAddrsUtxoCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { req := apitypes.InsightAddr{} body, err := ioutil.ReadAll(r.Body) r.Body.Close() if err != nil { writeInsightError(w, fmt.Sprintf("error reading JSON message: %v", err)) return ...
[ "func", "PostAddrsUtxoCtx", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "req", ":=",...
// PostAddrsUtxoCtx middleware processes parameters given in the POST request // body for an addrs utxo endpoint.
[ "PostAddrsUtxoCtx", "middleware", "processes", "parameters", "given", "in", "the", "POST", "request", "body", "for", "an", "addrs", "utxo", "endpoint", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L227-L248
train
decred/dcrdata
api/insight/apimiddleware.go
GetAddressCommandCtx
func GetAddressCommandCtx(r *http.Request) (string, bool) { command, ok := r.Context().Value(ctxAddrCmd).(string) if !ok { return "", false } return command, true }
go
func GetAddressCommandCtx(r *http.Request) (string, bool) { command, ok := r.Context().Value(ctxAddrCmd).(string) if !ok { return "", false } return command, true }
[ "func", "GetAddressCommandCtx", "(", "r", "*", "http", ".", "Request", ")", "(", "string", ",", "bool", ")", "{", "command", ",", "ok", ":=", "r", ".", "Context", "(", ")", ".", "Value", "(", "ctxAddrCmd", ")", ".", "(", "string", ")", "\n", "if", ...
// GetAddressCommandCtx retrieves the ctxAddrCmd data from the request context. // If not set the return value is "" and false.
[ "GetAddressCommandCtx", "retrieves", "the", "ctxAddrCmd", "data", "from", "the", "request", "context", ".", "If", "not", "set", "the", "return", "value", "is", "and", "false", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L262-L268
train
decred/dcrdata
api/insight/apimiddleware.go
GetLimitCtx
func GetLimitCtx(r *http.Request) int { limit, ok := r.Context().Value(m.CtxLimit).(string) if !ok { return 0 } intValue, err := strconv.Atoi(limit) if err != nil { return 0 } return intValue }
go
func GetLimitCtx(r *http.Request) int { limit, ok := r.Context().Value(m.CtxLimit).(string) if !ok { return 0 } intValue, err := strconv.Atoi(limit) if err != nil { return 0 } return intValue }
[ "func", "GetLimitCtx", "(", "r", "*", "http", ".", "Request", ")", "int", "{", "limit", ",", "ok", ":=", "r", ".", "Context", "(", ")", ".", "Value", "(", "m", ".", "CtxLimit", ")", ".", "(", "string", ")", "\n", "if", "!", "ok", "{", "return",...
// GetLimitCtx retrieves the ctxLimit data from the request context. If not set, // the return value is 0 which is interpreted as no limit.
[ "GetLimitCtx", "retrieves", "the", "ctxLimit", "data", "from", "the", "request", "context", ".", "If", "not", "set", "the", "return", "value", "is", "0", "which", "is", "interpreted", "as", "no", "limit", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L286-L296
train
decred/dcrdata
api/insight/apimiddleware.go
GetNbBlocksCtx
func GetNbBlocksCtx(r *http.Request) int { nbBlocks, ok := r.Context().Value(ctxNbBlocks).(int) if !ok { return 0 } return nbBlocks }
go
func GetNbBlocksCtx(r *http.Request) int { nbBlocks, ok := r.Context().Value(ctxNbBlocks).(int) if !ok { return 0 } return nbBlocks }
[ "func", "GetNbBlocksCtx", "(", "r", "*", "http", ".", "Request", ")", "int", "{", "nbBlocks", ",", "ok", ":=", "r", ".", "Context", "(", ")", ".", "Value", "(", "ctxNbBlocks", ")", ".", "(", "int", ")", "\n", "if", "!", "ok", "{", "return", "0", ...
// GetNbBlocksCtx retrieves the ctxNbBlocks data from the request context. If not // set, the return value is 0.
[ "GetNbBlocksCtx", "retrieves", "the", "ctxNbBlocks", "data", "from", "the", "request", "context", ".", "If", "not", "set", "the", "return", "value", "is", "0", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L322-L328
train
decred/dcrdata
api/insight/apimiddleware.go
NbBlocksCtx
func NbBlocksCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() nbBlocks := r.FormValue("nbBlocks") nbBlocksint, err := strconv.Atoi(nbBlocks) if err == nil { ctx = context.WithValue(r.Context(), ctxNbBlocks, nbBlocksint) } nex...
go
func NbBlocksCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() nbBlocks := r.FormValue("nbBlocks") nbBlocksint, err := strconv.Atoi(nbBlocks) if err == nil { ctx = context.WithValue(r.Context(), ctxNbBlocks, nbBlocksint) } nex...
[ "func", "NbBlocksCtx", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "ctx", ":=", "r...
// NbBlocksCtx will parse the query parameters for nbBlocks.
[ "NbBlocksCtx", "will", "parse", "the", "query", "parameters", "for", "nbBlocks", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apimiddleware.go#L331-L341
train
decred/dcrdata
mempool/monitor.go
NewMempoolMonitor
func NewMempoolMonitor(ctx context.Context, collector *MempoolDataCollector, savers []MempoolDataSaver, params *chaincfg.Params, wg *sync.WaitGroup, newTxInChan <-chan *dcrjson.TxRawResult, signalOuts []chan<- pstypes.HubMessage, initialStore bool) (*MempoolMonitor, error) { // Make the skeleton MempoolMonitor. p...
go
func NewMempoolMonitor(ctx context.Context, collector *MempoolDataCollector, savers []MempoolDataSaver, params *chaincfg.Params, wg *sync.WaitGroup, newTxInChan <-chan *dcrjson.TxRawResult, signalOuts []chan<- pstypes.HubMessage, initialStore bool) (*MempoolMonitor, error) { // Make the skeleton MempoolMonitor. p...
[ "func", "NewMempoolMonitor", "(", "ctx", "context", ".", "Context", ",", "collector", "*", "MempoolDataCollector", ",", "savers", "[", "]", "MempoolDataSaver", ",", "params", "*", "chaincfg", ".", "Params", ",", "wg", "*", "sync", ".", "WaitGroup", ",", "new...
// NewMempoolMonitor creates a new MempoolMonitor. The MempoolMonitor receives // notifications of new transactions on newTxInChan, and of new blocks on the // same channel using a nil transaction message. Once TxHandler is started, the // MempoolMonitor will process incoming transactions, and forward new ones on // vi...
[ "NewMempoolMonitor", "creates", "a", "new", "MempoolMonitor", ".", "The", "MempoolMonitor", "receives", "notifications", "of", "new", "transactions", "on", "newTxInChan", "and", "of", "new", "blocks", "on", "the", "same", "channel", "using", "a", "nil", "transacti...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L72-L93
train
decred/dcrdata
mempool/monitor.go
LastBlockHash
func (p *MempoolMonitor) LastBlockHash() chainhash.Hash { p.mtx.RLock() defer p.mtx.RUnlock() return p.lastBlock.Hash }
go
func (p *MempoolMonitor) LastBlockHash() chainhash.Hash { p.mtx.RLock() defer p.mtx.RUnlock() return p.lastBlock.Hash }
[ "func", "(", "p", "*", "MempoolMonitor", ")", "LastBlockHash", "(", ")", "chainhash", ".", "Hash", "{", "p", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "p", ".", "lastBlock", ".", ...
// LastBlockHash returns the hash of the most recently stored block.
[ "LastBlockHash", "returns", "the", "hash", "of", "the", "most", "recently", "stored", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L96-L100
train
decred/dcrdata
mempool/monitor.go
LastBlockHeight
func (p *MempoolMonitor) LastBlockHeight() int64 { p.mtx.RLock() defer p.mtx.RUnlock() return p.lastBlock.Height }
go
func (p *MempoolMonitor) LastBlockHeight() int64 { p.mtx.RLock() defer p.mtx.RUnlock() return p.lastBlock.Height }
[ "func", "(", "p", "*", "MempoolMonitor", ")", "LastBlockHeight", "(", ")", "int64", "{", "p", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "p", ".", "lastBlock", ".", "Height", "\n", ...
// LastBlockHeight returns the height of the most recently stored block.
[ "LastBlockHeight", "returns", "the", "height", "of", "the", "most", "recently", "stored", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L103-L107
train
decred/dcrdata
mempool/monitor.go
LastBlockTime
func (p *MempoolMonitor) LastBlockTime() int64 { p.mtx.RLock() defer p.mtx.RUnlock() return p.lastBlock.Time }
go
func (p *MempoolMonitor) LastBlockTime() int64 { p.mtx.RLock() defer p.mtx.RUnlock() return p.lastBlock.Time }
[ "func", "(", "p", "*", "MempoolMonitor", ")", "LastBlockTime", "(", ")", "int64", "{", "p", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "p", ".", "lastBlock", ".", "Time", "\n", "}...
// LastBlockTime returns the time of the most recently stored block.
[ "LastBlockTime", "returns", "the", "time", "of", "the", "most", "recently", "stored", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L110-L114
train
decred/dcrdata
mempool/monitor.go
Refresh
func (p *MempoolMonitor) Refresh() (*StakeData, []exptypes.MempoolTx, *exptypes.MempoolInfo, error) { // Collect mempool data (currently ticket fees) log.Trace("Gathering new mempool data.") stakeData, txs, addrOuts, txnsStore, err := p.collector.Collect() if err != nil { log.Errorf("mempool data collection faile...
go
func (p *MempoolMonitor) Refresh() (*StakeData, []exptypes.MempoolTx, *exptypes.MempoolInfo, error) { // Collect mempool data (currently ticket fees) log.Trace("Gathering new mempool data.") stakeData, txs, addrOuts, txnsStore, err := p.collector.Collect() if err != nil { log.Errorf("mempool data collection faile...
[ "func", "(", "p", "*", "MempoolMonitor", ")", "Refresh", "(", ")", "(", "*", "StakeData", ",", "[", "]", "exptypes", ".", "MempoolTx", ",", "*", "exptypes", ".", "MempoolInfo", ",", "error", ")", "{", "// Collect mempool data (currently ticket fees)", "log", ...
// Refresh collects mempool data, resets counters ticket counters and the timer, // but does not dispatch the MempoolDataSavers.
[ "Refresh", "collects", "mempool", "data", "resets", "counters", "ticket", "counters", "and", "the", "timer", "but", "does", "not", "dispatch", "the", "MempoolDataSavers", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L368-L412
train
decred/dcrdata
mempool/monitor.go
CollectAndStore
func (p *MempoolMonitor) CollectAndStore() error { log.Trace("Gathering new mempool data.") stakeData, txs, inv, err := p.Refresh() if err != nil { log.Errorf("mempool data collection failed: %v", err.Error()) // stakeData is nil when err != nil return err } // Store mempool stakeData with each registered s...
go
func (p *MempoolMonitor) CollectAndStore() error { log.Trace("Gathering new mempool data.") stakeData, txs, inv, err := p.Refresh() if err != nil { log.Errorf("mempool data collection failed: %v", err.Error()) // stakeData is nil when err != nil return err } // Store mempool stakeData with each registered s...
[ "func", "(", "p", "*", "MempoolMonitor", ")", "CollectAndStore", "(", ")", "error", "{", "log", ".", "Trace", "(", "\"", "\"", ")", "\n", "stakeData", ",", "txs", ",", "inv", ",", "err", ":=", "p", ".", "Refresh", "(", ")", "\n", "if", "err", "!=...
// CollectAndStore collects mempool data, resets counters ticket counters and // the timer, and dispatches the storers.
[ "CollectAndStore", "collects", "mempool", "data", "resets", "counters", "ticket", "counters", "and", "the", "timer", "and", "dispatches", "the", "storers", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/monitor.go#L416-L437
train
decred/dcrdata
explorer/types/explorertypes.go
BlocksToTicketMaturity
func (t *TxInfo) BlocksToTicketMaturity() (blocks int64) { if t.Type != "Ticket" { return } if t.Mature == "True" { return } return t.TicketInfo.TicketMaturity + 1 - t.Confirmations }
go
func (t *TxInfo) BlocksToTicketMaturity() (blocks int64) { if t.Type != "Ticket" { return } if t.Mature == "True" { return } return t.TicketInfo.TicketMaturity + 1 - t.Confirmations }
[ "func", "(", "t", "*", "TxInfo", ")", "BlocksToTicketMaturity", "(", ")", "(", "blocks", "int64", ")", "{", "if", "t", ".", "Type", "!=", "\"", "\"", "{", "return", "\n", "}", "\n", "if", "t", ".", "Mature", "==", "\"", "\"", "{", "return", "\n",...
// BlocksToTicketMaturity will return 0 if this isn't an immature ticket.
[ "BlocksToTicketMaturity", "will", "return", "0", "if", "this", "isn", "t", "an", "immature", "ticket", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L227-L235
train
decred/dcrdata
explorer/types/explorertypes.go
VotesOnBlock
func (vi *VoteInfo) VotesOnBlock(blockHash string) bool { return vi.Validation.ForBlock(blockHash) }
go
func (vi *VoteInfo) VotesOnBlock(blockHash string) bool { return vi.Validation.ForBlock(blockHash) }
[ "func", "(", "vi", "*", "VoteInfo", ")", "VotesOnBlock", "(", "blockHash", "string", ")", "bool", "{", "return", "vi", ".", "Validation", ".", "ForBlock", "(", "blockHash", ")", "\n", "}" ]
// VotesOnBlock indicates if the vote is voting on the validity of block // specified by the given hash.
[ "VotesOnBlock", "indicates", "if", "the", "vote", "is", "voting", "on", "the", "validity", "of", "block", "specified", "by", "the", "given", "hash", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L318-L320
train
decred/dcrdata
explorer/types/explorertypes.go
ForBlock
func (v *BlockValidation) ForBlock(blockHash string) bool { return blockHash != "" && blockHash == v.Hash }
go
func (v *BlockValidation) ForBlock(blockHash string) bool { return blockHash != "" && blockHash == v.Hash }
[ "func", "(", "v", "*", "BlockValidation", ")", "ForBlock", "(", "blockHash", "string", ")", "bool", "{", "return", "blockHash", "!=", "\"", "\"", "&&", "blockHash", "==", "v", ".", "Hash", "\n", "}" ]
// ForBlock indicates if the validation choice is for the specified block.
[ "ForBlock", "indicates", "if", "the", "validation", "choice", "is", "for", "the", "specified", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L323-L325
train
decred/dcrdata
explorer/types/explorertypes.go
DeepCopy
func (mpi *MempoolInfo) DeepCopy() *MempoolInfo { if mpi == nil { return nil } mpi.RLock() defer mpi.RUnlock() out := new(MempoolInfo) out.Transactions = CopyMempoolTxSlice(mpi.Transactions) out.Tickets = CopyMempoolTxSlice(mpi.Tickets) out.Votes = CopyMempoolTxSlice(mpi.Votes) out.Revocations = CopyMempoo...
go
func (mpi *MempoolInfo) DeepCopy() *MempoolInfo { if mpi == nil { return nil } mpi.RLock() defer mpi.RUnlock() out := new(MempoolInfo) out.Transactions = CopyMempoolTxSlice(mpi.Transactions) out.Tickets = CopyMempoolTxSlice(mpi.Tickets) out.Votes = CopyMempoolTxSlice(mpi.Votes) out.Revocations = CopyMempoo...
[ "func", "(", "mpi", "*", "MempoolInfo", ")", "DeepCopy", "(", ")", "*", "MempoolInfo", "{", "if", "mpi", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "mpi", ".", "RLock", "(", ")", "\n", "defer", "mpi", ".", "RUnlock", "(", ")", "\n\n", ...
// DeepCopy makes a deep copy of MempoolInfo, where all the slice and map data // are copied over.
[ "DeepCopy", "makes", "a", "deep", "copy", "of", "MempoolInfo", "where", "all", "the", "slice", "and", "map", "data", "are", "copied", "over", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L449-L467
train
decred/dcrdata
explorer/types/explorertypes.go
Trim
func (mpi *MempoolInfo) Trim() *TrimmedMempoolInfo { mpi.RLock() mempoolRegularTxs := TrimMempoolTx(mpi.Transactions) mempoolVotes := TrimMempoolTx(mpi.Votes) data := &TrimmedMempoolInfo{ Transactions: FilterRegularTx(mempoolRegularTxs), Tickets: TrimMempoolTx(mpi.Tickets), Votes: FilterUniqueLa...
go
func (mpi *MempoolInfo) Trim() *TrimmedMempoolInfo { mpi.RLock() mempoolRegularTxs := TrimMempoolTx(mpi.Transactions) mempoolVotes := TrimMempoolTx(mpi.Votes) data := &TrimmedMempoolInfo{ Transactions: FilterRegularTx(mempoolRegularTxs), Tickets: TrimMempoolTx(mpi.Tickets), Votes: FilterUniqueLa...
[ "func", "(", "mpi", "*", "MempoolInfo", ")", "Trim", "(", ")", "*", "TrimmedMempoolInfo", "{", "mpi", ".", "RLock", "(", ")", "\n\n", "mempoolRegularTxs", ":=", "TrimMempoolTx", "(", "mpi", ".", "Transactions", ")", "\n", "mempoolVotes", ":=", "TrimMempoolTx...
// Trim converts the MempoolInfo to TrimmedMempoolInfo.
[ "Trim", "converts", "the", "MempoolInfo", "to", "TrimmedMempoolInfo", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L470-L501
train
decred/dcrdata
explorer/types/explorertypes.go
getTxFromList
func getTxFromList(txid string, txns []MempoolTx) (MempoolTx, bool) { for idx := range txns { if txns[idx].TxID == txid { return txns[idx], true } } return MempoolTx{}, false }
go
func getTxFromList(txid string, txns []MempoolTx) (MempoolTx, bool) { for idx := range txns { if txns[idx].TxID == txid { return txns[idx], true } } return MempoolTx{}, false }
[ "func", "getTxFromList", "(", "txid", "string", ",", "txns", "[", "]", "MempoolTx", ")", "(", "MempoolTx", ",", "bool", ")", "{", "for", "idx", ":=", "range", "txns", "{", "if", "txns", "[", "idx", "]", ".", "TxID", "==", "txid", "{", "return", "tx...
// getTxFromList is a helper function for searching the MempoolInfo tx lists.
[ "getTxFromList", "is", "a", "helper", "function", "for", "searching", "the", "MempoolInfo", "tx", "lists", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L504-L511
train
decred/dcrdata
explorer/types/explorertypes.go
Tx
func (mpi *MempoolInfo) Tx(txid string) (MempoolTx, bool) { mpi.RLock() defer mpi.RUnlock() _, found := mpi.InvRegular[txid] if found { return getTxFromList(txid, mpi.Transactions) } _, found = mpi.InvStake[txid] if found { tx, found := getTxFromList(txid, mpi.Tickets) if found { return tx, true } t...
go
func (mpi *MempoolInfo) Tx(txid string) (MempoolTx, bool) { mpi.RLock() defer mpi.RUnlock() _, found := mpi.InvRegular[txid] if found { return getTxFromList(txid, mpi.Transactions) } _, found = mpi.InvStake[txid] if found { tx, found := getTxFromList(txid, mpi.Tickets) if found { return tx, true } t...
[ "func", "(", "mpi", "*", "MempoolInfo", ")", "Tx", "(", "txid", "string", ")", "(", "MempoolTx", ",", "bool", ")", "{", "mpi", ".", "RLock", "(", ")", "\n", "defer", "mpi", ".", "RUnlock", "(", ")", "\n", "_", ",", "found", ":=", "mpi", ".", "I...
// Tx checks the inventory and searches the appropriate lists for a // transaction matching the provided transaction ID.
[ "Tx", "checks", "the", "inventory", "and", "searches", "the", "appropriate", "lists", "for", "a", "transaction", "matching", "the", "provided", "transaction", "ID", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L515-L535
train
decred/dcrdata
explorer/types/explorertypes.go
ID
func (mpi *MempoolInfo) ID() uint64 { mpi.RLock() defer mpi.RUnlock() return mpi.Ident }
go
func (mpi *MempoolInfo) ID() uint64 { mpi.RLock() defer mpi.RUnlock() return mpi.Ident }
[ "func", "(", "mpi", "*", "MempoolInfo", ")", "ID", "(", ")", "uint64", "{", "mpi", ".", "RLock", "(", ")", "\n", "defer", "mpi", ".", "RUnlock", "(", ")", "\n", "return", "mpi", ".", "Ident", "\n", "}" ]
// ID can be used to track state changes.
[ "ID", "can", "be", "used", "to", "track", "state", "changes", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L538-L542
train
decred/dcrdata
explorer/types/explorertypes.go
FilterUniqueLastBlockVotes
func FilterUniqueLastBlockVotes(txs []*TrimmedTxInfo) (votes []*TrimmedTxInfo) { seenVotes := make(map[string]struct{}) for _, tx := range txs { if tx.VoteInfo != nil && tx.VoteInfo.ForLastBlock { // Do not append duplicates. if _, seen := seenVotes[tx.TxID]; seen { continue } votes = append(votes, ...
go
func FilterUniqueLastBlockVotes(txs []*TrimmedTxInfo) (votes []*TrimmedTxInfo) { seenVotes := make(map[string]struct{}) for _, tx := range txs { if tx.VoteInfo != nil && tx.VoteInfo.ForLastBlock { // Do not append duplicates. if _, seen := seenVotes[tx.TxID]; seen { continue } votes = append(votes, ...
[ "func", "FilterUniqueLastBlockVotes", "(", "txs", "[", "]", "*", "TrimmedTxInfo", ")", "(", "votes", "[", "]", "*", "TrimmedTxInfo", ")", "{", "seenVotes", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "for", "_", ",", ...
// FilterUniqueLastBlockVotes returns a slice of all the vote transactions from // the input slice that are flagged as voting on the previous block.
[ "FilterUniqueLastBlockVotes", "returns", "a", "slice", "of", "all", "the", "vote", "transactions", "from", "the", "input", "slice", "that", "are", "flagged", "as", "voting", "on", "the", "previous", "block", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L594-L607
train
decred/dcrdata
explorer/types/explorertypes.go
NewVotingInfo
func NewVotingInfo(votesPerBlock uint16) VotingInfo { return VotingInfo{ MaxVotesPerBlock: votesPerBlock, VotedTickets: make(map[string]bool), VoteTallys: make(map[string]*VoteTally), } }
go
func NewVotingInfo(votesPerBlock uint16) VotingInfo { return VotingInfo{ MaxVotesPerBlock: votesPerBlock, VotedTickets: make(map[string]bool), VoteTallys: make(map[string]*VoteTally), } }
[ "func", "NewVotingInfo", "(", "votesPerBlock", "uint16", ")", "VotingInfo", "{", "return", "VotingInfo", "{", "MaxVotesPerBlock", ":", "votesPerBlock", ",", "VotedTickets", ":", "make", "(", "map", "[", "string", "]", "bool", ")", ",", "VoteTallys", ":", "make...
// NewVotingInfo initializes a VotingInfo.
[ "NewVotingInfo", "initializes", "a", "VotingInfo", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L726-L732
train
decred/dcrdata
explorer/types/explorertypes.go
Tally
func (vi *VotingInfo) Tally(vinfo *VoteInfo) { _, ok := vi.VoteTallys[vinfo.Validation.Hash] if ok { vi.VoteTallys[vinfo.Validation.Hash].Mark(vinfo.Validation.Validity) return } marks := make([]bool, 1, vi.MaxVotesPerBlock) marks[0] = vinfo.Validation.Validity vi.VoteTallys[vinfo.Validation.Hash] = &VoteTall...
go
func (vi *VotingInfo) Tally(vinfo *VoteInfo) { _, ok := vi.VoteTallys[vinfo.Validation.Hash] if ok { vi.VoteTallys[vinfo.Validation.Hash].Mark(vinfo.Validation.Validity) return } marks := make([]bool, 1, vi.MaxVotesPerBlock) marks[0] = vinfo.Validation.Validity vi.VoteTallys[vinfo.Validation.Hash] = &VoteTall...
[ "func", "(", "vi", "*", "VotingInfo", ")", "Tally", "(", "vinfo", "*", "VoteInfo", ")", "{", "_", ",", "ok", ":=", "vi", ".", "VoteTallys", "[", "vinfo", ".", "Validation", ".", "Hash", "]", "\n", "if", "ok", "{", "vi", ".", "VoteTallys", "[", "v...
// Tally adds the VoteInfo to the VotingInfo.VoteTally
[ "Tally", "adds", "the", "VoteInfo", "to", "the", "VotingInfo", ".", "VoteTally" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L735-L747
train
decred/dcrdata
explorer/types/explorertypes.go
BlockStatus
func (vi *VotingInfo) BlockStatus(hash string) ([]int, int) { tally, ok := vi.VoteTallys[hash] if ok { return tally.Status() } marks := make([]int, int(vi.MaxVotesPerBlock)) for i := range marks { marks[i] = VoteMissing } return marks, VoteMissing }
go
func (vi *VotingInfo) BlockStatus(hash string) ([]int, int) { tally, ok := vi.VoteTallys[hash] if ok { return tally.Status() } marks := make([]int, int(vi.MaxVotesPerBlock)) for i := range marks { marks[i] = VoteMissing } return marks, VoteMissing }
[ "func", "(", "vi", "*", "VotingInfo", ")", "BlockStatus", "(", "hash", "string", ")", "(", "[", "]", "int", ",", "int", ")", "{", "tally", ",", "ok", ":=", "vi", ".", "VoteTallys", "[", "hash", "]", "\n", "if", "ok", "{", "return", "tally", ".", ...
// BlockStatus fetches a list of votes in mempool, for the provided block hash. // If not found, a list of VoteMissing is returned.
[ "BlockStatus", "fetches", "a", "list", "of", "votes", "in", "mempool", "for", "the", "provided", "block", "hash", ".", "If", "not", "found", "a", "list", "of", "VoteMissing", "is", "returned", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L751-L761
train
decred/dcrdata
explorer/types/explorertypes.go
Mark
func (tally *VoteTally) Mark(vote bool) { tally.Marks = append(tally.Marks, vote) }
go
func (tally *VoteTally) Mark(vote bool) { tally.Marks = append(tally.Marks, vote) }
[ "func", "(", "tally", "*", "VoteTally", ")", "Mark", "(", "vote", "bool", ")", "{", "tally", ".", "Marks", "=", "append", "(", "tally", ".", "Marks", ",", "vote", ")", "\n", "}" ]
// Mark adds the vote to the VoteTally.
[ "Mark", "adds", "the", "vote", "to", "the", "VoteTally", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L770-L772
train
decred/dcrdata
explorer/types/explorertypes.go
Affirmations
func (tally *VoteTally) Affirmations() (c int) { for _, affirmed := range tally.Marks { if affirmed { c++ } } return c }
go
func (tally *VoteTally) Affirmations() (c int) { for _, affirmed := range tally.Marks { if affirmed { c++ } } return c }
[ "func", "(", "tally", "*", "VoteTally", ")", "Affirmations", "(", ")", "(", "c", "int", ")", "{", "for", "_", ",", "affirmed", ":=", "range", "tally", ".", "Marks", "{", "if", "affirmed", "{", "c", "++", "\n", "}", "\n", "}", "\n", "return", "c",...
// Affirmations counts the number of selected ticket holders who have voted // in favor of the block for the given hash.
[ "Affirmations", "counts", "the", "number", "of", "selected", "ticket", "holders", "who", "have", "voted", "in", "favor", "of", "the", "block", "for", "the", "given", "hash", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L803-L810
train
decred/dcrdata
explorer/types/explorertypes.go
AddressPrefixes
func AddressPrefixes(params *chaincfg.Params) []AddrPrefix { Descriptions := []string{"P2PK address", "P2PKH address prefix. Standard wallet address. 1 public key -> 1 private key", "Ed25519 P2PKH address prefix", "secp256k1 Schnorr P2PKH address prefix", "P2SH address prefix", "WIF private key prefix", "H...
go
func AddressPrefixes(params *chaincfg.Params) []AddrPrefix { Descriptions := []string{"P2PK address", "P2PKH address prefix. Standard wallet address. 1 public key -> 1 private key", "Ed25519 P2PKH address prefix", "secp256k1 Schnorr P2PKH address prefix", "P2SH address prefix", "WIF private key prefix", "H...
[ "func", "AddressPrefixes", "(", "params", "*", "chaincfg", ".", "Params", ")", "[", "]", "AddrPrefix", "{", "Descriptions", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", ...
// AddressPrefixes generates an array AddrPrefix by using chaincfg.Params
[ "AddressPrefixes", "generates", "an", "array", "AddrPrefix", "by", "using", "chaincfg", ".", "Params" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L952-L997
train
decred/dcrdata
explorer/types/explorertypes.go
UnspentOutputIndices
func UnspentOutputIndices(vouts []Vout) (unspents []int) { for idx := range vouts { vout := vouts[idx] if vout.Amount == 0.0 || vout.Spent { continue } unspents = append(unspents, idx) } return }
go
func UnspentOutputIndices(vouts []Vout) (unspents []int) { for idx := range vouts { vout := vouts[idx] if vout.Amount == 0.0 || vout.Spent { continue } unspents = append(unspents, idx) } return }
[ "func", "UnspentOutputIndices", "(", "vouts", "[", "]", "Vout", ")", "(", "unspents", "[", "]", "int", ")", "{", "for", "idx", ":=", "range", "vouts", "{", "vout", ":=", "vouts", "[", "idx", "]", "\n", "if", "vout", ".", "Amount", "==", "0.0", "||"...
// UnspentOutputIndices finds the indices of the transaction outputs that appear // unspent. The indices returned are the index within the passed slice, not // within the transaction.
[ "UnspentOutputIndices", "finds", "the", "indices", "of", "the", "transaction", "outputs", "that", "appear", "unspent", ".", "The", "indices", "returned", "are", "the", "index", "within", "the", "passed", "slice", "not", "within", "the", "transaction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L1035-L1044
train
decred/dcrdata
explorer/types/explorertypes.go
MsgTxMempoolInputs
func MsgTxMempoolInputs(msgTx *wire.MsgTx) (inputs []MempoolInput) { for vindex := range msgTx.TxIn { outpoint := msgTx.TxIn[vindex].PreviousOutPoint outId := outpoint.Hash.String() inputs = append(inputs, MempoolInput{ TxId: outId, Index: uint32(vindex), Outdex: outpoint.Index, }) } return }
go
func MsgTxMempoolInputs(msgTx *wire.MsgTx) (inputs []MempoolInput) { for vindex := range msgTx.TxIn { outpoint := msgTx.TxIn[vindex].PreviousOutPoint outId := outpoint.Hash.String() inputs = append(inputs, MempoolInput{ TxId: outId, Index: uint32(vindex), Outdex: outpoint.Index, }) } return }
[ "func", "MsgTxMempoolInputs", "(", "msgTx", "*", "wire", ".", "MsgTx", ")", "(", "inputs", "[", "]", "MempoolInput", ")", "{", "for", "vindex", ":=", "range", "msgTx", ".", "TxIn", "{", "outpoint", ":=", "msgTx", ".", "TxIn", "[", "vindex", "]", ".", ...
// MsgTxMempoolInputs parses a MsgTx and creates a list of MempoolInput.
[ "MsgTxMempoolInputs", "parses", "a", "MsgTx", "and", "creates", "a", "list", "of", "MempoolInput", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/types/explorertypes.go#L1047-L1058
train
decred/dcrdata
explorer/templates.go
execTemplateToString
func (t *templates) execTemplateToString(name string, data interface{}) (string, error) { temp, ok := t.templates[name] if !ok { return "", fmt.Errorf("Template %s not known", name) } var page bytes.Buffer err := temp.template.ExecuteTemplate(&page, name, data) return page.String(), err }
go
func (t *templates) execTemplateToString(name string, data interface{}) (string, error) { temp, ok := t.templates[name] if !ok { return "", fmt.Errorf("Template %s not known", name) } var page bytes.Buffer err := temp.template.ExecuteTemplate(&page, name, data) return page.String(), err }
[ "func", "(", "t", "*", "templates", ")", "execTemplateToString", "(", "name", "string", ",", "data", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "temp", ",", "ok", ":=", "t", ".", "templates", "[", "name", "]", "\n", "if", "!...
// execTemplateToString executes the associated input template using the // supplied data, and writes the result into a string. If the template fails to // execute or isn't found, a non-nil error will be returned. Check it before // writing to theclient, otherwise you might as well execute directly into // your respons...
[ "execTemplateToString", "executes", "the", "associated", "input", "template", "using", "the", "supplied", "data", "and", "writes", "the", "result", "into", "a", "string", ".", "If", "the", "template", "fails", "to", "execute", "or", "isn", "t", "found", "a", ...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/templates.go#L83-L92
train
decred/dcrdata
txhelpers/subsidy.go
UltimateSubsidy
func UltimateSubsidy(params *chaincfg.Params) int64 { // Check previously computed ultimate subsidies. totalSubsidy, ok := ultimateSubsidies[params] if ok { return totalSubsidy } subsidyCache := blockchain.NewSubsidyCache(0, params) totalSubsidy = params.BlockOneSubsidy() for i := int64(0); ; i++ { // Gene...
go
func UltimateSubsidy(params *chaincfg.Params) int64 { // Check previously computed ultimate subsidies. totalSubsidy, ok := ultimateSubsidies[params] if ok { return totalSubsidy } subsidyCache := blockchain.NewSubsidyCache(0, params) totalSubsidy = params.BlockOneSubsidy() for i := int64(0); ; i++ { // Gene...
[ "func", "UltimateSubsidy", "(", "params", "*", "chaincfg", ".", "Params", ")", "int64", "{", "// Check previously computed ultimate subsidies.", "totalSubsidy", ",", "ok", ":=", "ultimateSubsidies", "[", "params", "]", "\n", "if", "ok", "{", "return", "totalSubsidy"...
// UltimateSubsidy computes the total subsidy over the entire subsidy // distribution period of the network.
[ "UltimateSubsidy", "computes", "the", "total", "subsidy", "over", "the", "entire", "subsidy", "distribution", "period", "of", "the", "network", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/subsidy.go#L18-L66
train
decred/dcrdata
db/dcrsqlite/apisource.go
InitWiredDB
func InitWiredDB(dbInfo *DBInfo, stakeDB *stakedb.StakeDatabase, statusC chan uint32, cl *rpcclient.Client, p *chaincfg.Params, shutdown func()) (*WiredDB, error) { db, err := InitDB(dbInfo, shutdown) if err != nil { return nil, err } return newWiredDB(db, stakeDB, statusC, cl, p), nil }
go
func InitWiredDB(dbInfo *DBInfo, stakeDB *stakedb.StakeDatabase, statusC chan uint32, cl *rpcclient.Client, p *chaincfg.Params, shutdown func()) (*WiredDB, error) { db, err := InitDB(dbInfo, shutdown) if err != nil { return nil, err } return newWiredDB(db, stakeDB, statusC, cl, p), nil }
[ "func", "InitWiredDB", "(", "dbInfo", "*", "DBInfo", ",", "stakeDB", "*", "stakedb", ".", "StakeDatabase", ",", "statusC", "chan", "uint32", ",", "cl", "*", "rpcclient", ".", "Client", ",", "p", "*", "chaincfg", ".", "Params", ",", "shutdown", "func", "(...
// InitWiredDB creates a new WiredDB from a file containing the data for a // sql.DB. The other parameters are same as those for NewWiredDB.
[ "InitWiredDB", "creates", "a", "new", "WiredDB", "from", "a", "file", "containing", "the", "data", "for", "a", "sql", ".", "DB", ".", "The", "other", "parameters", "are", "same", "as", "those", "for", "NewWiredDB", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L78-L86
train
decred/dcrdata
db/dcrsqlite/apisource.go
ReportHeights
func (db *WiredDB) ReportHeights() error { // Check and report heights of the DBs. dbHeight is the lowest of the // heights, and may be -1 with an empty SQLite DB. dbHeight, summaryHeight, stakeInfoHeight, stakeDBHeight, err := db.DBHeights() if err != nil { return fmt.Errorf("DBHeights failed: %v", err) } if d...
go
func (db *WiredDB) ReportHeights() error { // Check and report heights of the DBs. dbHeight is the lowest of the // heights, and may be -1 with an empty SQLite DB. dbHeight, summaryHeight, stakeInfoHeight, stakeDBHeight, err := db.DBHeights() if err != nil { return fmt.Errorf("DBHeights failed: %v", err) } if d...
[ "func", "(", "db", "*", "WiredDB", ")", "ReportHeights", "(", ")", "error", "{", "// Check and report heights of the DBs. dbHeight is the lowest of the", "// heights, and may be -1 with an empty SQLite DB.", "dbHeight", ",", "summaryHeight", ",", "stakeInfoHeight", ",", "stakeD...
// ReportHeights logs the SQLite table heights, and the stake database height, // returning a non-nil error only when the SQLite tables are not at the same // height.
[ "ReportHeights", "logs", "the", "SQLite", "table", "heights", "and", "the", "stake", "database", "height", "returning", "a", "non", "-", "nil", "error", "only", "when", "the", "SQLite", "tables", "are", "not", "at", "the", "same", "height", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L149-L168
train
decred/dcrdata
db/dcrsqlite/apisource.go
CheckConnectivity
func (db *WiredDB) CheckConnectivity() error { var err error if err = db.Ping(); err != nil { return err } if err = db.client.Ping(); err != nil { return err } return err }
go
func (db *WiredDB) CheckConnectivity() error { var err error if err = db.Ping(); err != nil { return err } if err = db.client.Ping(); err != nil { return err } return err }
[ "func", "(", "db", "*", "WiredDB", ")", "CheckConnectivity", "(", ")", "error", "{", "var", "err", "error", "\n", "if", "err", "=", "db", ".", "Ping", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", "=", "...
// CheckConnectivity ensures the db and RPC client are working.
[ "CheckConnectivity", "ensures", "the", "db", "and", "RPC", "client", "are", "working", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L171-L180
train
decred/dcrdata
db/dcrsqlite/apisource.go
PurgeBlocksAboveHeight
func (db *WiredDB) PurgeBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error) { var summaryHeight, stakeInfoHeight int64 _, summaryHeight, stakeInfoHeight, _, err = db.DBHeights() if err != nil { return } if summaryHeight != stakeInfoHeight { log.Warnf("Tables are at different heights...
go
func (db *WiredDB) PurgeBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error) { var summaryHeight, stakeInfoHeight int64 _, summaryHeight, stakeInfoHeight, _, err = db.DBHeights() if err != nil { return } if summaryHeight != stakeInfoHeight { log.Warnf("Tables are at different heights...
[ "func", "(", "db", "*", "WiredDB", ")", "PurgeBlocksAboveHeight", "(", "height", "int64", ")", "(", "NSummaryRows", ",", "NStakeInfoRows", "int64", ",", "err", "error", ")", "{", "var", "summaryHeight", ",", "stakeInfoHeight", "int64", "\n", "_", ",", "summa...
// PurgeBlocksAboveHeight deletes all data across all tables for the blocks // above the given height, including side chain blocks. The numbers of blocks // removed from the block summary table and stake info table are returned. // PurgeBlocksAboveHeight will not return sql.ErrNoRows, but it will return // without remo...
[ "PurgeBlocksAboveHeight", "deletes", "all", "data", "across", "all", "tables", "for", "the", "blocks", "above", "the", "given", "height", "including", "side", "chain", "blocks", ".", "The", "numbers", "of", "blocks", "removed", "from", "the", "block", "summary",...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L257-L306
train
decred/dcrdata
db/dcrsqlite/apisource.go
PurgeBlock
func (db *WiredDB) PurgeBlock(hash string) (NSummaryRows, NStakeInfoRows int64, err error) { NSummaryRows, NStakeInfoRows, err = db.DeleteBlock(hash) // DeleteBlock should not return sql.ErrNoRows, but check anyway. if err == sql.ErrNoRows { err = nil } return }
go
func (db *WiredDB) PurgeBlock(hash string) (NSummaryRows, NStakeInfoRows int64, err error) { NSummaryRows, NStakeInfoRows, err = db.DeleteBlock(hash) // DeleteBlock should not return sql.ErrNoRows, but check anyway. if err == sql.ErrNoRows { err = nil } return }
[ "func", "(", "db", "*", "WiredDB", ")", "PurgeBlock", "(", "hash", "string", ")", "(", "NSummaryRows", ",", "NStakeInfoRows", "int64", ",", "err", "error", ")", "{", "NSummaryRows", ",", "NStakeInfoRows", ",", "err", "=", "db", ".", "DeleteBlock", "(", "...
// PurgeBlock deletes all data across all tables for the block with the // specified hash. The numbers of blocks removed from the block summary table // and stake info table are returned. PurgeBlock will not return sql.ErrNoRows, // but it may return without removing a block.
[ "PurgeBlock", "deletes", "all", "data", "across", "all", "tables", "for", "the", "block", "with", "the", "specified", "hash", ".", "The", "numbers", "of", "blocks", "removed", "from", "the", "block", "summary", "table", "and", "stake", "info", "table", "are"...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L312-L319
train
decred/dcrdata
db/dcrsqlite/apisource.go
PurgeBestBlock
func (db *WiredDB) PurgeBestBlock() (NSummaryRows, NStakeInfoRows, height int64, hash string, err error) { var summaryHeight, stakeInfoHeight int64 _, summaryHeight, stakeInfoHeight, _, err = db.DBHeights() if err != nil { return } if summaryHeight != stakeInfoHeight { err = fmt.Errorf("tables are at different...
go
func (db *WiredDB) PurgeBestBlock() (NSummaryRows, NStakeInfoRows, height int64, hash string, err error) { var summaryHeight, stakeInfoHeight int64 _, summaryHeight, stakeInfoHeight, _, err = db.DBHeights() if err != nil { return } if summaryHeight != stakeInfoHeight { err = fmt.Errorf("tables are at different...
[ "func", "(", "db", "*", "WiredDB", ")", "PurgeBestBlock", "(", ")", "(", "NSummaryRows", ",", "NStakeInfoRows", ",", "height", "int64", ",", "hash", "string", ",", "err", "error", ")", "{", "var", "summaryHeight", ",", "stakeInfoHeight", "int64", "\n", "_"...
// PurgeBestBlock deletes all data across all tables for the best block in the // block summary table. The numbers of blocks removed from the block summary // table and stake info table are returned. PurgeBestBlock will not return // sql.ErrNoRows, but it will return without removing a block if the tables are // empty....
[ "PurgeBestBlock", "deletes", "all", "data", "across", "all", "tables", "for", "the", "best", "block", "in", "the", "block", "summary", "table", ".", "The", "numbers", "of", "blocks", "removed", "from", "the", "block", "summary", "table", "and", "stake", "inf...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L327-L368
train
decred/dcrdata
db/dcrsqlite/apisource.go
PurgeBestBlocks
func (db *WiredDB) PurgeBestBlocks(N int64) (NSummaryRows, NStakeInfoRows, height int64, hash string, err error) { // If N is less than 1, get the current best block height and hash, then // return. if N < 1 { var h chainhash.Hash h, height, err = db.GetBestBlockHeightHash() if err == sql.ErrNoRows { err = ...
go
func (db *WiredDB) PurgeBestBlocks(N int64) (NSummaryRows, NStakeInfoRows, height int64, hash string, err error) { // If N is less than 1, get the current best block height and hash, then // return. if N < 1 { var h chainhash.Hash h, height, err = db.GetBestBlockHeightHash() if err == sql.ErrNoRows { err = ...
[ "func", "(", "db", "*", "WiredDB", ")", "PurgeBestBlocks", "(", "N", "int64", ")", "(", "NSummaryRows", ",", "NStakeInfoRows", ",", "height", "int64", ",", "hash", "string", ",", "err", "error", ")", "{", "// If N is less than 1, get the current best block height ...
// PurgeBestBlocks deletes all data across all tables for the N best blocks in // the block summary table. The number of blocks removed is returned. // PurgeBestBlocks will not return sql.ErrNoRows, but it will return without // removing the requested number of blocks if the tables are empty or become // empty. The ret...
[ "PurgeBestBlocks", "deletes", "all", "data", "across", "all", "tables", "for", "the", "N", "best", "blocks", "in", "the", "block", "summary", "table", ".", "The", "number", "of", "blocks", "removed", "is", "returned", ".", "PurgeBestBlocks", "will", "not", "...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L376-L424
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetBestBlockHeightHash
func (db *WiredDB) GetBestBlockHeightHash() (chainhash.Hash, int64, error) { bestBlockSummary := db.GetBestBlockSummary() if bestBlockSummary == nil { return chainhash.Hash{}, -1, fmt.Errorf("unable to retrieve best block summary") } height := int64(bestBlockSummary.Height) hash, err := chainhash.NewHashFromStr(...
go
func (db *WiredDB) GetBestBlockHeightHash() (chainhash.Hash, int64, error) { bestBlockSummary := db.GetBestBlockSummary() if bestBlockSummary == nil { return chainhash.Hash{}, -1, fmt.Errorf("unable to retrieve best block summary") } height := int64(bestBlockSummary.Height) hash, err := chainhash.NewHashFromStr(...
[ "func", "(", "db", "*", "WiredDB", ")", "GetBestBlockHeightHash", "(", ")", "(", "chainhash", ".", "Hash", ",", "int64", ",", "error", ")", "{", "bestBlockSummary", ":=", "db", ".", "GetBestBlockSummary", "(", ")", "\n", "if", "bestBlockSummary", "==", "ni...
// GetBestBlockHeightHash retrieves the DB's best block hash and height.
[ "GetBestBlockHeightHash", "retrieves", "the", "DB", "s", "best", "block", "hash", "and", "height", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L427-L435
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetRawTransactionWithPrevOutAddresses
func (db *WiredDB) GetRawTransactionWithPrevOutAddresses(txid *chainhash.Hash) (*apitypes.Tx, [][]string) { tx, _ := db.getRawTransaction(txid) if tx == nil { return nil, nil } prevOutAddresses := make([][]string, len(tx.Vin)) for i := range tx.Vin { vin := &tx.Vin[i] // Skip inspecting previous outpoint f...
go
func (db *WiredDB) GetRawTransactionWithPrevOutAddresses(txid *chainhash.Hash) (*apitypes.Tx, [][]string) { tx, _ := db.getRawTransaction(txid) if tx == nil { return nil, nil } prevOutAddresses := make([][]string, len(tx.Vin)) for i := range tx.Vin { vin := &tx.Vin[i] // Skip inspecting previous outpoint f...
[ "func", "(", "db", "*", "WiredDB", ")", "GetRawTransactionWithPrevOutAddresses", "(", "txid", "*", "chainhash", ".", "Hash", ")", "(", "*", "apitypes", ".", "Tx", ",", "[", "]", "[", "]", "string", ")", "{", "tx", ",", "_", ":=", "db", ".", "getRawTr...
// GetRawTransactionWithPrevOutAddresses looks up the previous outpoints for a // transaction and extracts a slice of addresses encoded by the pkScript for // each previous outpoint consumed by the transaction.
[ "GetRawTransactionWithPrevOutAddresses", "looks", "up", "the", "previous", "outpoints", "for", "a", "transaction", "and", "extracts", "a", "slice", "of", "addresses", "encoded", "by", "the", "pkScript", "for", "each", "previous", "outpoint", "consumed", "by", "the",...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L611-L635
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetVoteVersionInfo
func (db *WiredDB) GetVoteVersionInfo(ver uint32) (*dcrjson.GetVoteInfoResult, error) { return db.client.GetVoteInfo(ver) }
go
func (db *WiredDB) GetVoteVersionInfo(ver uint32) (*dcrjson.GetVoteInfoResult, error) { return db.client.GetVoteInfo(ver) }
[ "func", "(", "db", "*", "WiredDB", ")", "GetVoteVersionInfo", "(", "ver", "uint32", ")", "(", "*", "dcrjson", ".", "GetVoteInfoResult", ",", "error", ")", "{", "return", "db", ".", "client", ".", "GetVoteInfo", "(", "ver", ")", "\n", "}" ]
// GetVoteVersionInfo requests stake version info from the dcrd RPC server
[ "GetVoteVersionInfo", "requests", "stake", "version", "info", "from", "the", "dcrd", "RPC", "server" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L700-L702
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetStakeVersions
func (db *WiredDB) GetStakeVersions(blockHash string, count int32) (*dcrjson.GetStakeVersionsResult, error) { return db.client.GetStakeVersions(blockHash, count) }
go
func (db *WiredDB) GetStakeVersions(blockHash string, count int32) (*dcrjson.GetStakeVersionsResult, error) { return db.client.GetStakeVersions(blockHash, count) }
[ "func", "(", "db", "*", "WiredDB", ")", "GetStakeVersions", "(", "blockHash", "string", ",", "count", "int32", ")", "(", "*", "dcrjson", ".", "GetStakeVersionsResult", ",", "error", ")", "{", "return", "db", ".", "client", ".", "GetStakeVersions", "(", "bl...
// GetStakeVersions requests the output of the getstakeversions RPC, which gets // stake version information and individual vote version information starting at the // given block and for count-1 blocks prior.
[ "GetStakeVersions", "requests", "the", "output", "of", "the", "getstakeversions", "RPC", "which", "gets", "stake", "version", "information", "and", "individual", "vote", "version", "information", "starting", "at", "the", "given", "block", "and", "for", "count", "-...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L707-L709
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetBlockSummaryTimeRange
func (db *WiredDB) GetBlockSummaryTimeRange(min, max int64, limit int) []apitypes.BlockDataBasic { blockSummary, err := db.RetrieveBlockSummaryByTimeRange(min, max, limit) if err != nil { log.Errorf("Unable to retrieve block summary using time %d: %v", min, err) } return blockSummary }
go
func (db *WiredDB) GetBlockSummaryTimeRange(min, max int64, limit int) []apitypes.BlockDataBasic { blockSummary, err := db.RetrieveBlockSummaryByTimeRange(min, max, limit) if err != nil { log.Errorf("Unable to retrieve block summary using time %d: %v", min, err) } return blockSummary }
[ "func", "(", "db", "*", "WiredDB", ")", "GetBlockSummaryTimeRange", "(", "min", ",", "max", "int64", ",", "limit", "int", ")", "[", "]", "apitypes", ".", "BlockDataBasic", "{", "blockSummary", ",", "err", ":=", "db", ".", "RetrieveBlockSummaryByTimeRange", "...
// GetBlockSummaryTimeRange returns the blocks created within a specified time // range min, max time
[ "GetBlockSummaryTimeRange", "returns", "the", "blocks", "created", "within", "a", "specified", "time", "range", "min", "max", "time" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L930-L936
train
decred/dcrdata
db/dcrsqlite/apisource.go
RetreiveDifficulty
func (db *WiredDB) RetreiveDifficulty(timestamp int64) float64 { sdiff, err := db.RetrieveDiff(timestamp) if err != nil { log.Errorf("Unable to retrieve difficulty: %v", err) return -1 } return sdiff }
go
func (db *WiredDB) RetreiveDifficulty(timestamp int64) float64 { sdiff, err := db.RetrieveDiff(timestamp) if err != nil { log.Errorf("Unable to retrieve difficulty: %v", err) return -1 } return sdiff }
[ "func", "(", "db", "*", "WiredDB", ")", "RetreiveDifficulty", "(", "timestamp", "int64", ")", "float64", "{", "sdiff", ",", "err", ":=", "db", ".", "RetrieveDiff", "(", "timestamp", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", ...
// RetreiveDifficulty fetches the difficulty value in the last 24hrs or // immediately after 24hrs.
[ "RetreiveDifficulty", "fetches", "the", "difficulty", "value", "in", "the", "last", "24hrs", "or", "immediately", "after", "24hrs", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L985-L992
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetAddressTransactionsWithSkip
func (db *WiredDB) GetAddressTransactionsWithSkip(addr string, count, skip int) *apitypes.Address { address, err := dcrutil.DecodeAddress(addr) if err != nil { log.Infof("Invalid address %s: %v", addr, err) return nil } txs, err := db.client.SearchRawTransactionsVerbose(address, skip, count, false, true, nil) ...
go
func (db *WiredDB) GetAddressTransactionsWithSkip(addr string, count, skip int) *apitypes.Address { address, err := dcrutil.DecodeAddress(addr) if err != nil { log.Infof("Invalid address %s: %v", addr, err) return nil } txs, err := db.client.SearchRawTransactionsVerbose(address, skip, count, false, true, nil) ...
[ "func", "(", "db", "*", "WiredDB", ")", "GetAddressTransactionsWithSkip", "(", "addr", "string", ",", "count", ",", "skip", "int", ")", "*", "apitypes", ".", "Address", "{", "address", ",", "err", ":=", "dcrutil", ".", "DecodeAddress", "(", "addr", ")", ...
// GetAddressTransactionsWithSkip returns an apitypes.Address Object with at most the // last count transactions the address was in
[ "GetAddressTransactionsWithSkip", "returns", "an", "apitypes", ".", "Address", "Object", "with", "at", "most", "the", "last", "count", "transactions", "the", "address", "was", "in" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1040-L1073
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetAddressTransactions
func (db *WiredDB) GetAddressTransactions(addr string, count int) *apitypes.Address { return db.GetAddressTransactionsWithSkip(addr, count, 0) }
go
func (db *WiredDB) GetAddressTransactions(addr string, count int) *apitypes.Address { return db.GetAddressTransactionsWithSkip(addr, count, 0) }
[ "func", "(", "db", "*", "WiredDB", ")", "GetAddressTransactions", "(", "addr", "string", ",", "count", "int", ")", "*", "apitypes", ".", "Address", "{", "return", "db", ".", "GetAddressTransactionsWithSkip", "(", "addr", ",", "count", ",", "0", ")", "\n", ...
// GetAddressTransactions returns an apitypes.Address Object with at most the // last count transactions the address was in
[ "GetAddressTransactions", "returns", "an", "apitypes", ".", "Address", "Object", "with", "at", "most", "the", "last", "count", "transactions", "the", "address", "was", "in" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1077-L1079
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetAddressTransactionsRaw
func (db *WiredDB) GetAddressTransactionsRaw(addr string, count int) []*apitypes.AddressTxRaw { return db.GetAddressTransactionsRawWithSkip(addr, count, 0) }
go
func (db *WiredDB) GetAddressTransactionsRaw(addr string, count int) []*apitypes.AddressTxRaw { return db.GetAddressTransactionsRawWithSkip(addr, count, 0) }
[ "func", "(", "db", "*", "WiredDB", ")", "GetAddressTransactionsRaw", "(", "addr", "string", ",", "count", "int", ")", "[", "]", "*", "apitypes", ".", "AddressTxRaw", "{", "return", "db", ".", "GetAddressTransactionsRawWithSkip", "(", "addr", ",", "count", ",...
// GetAddressTransactionsRaw returns an array of apitypes.AddressTxRaw objects // representing the raw result of SearchRawTransactionsverbose
[ "GetAddressTransactionsRaw", "returns", "an", "array", "of", "apitypes", ".", "AddressTxRaw", "objects", "representing", "the", "raw", "result", "of", "SearchRawTransactionsverbose" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1083-L1085
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetExplorerBlocks
func (db *WiredDB) GetExplorerBlocks(start int, end int) []*exptypes.BlockBasic { if start < end { return nil } summaries := make([]*exptypes.BlockBasic, 0, start-end) for i := start; i > end; i-- { data := db.GetBlockVerbose(i, true) block := new(exptypes.BlockBasic) if data != nil { block = makeExplore...
go
func (db *WiredDB) GetExplorerBlocks(start int, end int) []*exptypes.BlockBasic { if start < end { return nil } summaries := make([]*exptypes.BlockBasic, 0, start-end) for i := start; i > end; i-- { data := db.GetBlockVerbose(i, true) block := new(exptypes.BlockBasic) if data != nil { block = makeExplore...
[ "func", "(", "db", "*", "WiredDB", ")", "GetExplorerBlocks", "(", "start", "int", ",", "end", "int", ")", "[", "]", "*", "exptypes", ".", "BlockBasic", "{", "if", "start", "<", "end", "{", "return", "nil", "\n", "}", "\n", "summaries", ":=", "make", ...
// GetExplorerBlocks creates an slice of exptypes.BlockBasic beginning at start // and decreasing in block height to end, not including end.
[ "GetExplorerBlocks", "creates", "an", "slice", "of", "exptypes", ".", "BlockBasic", "beginning", "at", "start", "and", "decreasing", "in", "block", "height", "to", "end", "not", "including", "end", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1245-L1259
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetMempool
func (db *WiredDB) GetMempool() []exptypes.MempoolTx { mempooltxs, err := db.client.GetRawMempoolVerbose(dcrjson.GRMAll) if err != nil { log.Errorf("GetRawMempoolVerbose failed: %v", err) return nil } txs := make([]exptypes.MempoolTx, 0, len(mempooltxs)) for hashStr, tx := range mempooltxs { hash, err := c...
go
func (db *WiredDB) GetMempool() []exptypes.MempoolTx { mempooltxs, err := db.client.GetRawMempoolVerbose(dcrjson.GRMAll) if err != nil { log.Errorf("GetRawMempoolVerbose failed: %v", err) return nil } txs := make([]exptypes.MempoolTx, 0, len(mempooltxs)) for hashStr, tx := range mempooltxs { hash, err := c...
[ "func", "(", "db", "*", "WiredDB", ")", "GetMempool", "(", ")", "[", "]", "exptypes", ".", "MempoolTx", "{", "mempooltxs", ",", "err", ":=", "db", ".", "client", ".", "GetRawMempoolVerbose", "(", "dcrjson", ".", "GRMAll", ")", "\n", "if", "err", "!=", ...
// GetMempool gets all transactions from the mempool for explorer and adds the // total out for all the txs and vote info for the votes. The returned slice // will be nil if the GetRawMempoolVerbose RPC fails. A zero-length non-nil // slice is returned if there are no transactions in mempool.
[ "GetMempool", "gets", "all", "transactions", "from", "the", "mempool", "for", "explorer", "and", "adds", "the", "total", "out", "for", "all", "the", "txs", "and", "vote", "info", "for", "the", "votes", ".", "The", "returned", "slice", "will", "be", "nil", ...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1706-L1766
train
decred/dcrdata
db/dcrsqlite/apisource.go
TxHeight
func (db *WiredDB) TxHeight(txid *chainhash.Hash) (height int64) { txraw, err := db.client.GetRawTransactionVerbose(txid) if err != nil { log.Errorf("GetRawTransactionVerbose failed for: %v", txid) return 0 } height = txraw.BlockHeight return }
go
func (db *WiredDB) TxHeight(txid *chainhash.Hash) (height int64) { txraw, err := db.client.GetRawTransactionVerbose(txid) if err != nil { log.Errorf("GetRawTransactionVerbose failed for: %v", txid) return 0 } height = txraw.BlockHeight return }
[ "func", "(", "db", "*", "WiredDB", ")", "TxHeight", "(", "txid", "*", "chainhash", ".", "Hash", ")", "(", "height", "int64", ")", "{", "txraw", ",", "err", ":=", "db", ".", "client", ".", "GetRawTransactionVerbose", "(", "txid", ")", "\n", "if", "err...
// TxHeight gives the block height of the transaction id specified
[ "TxHeight", "gives", "the", "block", "height", "of", "the", "transaction", "id", "specified" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1769-L1777
train
decred/dcrdata
db/dcrsqlite/apisource.go
Difficulty
func (db *WiredDB) Difficulty() (float64, error) { diff, err := db.client.GetDifficulty() if err != nil { log.Error("GetDifficulty failed") return diff, err } return diff, nil }
go
func (db *WiredDB) Difficulty() (float64, error) { diff, err := db.client.GetDifficulty() if err != nil { log.Error("GetDifficulty failed") return diff, err } return diff, nil }
[ "func", "(", "db", "*", "WiredDB", ")", "Difficulty", "(", ")", "(", "float64", ",", "error", ")", "{", "diff", ",", "err", ":=", "db", ".", "client", ".", "GetDifficulty", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Error", "(", ...
// Difficulty returns the difficulty.
[ "Difficulty", "returns", "the", "difficulty", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1780-L1787
train
decred/dcrdata
db/dcrsqlite/apisource.go
GetTip
func (db *WiredDB) GetTip() (*exptypes.WebBasicBlock, error) { tip, err := db.DB.getTip() if err != nil { return nil, err } blockdata := exptypes.WebBasicBlock{ Height: tip.Height, Size: tip.Size, Hash: tip.Hash, Difficulty: tip.Difficulty, StakeDiff: tip.StakeDiff, Time: ...
go
func (db *WiredDB) GetTip() (*exptypes.WebBasicBlock, error) { tip, err := db.DB.getTip() if err != nil { return nil, err } blockdata := exptypes.WebBasicBlock{ Height: tip.Height, Size: tip.Size, Hash: tip.Hash, Difficulty: tip.Difficulty, StakeDiff: tip.StakeDiff, Time: ...
[ "func", "(", "db", "*", "WiredDB", ")", "GetTip", "(", ")", "(", "*", "exptypes", ".", "WebBasicBlock", ",", "error", ")", "{", "tip", ",", "err", ":=", "db", ".", "DB", ".", "getTip", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "n...
// GetTip grabs the highest block stored in the database.
[ "GetTip", "grabs", "the", "highest", "block", "stored", "in", "the", "database", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/apisource.go#L1790-L1809
train
decred/dcrdata
api/types/apitypes.go
MarshalJSON
func (t *TimeAPI) MarshalJSON() ([]byte, error) { return json.Marshal(t.S.UNIX()) }
go
func (t *TimeAPI) MarshalJSON() ([]byte, error) { return json.Marshal(t.S.UNIX()) }
[ "func", "(", "t", "*", "TimeAPI", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "json", ".", "Marshal", "(", "t", ".", "S", ".", "UNIX", "(", ")", ")", "\n", "}" ]
// MarshalJSON is set as the default marshalling function for TimeAPI struct.
[ "MarshalJSON", "is", "set", "as", "the", "default", "marshalling", "function", "for", "TimeAPI", "struct", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L37-L39
train
decred/dcrdata
api/types/apitypes.go
NewTimeAPI
func NewTimeAPI(t time.Time) TimeAPI { return TimeAPI{ S: dbtypes.NewTimeDef(t), } }
go
func NewTimeAPI(t time.Time) TimeAPI { return TimeAPI{ S: dbtypes.NewTimeDef(t), } }
[ "func", "NewTimeAPI", "(", "t", "time", ".", "Time", ")", "TimeAPI", "{", "return", "TimeAPI", "{", "S", ":", "dbtypes", ".", "NewTimeDef", "(", "t", ")", ",", "}", "\n", "}" ]
// NewTimeAPI constructs a TimeAPI from the given time.Time. It presets the // timezone for formatting to UTC.
[ "NewTimeAPI", "constructs", "a", "TimeAPI", "from", "the", "given", "time", ".", "Time", ".", "It", "presets", "the", "timezone", "for", "formatting", "to", "UTC", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L56-L60
train
decred/dcrdata
api/types/apitypes.go
String
func (sc ScriptClass) String() string { name, found := scriptClassToName[sc] if !found { return ScriptClassInvalid.String() // better be in scriptClassToName! } return name }
go
func (sc ScriptClass) String() string { name, found := scriptClassToName[sc] if !found { return ScriptClassInvalid.String() // better be in scriptClassToName! } return name }
[ "func", "(", "sc", "ScriptClass", ")", "String", "(", ")", "string", "{", "name", ",", "found", ":=", "scriptClassToName", "[", "sc", "]", "\n", "if", "!", "found", "{", "return", "ScriptClassInvalid", ".", "String", "(", ")", "// better be in scriptClassToN...
// String returns the name of the ScriptClass. If the ScriptClass is // unrecognized it is treated as ScriptClassInvalid.
[ "String", "returns", "the", "name", "of", "the", "ScriptClass", ".", "If", "the", "ScriptClass", "is", "unrecognized", "it", "is", "treated", "as", "ScriptClassInvalid", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L265-L271
train
decred/dcrdata
api/types/apitypes.go
NewStatus
func NewStatus(nodeHeight uint32, conns int64, apiVersion int, dcrdataVersion, netName string) *Status { return &Status{ height: nodeHeight, nodeConnections: conns, api: APIStatus{ APIVersion: apiVersion, DcrdataVersion: dcrdataVersion, NetworkName: netName, }, } }
go
func NewStatus(nodeHeight uint32, conns int64, apiVersion int, dcrdataVersion, netName string) *Status { return &Status{ height: nodeHeight, nodeConnections: conns, api: APIStatus{ APIVersion: apiVersion, DcrdataVersion: dcrdataVersion, NetworkName: netName, }, } }
[ "func", "NewStatus", "(", "nodeHeight", "uint32", ",", "conns", "int64", ",", "apiVersion", "int", ",", "dcrdataVersion", ",", "netName", "string", ")", "*", "Status", "{", "return", "&", "Status", "{", "height", ":", "nodeHeight", ",", "nodeConnections", ":...
// NewStatus is the constructor for a new Status.
[ "NewStatus", "is", "the", "constructor", "for", "a", "new", "Status", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L435-L445
train
decred/dcrdata
api/types/apitypes.go
API
func (s *Status) API() APIStatus { s.RLock() defer s.RUnlock() return APIStatus{ Ready: s.ready, DBHeight: s.dbHeight, DBLastBlockTime: s.dbLastBlockTime, Height: s.height, NodeConnections: s.nodeConnections, APIVersion: s.api.APIVersion, DcrdataVersion: s.api.DcrdataVer...
go
func (s *Status) API() APIStatus { s.RLock() defer s.RUnlock() return APIStatus{ Ready: s.ready, DBHeight: s.dbHeight, DBLastBlockTime: s.dbLastBlockTime, Height: s.height, NodeConnections: s.nodeConnections, APIVersion: s.api.APIVersion, DcrdataVersion: s.api.DcrdataVer...
[ "func", "(", "s", "*", "Status", ")", "API", "(", ")", "APIStatus", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n", "return", "APIStatus", "{", "Ready", ":", "s", ".", "ready", ",", "DBHeight", ":", "s", "....
// API is a method for creating an APIStatus from Status.
[ "API", "is", "a", "method", "for", "creating", "an", "APIStatus", "from", "Status", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L448-L461
train
decred/dcrdata
api/types/apitypes.go
Height
func (s *Status) Height() uint32 { s.RLock() defer s.RUnlock() return s.height }
go
func (s *Status) Height() uint32 { s.RLock() defer s.RUnlock() return s.height }
[ "func", "(", "s", "*", "Status", ")", "Height", "(", ")", "uint32", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "height", "\n", "}" ]
// Height is the last known node height.
[ "Height", "is", "the", "last", "known", "node", "height", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L464-L468
train
decred/dcrdata
api/types/apitypes.go
SetHeight
func (s *Status) SetHeight(height uint32) { s.Lock() defer s.Unlock() s.ready = height == s.dbHeight s.height = height }
go
func (s *Status) SetHeight(height uint32) { s.Lock() defer s.Unlock() s.ready = height == s.dbHeight s.height = height }
[ "func", "(", "s", "*", "Status", ")", "SetHeight", "(", "height", "uint32", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "s", ".", "ready", "=", "height", "==", "s", ".", "dbHeight", "\n", "s", ".", ...
// SetHeight stores the node height. Additionally, Status.ready is set to true // if Status.height is the same as Status.dbHeight.
[ "SetHeight", "stores", "the", "node", "height", ".", "Additionally", "Status", ".", "ready", "is", "set", "to", "true", "if", "Status", ".", "height", "is", "the", "same", "as", "Status", ".", "dbHeight", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L472-L477
train
decred/dcrdata
api/types/apitypes.go
SetHeightAndConnections
func (s *Status) SetHeightAndConnections(height uint32, conns int64) { s.Lock() defer s.Unlock() s.nodeConnections = conns s.ready = height == s.dbHeight s.height = height }
go
func (s *Status) SetHeightAndConnections(height uint32, conns int64) { s.Lock() defer s.Unlock() s.nodeConnections = conns s.ready = height == s.dbHeight s.height = height }
[ "func", "(", "s", "*", "Status", ")", "SetHeightAndConnections", "(", "height", "uint32", ",", "conns", "int64", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "s", ".", "nodeConnections", "=", "conns", "\n",...
// SetHeightAndConnections simultaneously sets the node height and node // connection count. Status.ready is set to true if the height and dbHeight are // the same.
[ "SetHeightAndConnections", "simultaneously", "sets", "the", "node", "height", "and", "node", "connection", "count", ".", "Status", ".", "ready", "is", "set", "to", "true", "if", "the", "height", "and", "dbHeight", "are", "the", "same", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L482-L488
train
decred/dcrdata
api/types/apitypes.go
SetReady
func (s *Status) SetReady(ready bool) { s.Lock() defer s.Unlock() s.ready = ready }
go
func (s *Status) SetReady(ready bool) { s.Lock() defer s.Unlock() s.ready = ready }
[ "func", "(", "s", "*", "Status", ")", "SetReady", "(", "ready", "bool", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "s", ".", "ready", "=", "ready", "\n", "}" ]
// SetReady sets the ready state.
[ "SetReady", "sets", "the", "ready", "state", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L491-L495
train
decred/dcrdata
api/types/apitypes.go
DBUpdate
func (s *Status) DBUpdate(height uint32, blockTime int64) { s.Lock() defer s.Unlock() s.dbHeight = height s.dbLastBlockTime = blockTime s.ready = s.dbHeight == height }
go
func (s *Status) DBUpdate(height uint32, blockTime int64) { s.Lock() defer s.Unlock() s.dbHeight = height s.dbLastBlockTime = blockTime s.ready = s.dbHeight == height }
[ "func", "(", "s", "*", "Status", ")", "DBUpdate", "(", "height", "uint32", ",", "blockTime", "int64", ")", "{", "s", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "Unlock", "(", ")", "\n", "s", ".", "dbHeight", "=", "height", "\n", "s", ".", ...
// DBUpdate updates both the height and time of the best DB block. Status.ready // is set to true if Status.height is the same as Status.dbHeight.
[ "DBUpdate", "updates", "both", "the", "height", "and", "time", "of", "the", "best", "DB", "block", ".", "Status", ".", "ready", "is", "set", "to", "true", "if", "Status", ".", "height", "is", "the", "same", "as", "Status", ".", "dbHeight", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/types/apitypes.go#L499-L505
train
decred/dcrdata
db/dcrpg/upgrades.go
String
func (v DatabaseVersion) String() string { return fmt.Sprintf("%d.%d.%d", v.compat, v.schema, v.maint) }
go
func (v DatabaseVersion) String() string { return fmt.Sprintf("%d.%d.%d", v.compat, v.schema, v.maint) }
[ "func", "(", "v", "DatabaseVersion", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ".", "compat", ",", "v", ".", "schema", ",", "v", ".", "maint", ")", "\n", "}" ]
// String implements Stringer for DatabaseVersion.
[ "String", "implements", "Stringer", "for", "DatabaseVersion", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades.go#L52-L54
train
decred/dcrdata
db/dcrpg/upgrades.go
NewDatabaseVersion
func NewDatabaseVersion(major, minor, patch uint32) DatabaseVersion { return DatabaseVersion{major, minor, patch} }
go
func NewDatabaseVersion(major, minor, patch uint32) DatabaseVersion { return DatabaseVersion{major, minor, patch} }
[ "func", "NewDatabaseVersion", "(", "major", ",", "minor", ",", "patch", "uint32", ")", "DatabaseVersion", "{", "return", "DatabaseVersion", "{", "major", ",", "minor", ",", "patch", "}", "\n", "}" ]
// NewDatabaseVersion returns a new DatabaseVersion with the version major.minor.patch
[ "NewDatabaseVersion", "returns", "a", "new", "DatabaseVersion", "with", "the", "version", "major", ".", "minor", ".", "patch" ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades.go#L57-L59
train
decred/dcrdata
db/dcrpg/upgrades.go
NeededToReach
func (v *DatabaseVersion) NeededToReach(other *DatabaseVersion) CompatAction { switch { case v.compat < other.compat: return Rebuild case v.compat < other.compat: return TimeTravel case v.schema < other.schema: return Upgrade case v.schema > other.schema: return TimeTravel case v.maint < other.maint: re...
go
func (v *DatabaseVersion) NeededToReach(other *DatabaseVersion) CompatAction { switch { case v.compat < other.compat: return Rebuild case v.compat < other.compat: return TimeTravel case v.schema < other.schema: return Upgrade case v.schema > other.schema: return TimeTravel case v.maint < other.maint: re...
[ "func", "(", "v", "*", "DatabaseVersion", ")", "NeededToReach", "(", "other", "*", "DatabaseVersion", ")", "CompatAction", "{", "switch", "{", "case", "v", ".", "compat", "<", "other", ".", "compat", ":", "return", "Rebuild", "\n", "case", "v", ".", "com...
// NeededToReach describes what action is required for the DatabaseVersion to // reach another version provided in the input argument.
[ "NeededToReach", "describes", "what", "action", "is", "required", "for", "the", "DatabaseVersion", "to", "reach", "another", "version", "provided", "in", "the", "input", "argument", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades.go#L83-L100
train
decred/dcrdata
db/dcrpg/upgrades.go
String
func (v CompatAction) String() string { actions := map[CompatAction]string{ Rebuild: "rebuild", Upgrade: "upgrade", Maintenance: "maintenance", TimeTravel: "time travel", OK: "ok", } if actionStr, ok := actions[v]; ok { return actionStr } return "unknown" }
go
func (v CompatAction) String() string { actions := map[CompatAction]string{ Rebuild: "rebuild", Upgrade: "upgrade", Maintenance: "maintenance", TimeTravel: "time travel", OK: "ok", } if actionStr, ok := actions[v]; ok { return actionStr } return "unknown" }
[ "func", "(", "v", "CompatAction", ")", "String", "(", ")", "string", "{", "actions", ":=", "map", "[", "CompatAction", "]", "string", "{", "Rebuild", ":", "\"", "\"", ",", "Upgrade", ":", "\"", "\"", ",", "Maintenance", ":", "\"", "\"", ",", "TimeTra...
// String implements Stringer for CompatAction.
[ "String", "implements", "Stringer", "for", "CompatAction", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/upgrades.go#L103-L115
train
decred/dcrdata
dcrrates/rateserver/types.go
NewRateServer
func NewRateServer(index string, xcBot *exchanges.ExchangeBot) *RateServer { return &RateServer{ btcIndex: index, clientLock: new(sync.RWMutex), clients: make(map[StreamID]RateClient), xcBot: xcBot, } }
go
func NewRateServer(index string, xcBot *exchanges.ExchangeBot) *RateServer { return &RateServer{ btcIndex: index, clientLock: new(sync.RWMutex), clients: make(map[StreamID]RateClient), xcBot: xcBot, } }
[ "func", "NewRateServer", "(", "index", "string", ",", "xcBot", "*", "exchanges", ".", "ExchangeBot", ")", "*", "RateServer", "{", "return", "&", "RateServer", "{", "btcIndex", ":", "index", ",", "clientLock", ":", "new", "(", "sync", ".", "RWMutex", ")", ...
// NewRateServer is a constructor for a RateServer.
[ "NewRateServer", "is", "a", "constructor", "for", "a", "RateServer", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L37-L44
train
decred/dcrdata
dcrrates/rateserver/types.go
sendStateList
func sendStateList(client RateClient, states map[string]*exchanges.ExchangeState) (err error) { for token, state := range states { err = client.SendExchangeUpdate(makeExchangeRateUpdate(&exchanges.ExchangeUpdate{ Token: token, State: state, })) if err != nil { log.Errorf("SendExchangeUpdate error for %s...
go
func sendStateList(client RateClient, states map[string]*exchanges.ExchangeState) (err error) { for token, state := range states { err = client.SendExchangeUpdate(makeExchangeRateUpdate(&exchanges.ExchangeUpdate{ Token: token, State: state, })) if err != nil { log.Errorf("SendExchangeUpdate error for %s...
[ "func", "sendStateList", "(", "client", "RateClient", ",", "states", "map", "[", "string", "]", "*", "exchanges", ".", "ExchangeState", ")", "(", "err", "error", ")", "{", "for", "token", ",", "state", ":=", "range", "states", "{", "err", "=", "client", ...
// sendStateList is a helper for parsing the ExchangeBotState when a new client // subscription is received.
[ "sendStateList", "is", "a", "helper", "for", "parsing", "the", "ExchangeBotState", "when", "a", "new", "client", "subscription", "is", "received", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L54-L66
train
decred/dcrdata
dcrrates/rateserver/types.go
ReallySubscribeExchanges
func (server *RateServer) ReallySubscribeExchanges(hello *dcrrates.ExchangeSubscription, stream GRPCStream) (err error) { // For now, require the ExchangeBot clients to have the same base currency. // ToDo: Allow any index. if hello.BtcIndex != server.btcIndex { return fmt.Errorf("Exchange subscription has wrong B...
go
func (server *RateServer) ReallySubscribeExchanges(hello *dcrrates.ExchangeSubscription, stream GRPCStream) (err error) { // For now, require the ExchangeBot clients to have the same base currency. // ToDo: Allow any index. if hello.BtcIndex != server.btcIndex { return fmt.Errorf("Exchange subscription has wrong B...
[ "func", "(", "server", "*", "RateServer", ")", "ReallySubscribeExchanges", "(", "hello", "*", "dcrrates", ".", "ExchangeSubscription", ",", "stream", "GRPCStream", ")", "(", "err", "error", ")", "{", "// For now, require the ExchangeBot clients to have the same base curre...
// ReallySubscribeExchanges stores the client and their exchange subscriptions. // It waits for the client contexts Done channel to close and deletes the client // from the RateServer.clients map.
[ "ReallySubscribeExchanges", "stores", "the", "client", "and", "their", "exchange", "subscriptions", ".", "It", "waits", "for", "the", "client", "contexts", "Done", "channel", "to", "close", "and", "deletes", "the", "client", "from", "the", "RateServer", ".", "cl...
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L78-L122
train
decred/dcrdata
dcrrates/rateserver/types.go
addClient
func (server *RateServer) addClient(stream GRPCStream, hello *dcrrates.ExchangeSubscription) (RateClient, StreamID) { server.clientLock.Lock() defer server.clientLock.Unlock() client := NewRateClient(stream, hello.GetExchanges()) streamCounter++ server.clients[streamCounter] = client return client, streamCounter ...
go
func (server *RateServer) addClient(stream GRPCStream, hello *dcrrates.ExchangeSubscription) (RateClient, StreamID) { server.clientLock.Lock() defer server.clientLock.Unlock() client := NewRateClient(stream, hello.GetExchanges()) streamCounter++ server.clients[streamCounter] = client return client, streamCounter ...
[ "func", "(", "server", "*", "RateServer", ")", "addClient", "(", "stream", "GRPCStream", ",", "hello", "*", "dcrrates", ".", "ExchangeSubscription", ")", "(", "RateClient", ",", "StreamID", ")", "{", "server", ".", "clientLock", ".", "Lock", "(", ")", "\n"...
// addClient adds a client to the map and advance the streamCounter.
[ "addClient", "adds", "a", "client", "to", "the", "map", "and", "advance", "the", "streamCounter", "." ]
02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6
https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/dcrrates/rateserver/types.go#L125-L132
train