id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
142,300 | decred/dcrdata | stakedb/ticketpool.go | Cursor | func (tp *TicketPool) Cursor() int64 {
tp.mtx.RLock()
defer tp.mtx.RUnlock()
return tp.cursor
} | go | func (tp *TicketPool) Cursor() int64 {
tp.mtx.RLock()
defer tp.mtx.RUnlock()
return tp.cursor
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"Cursor",
"(",
")",
"int64",
"{",
"tp",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"tp",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"tp",
".",
"cursor",
"\n",
"}"
] | // Cursor returns the current cursor, the location of the next unapplied diff. | [
"Cursor",
"returns",
"the",
"current",
"cursor",
"the",
"location",
"of",
"the",
"next",
"unapplied",
"diff",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L342-L346 |
142,301 | decred/dcrdata | stakedb/ticketpool.go | append | func (tp *TicketPool) append(diff *PoolDiff) {
tp.tip++
tp.diffs = append(tp.diffs, *diff)
} | go | func (tp *TicketPool) append(diff *PoolDiff) {
tp.tip++
tp.diffs = append(tp.diffs, *diff)
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"append",
"(",
"diff",
"*",
"PoolDiff",
")",
"{",
"tp",
".",
"tip",
"++",
"\n",
"tp",
".",
"diffs",
"=",
"append",
"(",
"tp",
".",
"diffs",
",",
"*",
"diff",
")",
"\n",
"}"
] | // append grows the diffs slice and advances the tip height. | [
"append",
"grows",
"the",
"diffs",
"slice",
"and",
"advances",
"the",
"tip",
"height",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L349-L352 |
142,302 | decred/dcrdata | stakedb/ticketpool.go | trim | func (tp *TicketPool) trim() (int64, PoolDiff) {
if tp.tip == 0 || len(tp.diffs) == 0 {
return tp.tip, PoolDiff{}
}
tp.tip--
newMaxCursor := tp.maxCursor()
if tp.cursor > newMaxCursor {
if err := tp.retreatTo(newMaxCursor); err != nil {
log.Errorf("retreatTo failed: %v", err)
}
}
// Trim AFTER retreatin... | go | func (tp *TicketPool) trim() (int64, PoolDiff) {
if tp.tip == 0 || len(tp.diffs) == 0 {
return tp.tip, PoolDiff{}
}
tp.tip--
newMaxCursor := tp.maxCursor()
if tp.cursor > newMaxCursor {
if err := tp.retreatTo(newMaxCursor); err != nil {
log.Errorf("retreatTo failed: %v", err)
}
}
// Trim AFTER retreatin... | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"trim",
"(",
")",
"(",
"int64",
",",
"PoolDiff",
")",
"{",
"if",
"tp",
".",
"tip",
"==",
"0",
"||",
"len",
"(",
"tp",
".",
"diffs",
")",
"==",
"0",
"{",
"return",
"tp",
".",
"tip",
",",
"PoolDiff",
"... | // trim is the non-thread-safe version of Trim. | [
"trim",
"is",
"the",
"non",
"-",
"thread",
"-",
"safe",
"version",
"of",
"Trim",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L355-L370 |
142,303 | decred/dcrdata | stakedb/ticketpool.go | Trim | func (tp *TicketPool) Trim() (int64, PoolDiff) {
tp.mtx.Lock()
defer tp.mtx.Unlock()
return tp.trim()
} | go | func (tp *TicketPool) Trim() (int64, PoolDiff) {
tp.mtx.Lock()
defer tp.mtx.Unlock()
return tp.trim()
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"Trim",
"(",
")",
"(",
"int64",
",",
"PoolDiff",
")",
"{",
"tp",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tp",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"return",
"tp",
".",
"trim",
"(",
"... | // Trim removes the end diff and decrements the tip height. If the cursor would
// fall beyond the end of the diffs, the removed diffs are applied in reverse. | [
"Trim",
"removes",
"the",
"end",
"diff",
"and",
"decrements",
"the",
"tip",
"height",
".",
"If",
"the",
"cursor",
"would",
"fall",
"beyond",
"the",
"end",
"of",
"the",
"diffs",
"the",
"removed",
"diffs",
"are",
"applied",
"in",
"reverse",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L374-L378 |
142,304 | decred/dcrdata | stakedb/ticketpool.go | storeDiff | func storeDiff(db *badger.DB, diff *PoolDiff, height int64) error {
var heightBytes [8]byte
binary.BigEndian.PutUint64(heightBytes[:], uint64(height))
var poolDiffBuffer bytes.Buffer
if err := gob.NewEncoder(&poolDiffBuffer).Encode(diff); err != nil {
return err
}
return db.Update(func(txn *badger.Txn) error ... | go | func storeDiff(db *badger.DB, diff *PoolDiff, height int64) error {
var heightBytes [8]byte
binary.BigEndian.PutUint64(heightBytes[:], uint64(height))
var poolDiffBuffer bytes.Buffer
if err := gob.NewEncoder(&poolDiffBuffer).Encode(diff); err != nil {
return err
}
return db.Update(func(txn *badger.Txn) error ... | [
"func",
"storeDiff",
"(",
"db",
"*",
"badger",
".",
"DB",
",",
"diff",
"*",
"PoolDiff",
",",
"height",
"int64",
")",
"error",
"{",
"var",
"heightBytes",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint64",
"(",
"heightBytes",
"[",... | // storeDiff stores the input diff for the specified height in the on-disk DB. | [
"storeDiff",
"stores",
"the",
"input",
"diff",
"for",
"the",
"specified",
"height",
"in",
"the",
"on",
"-",
"disk",
"DB",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L381-L393 |
142,305 | decred/dcrdata | stakedb/ticketpool.go | storeDiffs | func storeDiffs(db *badger.DB, diffs []*PoolDiff, heights []int64) error {
heightToBytes := func(height int64) (heightBytes [8]byte) {
binary.BigEndian.PutUint64(heightBytes[:], uint64(height))
return
}
poolDiffBuffer := new(bytes.Buffer)
txn := db.NewTransaction(true)
for i, h := range heights {
heightByte... | go | func storeDiffs(db *badger.DB, diffs []*PoolDiff, heights []int64) error {
heightToBytes := func(height int64) (heightBytes [8]byte) {
binary.BigEndian.PutUint64(heightBytes[:], uint64(height))
return
}
poolDiffBuffer := new(bytes.Buffer)
txn := db.NewTransaction(true)
for i, h := range heights {
heightByte... | [
"func",
"storeDiffs",
"(",
"db",
"*",
"badger",
".",
"DB",
",",
"diffs",
"[",
"]",
"*",
"PoolDiff",
",",
"heights",
"[",
"]",
"int64",
")",
"error",
"{",
"heightToBytes",
":=",
"func",
"(",
"height",
"int64",
")",
"(",
"heightBytes",
"[",
"8",
"]",
... | // storeDiffs stores the input diffs for the specified heights in the on-disk DB. | [
"storeDiffs",
"stores",
"the",
"input",
"diffs",
"for",
"the",
"specified",
"heights",
"in",
"the",
"on",
"-",
"disk",
"DB",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L396-L432 |
142,306 | decred/dcrdata | stakedb/ticketpool.go | fetchDiff | func (tp *TicketPool) fetchDiff(height int64) (*PoolDiffDBItem, error) {
var heightBytes [8]byte
binary.BigEndian.PutUint64(heightBytes[:], uint64(height))
var diff *PoolDiffDBItem
err := tp.diffDB.View(func(txn *badger.Txn) error {
item, errTx := txn.Get(heightBytes[:])
if errTx != nil {
return fmt.Errorf(... | go | func (tp *TicketPool) fetchDiff(height int64) (*PoolDiffDBItem, error) {
var heightBytes [8]byte
binary.BigEndian.PutUint64(heightBytes[:], uint64(height))
var diff *PoolDiffDBItem
err := tp.diffDB.View(func(txn *badger.Txn) error {
item, errTx := txn.Get(heightBytes[:])
if errTx != nil {
return fmt.Errorf(... | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"fetchDiff",
"(",
"height",
"int64",
")",
"(",
"*",
"PoolDiffDBItem",
",",
"error",
")",
"{",
"var",
"heightBytes",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint64",
"(",
"heightBytes",
... | // fetchDiff retrieves the diff at the specified height from the on-disk DB. | [
"fetchDiff",
"retrieves",
"the",
"diff",
"at",
"the",
"specified",
"height",
"from",
"the",
"on",
"-",
"disk",
"DB",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L439-L477 |
142,307 | decred/dcrdata | stakedb/ticketpool.go | Append | func (tp *TicketPool) Append(diff *PoolDiff, height int64) error {
if height != tp.tip+1 {
return fmt.Errorf("block height %d does not build on %d", height, tp.tip)
}
tp.mtx.Lock()
defer tp.mtx.Unlock()
tp.append(diff)
return tp.storeDiff(diff, height)
} | go | func (tp *TicketPool) Append(diff *PoolDiff, height int64) error {
if height != tp.tip+1 {
return fmt.Errorf("block height %d does not build on %d", height, tp.tip)
}
tp.mtx.Lock()
defer tp.mtx.Unlock()
tp.append(diff)
return tp.storeDiff(diff, height)
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"Append",
"(",
"diff",
"*",
"PoolDiff",
",",
"height",
"int64",
")",
"error",
"{",
"if",
"height",
"!=",
"tp",
".",
"tip",
"+",
"1",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"height",
"... | // Append grows the diffs slice with the specified diff, and stores it in the
// on-disk DB. The height of the diff is used to check that it builds on the
// chain tip, and as a primary key in the DB. | [
"Append",
"grows",
"the",
"diffs",
"slice",
"with",
"the",
"specified",
"diff",
"and",
"stores",
"it",
"in",
"the",
"on",
"-",
"disk",
"DB",
".",
"The",
"height",
"of",
"the",
"diff",
"is",
"used",
"to",
"check",
"that",
"it",
"builds",
"on",
"the",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L482-L490 |
142,308 | decred/dcrdata | stakedb/ticketpool.go | AppendAndAdvancePool | func (tp *TicketPool) AppendAndAdvancePool(diff *PoolDiff, height int64) error {
if height != tp.tip+1 {
return fmt.Errorf("block height %d does not build on %d", height, tp.tip)
}
tp.mtx.Lock()
defer tp.mtx.Unlock()
tp.append(diff)
if err := tp.storeDiff(diff, height); err != nil {
return err
}
return tp.a... | go | func (tp *TicketPool) AppendAndAdvancePool(diff *PoolDiff, height int64) error {
if height != tp.tip+1 {
return fmt.Errorf("block height %d does not build on %d", height, tp.tip)
}
tp.mtx.Lock()
defer tp.mtx.Unlock()
tp.append(diff)
if err := tp.storeDiff(diff, height); err != nil {
return err
}
return tp.a... | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"AppendAndAdvancePool",
"(",
"diff",
"*",
"PoolDiff",
",",
"height",
"int64",
")",
"error",
"{",
"if",
"height",
"!=",
"tp",
".",
"tip",
"+",
"1",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
... | // AppendAndAdvancePool functions like Append, except that after growing the
// diffs slice and storing the diff in DB, the ticket pool is advanced. | [
"AppendAndAdvancePool",
"functions",
"like",
"Append",
"except",
"that",
"after",
"growing",
"the",
"diffs",
"slice",
"and",
"storing",
"the",
"diff",
"in",
"DB",
"the",
"ticket",
"pool",
"is",
"advanced",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L494-L505 |
142,309 | decred/dcrdata | stakedb/ticketpool.go | currentPool | func (tp *TicketPool) currentPool() ([]chainhash.Hash, int64) {
poolSize := len(tp.pool)
// allocate space for all the ticket hashes, but use append to avoid the
// slice initialization having to zero initialize all of the arrays.
pool := make([]chainhash.Hash, 0, poolSize)
for h := range tp.pool {
pool = append... | go | func (tp *TicketPool) currentPool() ([]chainhash.Hash, int64) {
poolSize := len(tp.pool)
// allocate space for all the ticket hashes, but use append to avoid the
// slice initialization having to zero initialize all of the arrays.
pool := make([]chainhash.Hash, 0, poolSize)
for h := range tp.pool {
pool = append... | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"currentPool",
"(",
")",
"(",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"int64",
")",
"{",
"poolSize",
":=",
"len",
"(",
"tp",
".",
"pool",
")",
"\n",
"// allocate space for all the ticket hashes, but use append to avo... | // currentPool is the non-thread-safe version of CurrentPool. | [
"currentPool",
"is",
"the",
"non",
"-",
"thread",
"-",
"safe",
"version",
"of",
"CurrentPool",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L508-L517 |
142,310 | decred/dcrdata | stakedb/ticketpool.go | CurrentPoolSize | func (tp *TicketPool) CurrentPoolSize() int {
tp.mtx.RLock()
defer tp.mtx.RUnlock()
return len(tp.pool)
} | go | func (tp *TicketPool) CurrentPoolSize() int {
tp.mtx.RLock()
defer tp.mtx.RUnlock()
return len(tp.pool)
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"CurrentPoolSize",
"(",
")",
"int",
"{",
"tp",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"tp",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"len",
"(",
"tp",
".",
"pool",
")",
"\n",
"... | // CurrentPoolSize returns the number of tickets stored in the current pool map. | [
"CurrentPoolSize",
"returns",
"the",
"number",
"of",
"tickets",
"stored",
"in",
"the",
"current",
"pool",
"map",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L530-L534 |
142,311 | decred/dcrdata | stakedb/ticketpool.go | advance | func (tp *TicketPool) advance() error {
if tp.cursor > tp.maxCursor() {
return fmt.Errorf("cursor at tip, unable to advance")
}
diffToNext := tp.diffs[tp.cursor]
initPoolSize := len(tp.pool)
expectedFinalSize := initPoolSize + len(diffToNext.In) - len(diffToNext.Out)
tp.applyDiff(diffToNext.In, diffToNext.Out... | go | func (tp *TicketPool) advance() error {
if tp.cursor > tp.maxCursor() {
return fmt.Errorf("cursor at tip, unable to advance")
}
diffToNext := tp.diffs[tp.cursor]
initPoolSize := len(tp.pool)
expectedFinalSize := initPoolSize + len(diffToNext.In) - len(diffToNext.Out)
tp.applyDiff(diffToNext.In, diffToNext.Out... | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"advance",
"(",
")",
"error",
"{",
"if",
"tp",
".",
"cursor",
">",
"tp",
".",
"maxCursor",
"(",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"diffToNext",
":=",
"tp"... | // advance applies the pool diff at the current cursor location, and advances
// the cursor. Note that when advancing at the last diff, the resulting cursor
// will be beyond the last element in the diffs slice. | [
"advance",
"applies",
"the",
"pool",
"diff",
"at",
"the",
"current",
"cursor",
"location",
"and",
"advances",
"the",
"cursor",
".",
"Note",
"that",
"when",
"advancing",
"at",
"the",
"last",
"diff",
"the",
"resulting",
"cursor",
"will",
"be",
"beyond",
"the",... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L564-L582 |
142,312 | decred/dcrdata | stakedb/ticketpool.go | advanceTo | func (tp *TicketPool) advanceTo(height int64) error {
if height > tp.tip {
return fmt.Errorf("cannot advance past tip")
}
for height > tp.cursor {
if err := tp.advance(); err != nil {
return err
}
}
return nil
} | go | func (tp *TicketPool) advanceTo(height int64) error {
if height > tp.tip {
return fmt.Errorf("cannot advance past tip")
}
for height > tp.cursor {
if err := tp.advance(); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"advanceTo",
"(",
"height",
"int64",
")",
"error",
"{",
"if",
"height",
">",
"tp",
".",
"tip",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"for",
"height",
">",
"tp",
".",... | // advanceTo successively applies pool diffs with advance until the cursor
// reaches the desired height. Note that this function will return without error
// if the initial cursor is at or beyond the specified height. | [
"advanceTo",
"successively",
"applies",
"pool",
"diffs",
"with",
"advance",
"until",
"the",
"cursor",
"reaches",
"the",
"desired",
"height",
".",
"Note",
"that",
"this",
"function",
"will",
"return",
"without",
"error",
"if",
"the",
"initial",
"cursor",
"is",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L587-L597 |
142,313 | decred/dcrdata | stakedb/ticketpool.go | AdvanceToTip | func (tp *TicketPool) AdvanceToTip() (int64, error) {
tp.mtx.Lock()
defer tp.mtx.Unlock()
err := tp.advanceTo(tp.tip)
return tp.cursor - 1, err
} | go | func (tp *TicketPool) AdvanceToTip() (int64, error) {
tp.mtx.Lock()
defer tp.mtx.Unlock()
err := tp.advanceTo(tp.tip)
return tp.cursor - 1, err
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"AdvanceToTip",
"(",
")",
"(",
"int64",
",",
"error",
")",
"{",
"tp",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tp",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"err",
":=",
"tp",
".",
"advance... | // AdvanceToTip advances the pool map by applying all stored diffs. Note that
// the cursor will stop just beyond the last element of the diffs slice. It will
// not be possible to advance further, only retreat. | [
"AdvanceToTip",
"advances",
"the",
"pool",
"map",
"by",
"applying",
"all",
"stored",
"diffs",
".",
"Note",
"that",
"the",
"cursor",
"will",
"stop",
"just",
"beyond",
"the",
"last",
"element",
"of",
"the",
"diffs",
"slice",
".",
"It",
"will",
"not",
"be",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L602-L607 |
142,314 | decred/dcrdata | stakedb/ticketpool.go | retreat | func (tp *TicketPool) retreat() error {
if tp.cursor == 0 {
return fmt.Errorf("cursor at genesis, unable to retreat")
}
diffFromPrev := tp.diffs[tp.cursor-1]
initPoolSize := len(tp.pool)
expectedFinalSize := initPoolSize - len(diffFromPrev.In) + len(diffFromPrev.Out)
tp.applyDiff(diffFromPrev.Out, diffFromPre... | go | func (tp *TicketPool) retreat() error {
if tp.cursor == 0 {
return fmt.Errorf("cursor at genesis, unable to retreat")
}
diffFromPrev := tp.diffs[tp.cursor-1]
initPoolSize := len(tp.pool)
expectedFinalSize := initPoolSize - len(diffFromPrev.In) + len(diffFromPrev.Out)
tp.applyDiff(diffFromPrev.Out, diffFromPre... | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"retreat",
"(",
")",
"error",
"{",
"if",
"tp",
".",
"cursor",
"==",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"diffFromPrev",
":=",
"tp",
".",
"diffs",
"[",
"tp",... | // retreat applies the previous diff in reverse, moving the pool map to the
// state before that diff was applied. The cursor is decremented, and may go to
// 0 but not beyond as the cursor is the location of the next unapplied diff. | [
"retreat",
"applies",
"the",
"previous",
"diff",
"in",
"reverse",
"moving",
"the",
"pool",
"map",
"to",
"the",
"state",
"before",
"that",
"diff",
"was",
"applied",
".",
"The",
"cursor",
"is",
"decremented",
"and",
"may",
"go",
"to",
"0",
"but",
"not",
"b... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L612-L628 |
142,315 | decred/dcrdata | stakedb/ticketpool.go | retreatTo | func (tp *TicketPool) retreatTo(height int64) error {
if height < 0 || height > tp.tip {
return fmt.Errorf("Invalid destination cursor %d", height)
}
for tp.cursor > height {
if err := tp.retreat(); err != nil {
return err
}
}
return nil
} | go | func (tp *TicketPool) retreatTo(height int64) error {
if height < 0 || height > tp.tip {
return fmt.Errorf("Invalid destination cursor %d", height)
}
for tp.cursor > height {
if err := tp.retreat(); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"retreatTo",
"(",
"height",
"int64",
")",
"error",
"{",
"if",
"height",
"<",
"0",
"||",
"height",
">",
"tp",
".",
"tip",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"height",
")",
"\n",
"}... | // retreatTo successively applies pool diffs in reverse with retreate until the
// cursor reaches the desired height. Note that this function will return
// without error if the initial cursor is at or below the specified height. | [
"retreatTo",
"successively",
"applies",
"pool",
"diffs",
"in",
"reverse",
"with",
"retreate",
"until",
"the",
"cursor",
"reaches",
"the",
"desired",
"height",
".",
"Note",
"that",
"this",
"function",
"will",
"return",
"without",
"error",
"if",
"the",
"initial",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L642-L652 |
142,316 | decred/dcrdata | stakedb/ticketpool.go | applyDiff | func (tp *TicketPool) applyDiff(in, out []chainhash.Hash) {
initsize := len(tp.pool)
for i := range in {
tp.pool[in[i]] = struct{}{}
}
endsize := len(tp.pool)
if endsize != initsize+len(in) {
log.Warnf("pool grew by %d instead of %d", endsize-initsize, len(in))
}
initsize = endsize
for i := range out {
ii... | go | func (tp *TicketPool) applyDiff(in, out []chainhash.Hash) {
initsize := len(tp.pool)
for i := range in {
tp.pool[in[i]] = struct{}{}
}
endsize := len(tp.pool)
if endsize != initsize+len(in) {
log.Warnf("pool grew by %d instead of %d", endsize-initsize, len(in))
}
initsize = endsize
for i := range out {
ii... | [
"func",
"(",
"tp",
"*",
"TicketPool",
")",
"applyDiff",
"(",
"in",
",",
"out",
"[",
"]",
"chainhash",
".",
"Hash",
")",
"{",
"initsize",
":=",
"len",
"(",
"tp",
".",
"pool",
")",
"\n",
"for",
"i",
":=",
"range",
"in",
"{",
"tp",
".",
"pool",
"[... | // applyDiff adds and removes tickets from the pool map. | [
"applyDiff",
"adds",
"and",
"removes",
"tickets",
"from",
"the",
"pool",
"map",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/stakedb/ticketpool.go#L655-L676 |
142,317 | decred/dcrdata | mempool/mempoolcache.go | GetHeight | func (c *MempoolDataCache) GetHeight() uint32 {
c.mtx.RLock()
defer c.mtx.RUnlock()
return c.height
} | go | func (c *MempoolDataCache) GetHeight() uint32 {
c.mtx.RLock()
defer c.mtx.RUnlock()
return c.height
} | [
"func",
"(",
"c",
"*",
"MempoolDataCache",
")",
"GetHeight",
"(",
")",
"uint32",
"{",
"c",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"c",
".",
"height",
"\n",
"}"
] | // GetHeight returns the mempool height | [
"GetHeight",
"returns",
"the",
"mempool",
"height"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mempoolcache.go#L64-L68 |
142,318 | decred/dcrdata | mempool/mempoolcache.go | GetNumTickets | func (c *MempoolDataCache) GetNumTickets() (uint32, uint32) {
c.mtx.RLock()
defer c.mtx.RUnlock()
return c.height, c.numTickets
} | go | func (c *MempoolDataCache) GetNumTickets() (uint32, uint32) {
c.mtx.RLock()
defer c.mtx.RUnlock()
return c.height, c.numTickets
} | [
"func",
"(",
"c",
"*",
"MempoolDataCache",
")",
"GetNumTickets",
"(",
")",
"(",
"uint32",
",",
"uint32",
")",
"{",
"c",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"c",
".",
"heigh... | // GetNumTickets returns the mempool height and number of tickets | [
"GetNumTickets",
"returns",
"the",
"mempool",
"height",
"and",
"number",
"of",
"tickets"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mempoolcache.go#L71-L75 |
142,319 | decred/dcrdata | mempool/mempoolcache.go | GetFeeInfo | func (c *MempoolDataCache) GetFeeInfo() (uint32, dcrjson.FeeInfoMempool) {
c.mtx.RLock()
defer c.mtx.RUnlock()
return c.height, c.ticketFeeInfo
} | go | func (c *MempoolDataCache) GetFeeInfo() (uint32, dcrjson.FeeInfoMempool) {
c.mtx.RLock()
defer c.mtx.RUnlock()
return c.height, c.ticketFeeInfo
} | [
"func",
"(",
"c",
"*",
"MempoolDataCache",
")",
"GetFeeInfo",
"(",
")",
"(",
"uint32",
",",
"dcrjson",
".",
"FeeInfoMempool",
")",
"{",
"c",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"RUnlock",
"(",
")",
"\n",
"return... | // GetFeeInfo returns the mempool height and basic fee info | [
"GetFeeInfo",
"returns",
"the",
"mempool",
"height",
"and",
"basic",
"fee",
"info"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mempoolcache.go#L78-L82 |
142,320 | decred/dcrdata | mempool/mempoolcache.go | GetFeeInfoExtra | func (c *MempoolDataCache) GetFeeInfoExtra() (uint32, *apitypes.MempoolTicketFeeInfo) {
c.mtx.RLock()
defer c.mtx.RUnlock()
feeInfo := apitypes.MempoolTicketFeeInfo{
Height: c.height,
Time: c.timestamp.Unix(),
FeeInfoMempool: c.ticketFeeInfo,
LowestMineable: c.lowestMineableByFeeRate,
}
r... | go | func (c *MempoolDataCache) GetFeeInfoExtra() (uint32, *apitypes.MempoolTicketFeeInfo) {
c.mtx.RLock()
defer c.mtx.RUnlock()
feeInfo := apitypes.MempoolTicketFeeInfo{
Height: c.height,
Time: c.timestamp.Unix(),
FeeInfoMempool: c.ticketFeeInfo,
LowestMineable: c.lowestMineableByFeeRate,
}
r... | [
"func",
"(",
"c",
"*",
"MempoolDataCache",
")",
"GetFeeInfoExtra",
"(",
")",
"(",
"uint32",
",",
"*",
"apitypes",
".",
"MempoolTicketFeeInfo",
")",
"{",
"c",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"RUnlock",
"(",
")"... | // GetFeeInfoExtra returns the mempool height and detailed fee info | [
"GetFeeInfoExtra",
"returns",
"the",
"mempool",
"height",
"and",
"detailed",
"fee",
"info"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mempoolcache.go#L85-L95 |
142,321 | decred/dcrdata | mempool/mempoolcache.go | GetFees | func (c *MempoolDataCache) GetFees(N int) (uint32, int, []float64) {
c.mtx.RLock()
defer c.mtx.RUnlock()
numFees := len(c.allFees)
//var fees []float64
fees := []float64{} // for consistency
if N == 0 {
return c.height, numFees, fees
}
if N < 0 || N >= numFees {
fees = make([]float64, numFees)
copy(fee... | go | func (c *MempoolDataCache) GetFees(N int) (uint32, int, []float64) {
c.mtx.RLock()
defer c.mtx.RUnlock()
numFees := len(c.allFees)
//var fees []float64
fees := []float64{} // for consistency
if N == 0 {
return c.height, numFees, fees
}
if N < 0 || N >= numFees {
fees = make([]float64, numFees)
copy(fee... | [
"func",
"(",
"c",
"*",
"MempoolDataCache",
")",
"GetFees",
"(",
"N",
"int",
")",
"(",
"uint32",
",",
"int",
",",
"[",
"]",
"float64",
")",
"{",
"c",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"RUnlock",
"(",
")",
... | // GetFees returns the mempool height number of fees and an array of the fields | [
"GetFees",
"returns",
"the",
"mempool",
"height",
"number",
"of",
"fees",
"and",
"an",
"array",
"of",
"the",
"fields"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mempoolcache.go#L98-L121 |
142,322 | decred/dcrdata | mempool/mempoolcache.go | GetFeeRates | func (c *MempoolDataCache) GetFeeRates(N int) (uint32, int64, int, []float64) {
c.mtx.RLock()
defer c.mtx.RUnlock()
numFees := len(c.allFeeRates)
//var fees []float64
fees := []float64{}
if N == 0 {
return c.height, c.timestamp.Unix(), numFees, fees
}
if N < 0 || N >= numFees {
fees = make([]float64, num... | go | func (c *MempoolDataCache) GetFeeRates(N int) (uint32, int64, int, []float64) {
c.mtx.RLock()
defer c.mtx.RUnlock()
numFees := len(c.allFeeRates)
//var fees []float64
fees := []float64{}
if N == 0 {
return c.height, c.timestamp.Unix(), numFees, fees
}
if N < 0 || N >= numFees {
fees = make([]float64, num... | [
"func",
"(",
"c",
"*",
"MempoolDataCache",
")",
"GetFeeRates",
"(",
"N",
"int",
")",
"(",
"uint32",
",",
"int64",
",",
"int",
",",
"[",
"]",
"float64",
")",
"{",
"c",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"RUn... | // GetFeeRates returns the mempool height, time, number of fees and an array of
// fee rates | [
"GetFeeRates",
"returns",
"the",
"mempool",
"height",
"time",
"number",
"of",
"fees",
"and",
"an",
"array",
"of",
"fee",
"rates"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mempoolcache.go#L125-L148 |
142,323 | decred/dcrdata | mempool/mempoolcache.go | GetTicketsDetails | func (c *MempoolDataCache) GetTicketsDetails(N int) (uint32, int64, int, TicketsDetails) {
c.mtx.RLock()
defer c.mtx.RUnlock()
numSSTx := len(c.allTicketsDetails)
//var details TicketsDetails
details := TicketsDetails{}
if N == 0 {
return c.height, c.timestamp.Unix(), numSSTx, details
}
if N < 0 || N >= num... | go | func (c *MempoolDataCache) GetTicketsDetails(N int) (uint32, int64, int, TicketsDetails) {
c.mtx.RLock()
defer c.mtx.RUnlock()
numSSTx := len(c.allTicketsDetails)
//var details TicketsDetails
details := TicketsDetails{}
if N == 0 {
return c.height, c.timestamp.Unix(), numSSTx, details
}
if N < 0 || N >= num... | [
"func",
"(",
"c",
"*",
"MempoolDataCache",
")",
"GetTicketsDetails",
"(",
"N",
"int",
")",
"(",
"uint32",
",",
"int64",
",",
"int",
",",
"TicketsDetails",
")",
"{",
"c",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"RUnl... | // GetTicketsDetails returns the mempool height, time, number of tickets and the
// ticket details | [
"GetTicketsDetails",
"returns",
"the",
"mempool",
"height",
"time",
"number",
"of",
"tickets",
"and",
"the",
"ticket",
"details"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mempoolcache.go#L152-L174 |
142,324 | decred/dcrdata | mempool/mempoolcache.go | GetTicketPriceCountTime | func (c *MempoolDataCache) GetTicketPriceCountTime(feeAvgLength int) *apitypes.PriceCountTime {
c.mtx.RLock()
defer c.mtx.RUnlock()
numFees := len(c.allFees)
if numFees < feeAvgLength {
feeAvgLength = numFees
}
var feeAvg float64
for i := 0; i < feeAvgLength; i++ {
feeAvg += c.allFees[numFees-i-1]
}
feeAv... | go | func (c *MempoolDataCache) GetTicketPriceCountTime(feeAvgLength int) *apitypes.PriceCountTime {
c.mtx.RLock()
defer c.mtx.RUnlock()
numFees := len(c.allFees)
if numFees < feeAvgLength {
feeAvgLength = numFees
}
var feeAvg float64
for i := 0; i < feeAvgLength; i++ {
feeAvg += c.allFees[numFees-i-1]
}
feeAv... | [
"func",
"(",
"c",
"*",
"MempoolDataCache",
")",
"GetTicketPriceCountTime",
"(",
"feeAvgLength",
"int",
")",
"*",
"apitypes",
".",
"PriceCountTime",
"{",
"c",
".",
"mtx",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mtx",
".",
"RUnlock",
"(",
")",
... | // GetTicketPriceCountTime gathers the nominal info for mempool tickets. | [
"GetTicketPriceCountTime",
"gathers",
"the",
"nominal",
"info",
"for",
"mempool",
"tickets",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/mempool/mempoolcache.go#L177-L196 |
142,325 | decred/dcrdata | api/insight/apiroutes.go | NewInsightApi | func NewInsightApi(client *rpcclient.Client, blockData *dcrpg.ChainDBRPC, params *chaincfg.Params,
memPoolData rpcutils.MempoolAddressChecker, JSONIndent string, maxAddrs int, status *apitypes.Status) *InsightApi {
newContext := InsightApi{
nodeClient: client,
BlockData: blockData,
params: par... | go | func NewInsightApi(client *rpcclient.Client, blockData *dcrpg.ChainDBRPC, params *chaincfg.Params,
memPoolData rpcutils.MempoolAddressChecker, JSONIndent string, maxAddrs int, status *apitypes.Status) *InsightApi {
newContext := InsightApi{
nodeClient: client,
BlockData: blockData,
params: par... | [
"func",
"NewInsightApi",
"(",
"client",
"*",
"rpcclient",
".",
"Client",
",",
"blockData",
"*",
"dcrpg",
".",
"ChainDBRPC",
",",
"params",
"*",
"chaincfg",
".",
"Params",
",",
"memPoolData",
"rpcutils",
".",
"MempoolAddressChecker",
",",
"JSONIndent",
"string",
... | // NewInsightApi is the constructor for InsightApi. | [
"NewInsightApi",
"is",
"the",
"constructor",
"for",
"InsightApi",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/api/insight/apiroutes.go#L46-L59 |
142,326 | decred/dcrdata | db/dcrpg/insightapi.go | GetRawTransaction | func (pgb *ChainDBRPC) GetRawTransaction(txid *chainhash.Hash) (*dcrjson.TxRawResult, error) {
txraw, err := rpcutils.GetTransactionVerboseByID(pgb.Client, txid)
if err != nil {
log.Errorf("GetRawTransactionVerbose failed for: %s", txid)
return nil, err
}
return txraw, nil
} | go | func (pgb *ChainDBRPC) GetRawTransaction(txid *chainhash.Hash) (*dcrjson.TxRawResult, error) {
txraw, err := rpcutils.GetTransactionVerboseByID(pgb.Client, txid)
if err != nil {
log.Errorf("GetRawTransactionVerbose failed for: %s", txid)
return nil, err
}
return txraw, nil
} | [
"func",
"(",
"pgb",
"*",
"ChainDBRPC",
")",
"GetRawTransaction",
"(",
"txid",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"*",
"dcrjson",
".",
"TxRawResult",
",",
"error",
")",
"{",
"txraw",
",",
"err",
":=",
"rpcutils",
".",
"GetTransactionVerboseByID",
"(",... | // GetRawTransaction gets a dcrjson.TxRawResult for the specified transaction
// hash. | [
"GetRawTransaction",
"gets",
"a",
"dcrjson",
".",
"TxRawResult",
"for",
"the",
"specified",
"transaction",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/insightapi.go#L23-L30 |
142,327 | decred/dcrdata | db/dcrpg/insightapi.go | GetBlockHeight | func (pgb *ChainDB) GetBlockHeight(hash string) (int64, error) {
ctx, cancel := context.WithTimeout(pgb.ctx, pgb.queryTimeout)
defer cancel()
height, err := RetrieveBlockHeight(ctx, pgb.db, hash)
if err != nil {
log.Errorf("Unable to get block height for hash %s: %v", hash, err)
return -1, pgb.replaceCancelErro... | go | func (pgb *ChainDB) GetBlockHeight(hash string) (int64, error) {
ctx, cancel := context.WithTimeout(pgb.ctx, pgb.queryTimeout)
defer cancel()
height, err := RetrieveBlockHeight(ctx, pgb.db, hash)
if err != nil {
log.Errorf("Unable to get block height for hash %s: %v", hash, err)
return -1, pgb.replaceCancelErro... | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"GetBlockHeight",
"(",
"hash",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"pgb",
".",
"ctx",
",",
"pgb",
".",
"queryTimeout",
")",
"\n"... | // GetBlockHeight returns the height of the block with the specified hash. | [
"GetBlockHeight",
"returns",
"the",
"height",
"of",
"the",
"block",
"with",
"the",
"specified",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/insightapi.go#L33-L42 |
142,328 | decred/dcrdata | db/dcrpg/insightapi.go | SendRawTransaction | func (pgb *ChainDBRPC) SendRawTransaction(txhex string) (string, error) {
msg, err := txhelpers.MsgTxFromHex(txhex)
if err != nil {
log.Errorf("SendRawTransaction failed: could not decode hex")
return "", err
}
hash, err := pgb.Client.SendRawTransaction(msg, true)
if err != nil {
log.Errorf("SendRawTransacti... | go | func (pgb *ChainDBRPC) SendRawTransaction(txhex string) (string, error) {
msg, err := txhelpers.MsgTxFromHex(txhex)
if err != nil {
log.Errorf("SendRawTransaction failed: could not decode hex")
return "", err
}
hash, err := pgb.Client.SendRawTransaction(msg, true)
if err != nil {
log.Errorf("SendRawTransacti... | [
"func",
"(",
"pgb",
"*",
"ChainDBRPC",
")",
"SendRawTransaction",
"(",
"txhex",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"msg",
",",
"err",
":=",
"txhelpers",
".",
"MsgTxFromHex",
"(",
"txhex",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // SendRawTransaction attempts to decode the input serialized transaction,
// passed as hex encoded string, and broadcast it, returning the tx hash. | [
"SendRawTransaction",
"attempts",
"to",
"decode",
"the",
"input",
"serialized",
"transaction",
"passed",
"as",
"hex",
"encoded",
"string",
"and",
"broadcast",
"it",
"returning",
"the",
"tx",
"hash",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/insightapi.go#L46-L58 |
142,329 | decred/dcrdata | db/dcrpg/insightapi.go | GetTransactionHex | func (pgb *ChainDBRPC) GetTransactionHex(txid *chainhash.Hash) string {
txraw, err := rpcutils.GetTransactionVerboseByID(pgb.Client, txid)
if err != nil {
log.Errorf("GetRawTransactionVerbose failed for: %v", err)
return ""
}
return txraw.Hex
} | go | func (pgb *ChainDBRPC) GetTransactionHex(txid *chainhash.Hash) string {
txraw, err := rpcutils.GetTransactionVerboseByID(pgb.Client, txid)
if err != nil {
log.Errorf("GetRawTransactionVerbose failed for: %v", err)
return ""
}
return txraw.Hex
} | [
"func",
"(",
"pgb",
"*",
"ChainDBRPC",
")",
"GetTransactionHex",
"(",
"txid",
"*",
"chainhash",
".",
"Hash",
")",
"string",
"{",
"txraw",
",",
"err",
":=",
"rpcutils",
".",
"GetTransactionVerboseByID",
"(",
"pgb",
".",
"Client",
",",
"txid",
")",
"\n\n",
... | // GetTransactionHex returns the full serialized transaction for the specified
// transaction hash as a hex encode string. | [
"GetTransactionHex",
"returns",
"the",
"full",
"serialized",
"transaction",
"for",
"the",
"specified",
"transaction",
"hash",
"as",
"a",
"hex",
"encode",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/insightapi.go#L172-L181 |
142,330 | decred/dcrdata | db/dcrpg/indexing.go | IndexVinTableOnVins | func IndexVinTableOnVins(db *sql.DB) (err error) {
_, err = db.Exec(internal.IndexVinTableOnVins)
return
} | go | func IndexVinTableOnVins(db *sql.DB) (err error) {
_, err = db.Exec(internal.IndexVinTableOnVins)
return
} | [
"func",
"IndexVinTableOnVins",
"(",
"db",
"*",
"sql",
".",
"DB",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"db",
".",
"Exec",
"(",
"internal",
".",
"IndexVinTableOnVins",
")",
"\n",
"return",
"\n",
"}"
] | // Vins table indexes | [
"Vins",
"table",
"indexes"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L29-L32 |
142,331 | decred/dcrdata | db/dcrpg/indexing.go | MissingIndexes | func (pgb *ChainDB) MissingIndexes() (missing, descs []string, err error) {
for idxName, desc := range internal.IndexDescriptions {
var exists bool
exists, err = ExistsIndex(pgb.db, idxName)
if err != nil {
return
}
if !exists {
missing = append(missing, idxName)
descs = append(descs, desc)
}
}
... | go | func (pgb *ChainDB) MissingIndexes() (missing, descs []string, err error) {
for idxName, desc := range internal.IndexDescriptions {
var exists bool
exists, err = ExistsIndex(pgb.db, idxName)
if err != nil {
return
}
if !exists {
missing = append(missing, idxName)
descs = append(descs, desc)
}
}
... | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"MissingIndexes",
"(",
")",
"(",
"missing",
",",
"descs",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"for",
"idxName",
",",
"desc",
":=",
"range",
"internal",
".",
"IndexDescriptions",
"{",
"var",
"exist... | // Indexes checks
// MissingIndexes lists missing table indexes and their descriptions. | [
"Indexes",
"checks",
"MissingIndexes",
"lists",
"missing",
"table",
"indexes",
"and",
"their",
"descriptions",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L364-L377 |
142,332 | decred/dcrdata | db/dcrpg/indexing.go | MissingAddressIndexes | func (pgb *ChainDB) MissingAddressIndexes() (missing []string, descs []string, err error) {
for _, idxName := range internal.AddressesIndexNames {
var exists bool
exists, err = ExistsIndex(pgb.db, idxName)
if err != nil {
return
}
if !exists {
missing = append(missing, idxName)
descs = append(descs,... | go | func (pgb *ChainDB) MissingAddressIndexes() (missing []string, descs []string, err error) {
for _, idxName := range internal.AddressesIndexNames {
var exists bool
exists, err = ExistsIndex(pgb.db, idxName)
if err != nil {
return
}
if !exists {
missing = append(missing, idxName)
descs = append(descs,... | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"MissingAddressIndexes",
"(",
")",
"(",
"missing",
"[",
"]",
"string",
",",
"descs",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"for",
"_",
",",
"idxName",
":=",
"range",
"internal",
".",
"AddressesIndex... | // MissingAddressIndexes list missing addresses table indexes and their
// descriptions. | [
"MissingAddressIndexes",
"list",
"missing",
"addresses",
"table",
"indexes",
"and",
"their",
"descriptions",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L381-L394 |
142,333 | decred/dcrdata | db/dcrpg/indexing.go | indexDescription | func (pgb *ChainDB) indexDescription(indexName string) string {
name, ok := internal.IndexDescriptions[indexName]
if !ok {
name = "unknown index"
}
return name
} | go | func (pgb *ChainDB) indexDescription(indexName string) string {
name, ok := internal.IndexDescriptions[indexName]
if !ok {
name = "unknown index"
}
return name
} | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"indexDescription",
"(",
"indexName",
"string",
")",
"string",
"{",
"name",
",",
"ok",
":=",
"internal",
".",
"IndexDescriptions",
"[",
"indexName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"name",
"=",
"\"",
"\"",
"\n"... | // indexDescription gives the description of the named index. | [
"indexDescription",
"gives",
"the",
"description",
"of",
"the",
"named",
"index",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L397-L403 |
142,334 | decred/dcrdata | db/dcrpg/indexing.go | DeindexAll | func (pgb *ChainDB) DeindexAll() error {
allDeIndexes := []deIndexingInfo{
// blocks table
{DeindexBlockTableOnHash},
{DeindexBlockTableOnHeight},
// transactions table
{DeindexTransactionTableOnHashes},
{DeindexTransactionTableOnBlockIn},
// vins table
{DeindexVinTableOnVins},
{DeindexVinTableOnPr... | go | func (pgb *ChainDB) DeindexAll() error {
allDeIndexes := []deIndexingInfo{
// blocks table
{DeindexBlockTableOnHash},
{DeindexBlockTableOnHeight},
// transactions table
{DeindexTransactionTableOnHashes},
{DeindexTransactionTableOnBlockIn},
// vins table
{DeindexVinTableOnVins},
{DeindexVinTableOnPr... | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"DeindexAll",
"(",
")",
"error",
"{",
"allDeIndexes",
":=",
"[",
"]",
"deIndexingInfo",
"{",
"// blocks table",
"{",
"DeindexBlockTableOnHash",
"}",
",",
"{",
"DeindexBlockTableOnHeight",
"}",
",",
"// transactions table",
... | // DeindexAll drops indexes in most tables. | [
"DeindexAll",
"drops",
"indexes",
"in",
"most",
"tables",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L406-L466 |
142,335 | decred/dcrdata | db/dcrpg/indexing.go | IndexTicketsTable | func (pgb *ChainDB) IndexTicketsTable(barLoad chan *dbtypes.ProgressBarLoad) error {
ticketsTableIndexes := []indexingInfo{
{Msg: "ticket hash", IndexFunc: IndexTicketsTableOnHashes},
{Msg: "ticket pool status", IndexFunc: IndexTicketsTableOnPoolStatus},
{Msg: "transaction Db ID", IndexFunc: IndexTicketsTableOnT... | go | func (pgb *ChainDB) IndexTicketsTable(barLoad chan *dbtypes.ProgressBarLoad) error {
ticketsTableIndexes := []indexingInfo{
{Msg: "ticket hash", IndexFunc: IndexTicketsTableOnHashes},
{Msg: "ticket pool status", IndexFunc: IndexTicketsTableOnPoolStatus},
{Msg: "transaction Db ID", IndexFunc: IndexTicketsTableOnT... | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"IndexTicketsTable",
"(",
"barLoad",
"chan",
"*",
"dbtypes",
".",
"ProgressBarLoad",
")",
"error",
"{",
"ticketsTableIndexes",
":=",
"[",
"]",
"indexingInfo",
"{",
"{",
"Msg",
":",
"\"",
"\"",
",",
"IndexFunc",
":",... | // IndexTicketsTable creates indexes in the tickets table on ticket hash,
// ticket pool status and tx DB ID columns. | [
"IndexTicketsTable",
"creates",
"indexes",
"in",
"the",
"tickets",
"table",
"on",
"ticket",
"hash",
"ticket",
"pool",
"status",
"and",
"tx",
"DB",
"ID",
"columns",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L540-L563 |
142,336 | decred/dcrdata | db/dcrpg/indexing.go | DeindexTicketsTable | func (pgb *ChainDB) DeindexTicketsTable() error {
ticketsTablesDeIndexes := []deIndexingInfo{
{DeindexTicketsTableOnHashes},
{DeindexTicketsTableOnPoolStatus},
{DeindexTicketsTableOnTxDbID},
}
var err error
for _, val := range ticketsTablesDeIndexes {
if err = val.DeIndexFunc(pgb.db); err != nil {
warnU... | go | func (pgb *ChainDB) DeindexTicketsTable() error {
ticketsTablesDeIndexes := []deIndexingInfo{
{DeindexTicketsTableOnHashes},
{DeindexTicketsTableOnPoolStatus},
{DeindexTicketsTableOnTxDbID},
}
var err error
for _, val := range ticketsTablesDeIndexes {
if err = val.DeIndexFunc(pgb.db); err != nil {
warnU... | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"DeindexTicketsTable",
"(",
")",
"error",
"{",
"ticketsTablesDeIndexes",
":=",
"[",
"]",
"deIndexingInfo",
"{",
"{",
"DeindexTicketsTableOnHashes",
"}",
",",
"{",
"DeindexTicketsTableOnPoolStatus",
"}",
",",
"{",
"DeindexTi... | // DeindexTicketsTable drops indexes in the tickets table on ticket hash,
// ticket pool status and tx DB ID columns. | [
"DeindexTicketsTable",
"drops",
"indexes",
"in",
"the",
"tickets",
"table",
"on",
"ticket",
"hash",
"ticket",
"pool",
"status",
"and",
"tx",
"DB",
"ID",
"columns",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L567-L582 |
142,337 | decred/dcrdata | db/dcrpg/indexing.go | IndexAddressTable | func (pgb *ChainDB) IndexAddressTable(barLoad chan *dbtypes.ProgressBarLoad) error {
addressesTableIndexes := []indexingInfo{
{Msg: "address", IndexFunc: IndexAddressTableOnAddress},
{Msg: "matching tx hash", IndexFunc: IndexMatchingTxHashOnTableAddress},
{Msg: "block time", IndexFunc: IndexBlockTimeOnTableAddre... | go | func (pgb *ChainDB) IndexAddressTable(barLoad chan *dbtypes.ProgressBarLoad) error {
addressesTableIndexes := []indexingInfo{
{Msg: "address", IndexFunc: IndexAddressTableOnAddress},
{Msg: "matching tx hash", IndexFunc: IndexMatchingTxHashOnTableAddress},
{Msg: "block time", IndexFunc: IndexBlockTimeOnTableAddre... | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"IndexAddressTable",
"(",
"barLoad",
"chan",
"*",
"dbtypes",
".",
"ProgressBarLoad",
")",
"error",
"{",
"addressesTableIndexes",
":=",
"[",
"]",
"indexingInfo",
"{",
"{",
"Msg",
":",
"\"",
"\"",
",",
"IndexFunc",
":... | // IndexAddressTable creates the indexes on the address table on the vout ID,
// block_time, matching_tx_hash and address columns. | [
"IndexAddressTable",
"creates",
"the",
"indexes",
"on",
"the",
"address",
"table",
"on",
"the",
"vout",
"ID",
"block_time",
"matching_tx_hash",
"and",
"address",
"columns",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L607-L632 |
142,338 | decred/dcrdata | db/dcrpg/indexing.go | DeindexAddressTable | func (pgb *ChainDB) DeindexAddressTable() error {
addressesDeindexes := []deIndexingInfo{
{DeindexAddressTableOnAddress},
{DeindexMatchingTxHashOnTableAddress},
{DeindexBlockTimeOnTableAddress},
{DeindexAddressTableOnVoutID},
//{DeindexAddressTableOnTxHash},
}
var err error
for _, val := range addressesD... | go | func (pgb *ChainDB) DeindexAddressTable() error {
addressesDeindexes := []deIndexingInfo{
{DeindexAddressTableOnAddress},
{DeindexMatchingTxHashOnTableAddress},
{DeindexBlockTimeOnTableAddress},
{DeindexAddressTableOnVoutID},
//{DeindexAddressTableOnTxHash},
}
var err error
for _, val := range addressesD... | [
"func",
"(",
"pgb",
"*",
"ChainDB",
")",
"DeindexAddressTable",
"(",
")",
"error",
"{",
"addressesDeindexes",
":=",
"[",
"]",
"deIndexingInfo",
"{",
"{",
"DeindexAddressTableOnAddress",
"}",
",",
"{",
"DeindexMatchingTxHashOnTableAddress",
"}",
",",
"{",
"DeindexB... | // DeindexAddressTable drops the vin ID, block_time, matching_tx_hash
// and address column indexes for the address table. | [
"DeindexAddressTable",
"drops",
"the",
"vin",
"ID",
"block_time",
"matching_tx_hash",
"and",
"address",
"column",
"indexes",
"for",
"the",
"address",
"table",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrpg/indexing.go#L636-L653 |
142,339 | decred/dcrdata | txhelpers/staketree.go | TicketTxnsInBlock | func TicketTxnsInBlock(bl *dcrutil.Block) ([]chainhash.Hash, []*dcrutil.Tx) {
tickets := make([]chainhash.Hash, 0)
ticketTxns := make([]*dcrutil.Tx, 0)
for _, stx := range bl.STransactions() {
if stake.DetermineTxType(stx.MsgTx()) == stake.TxTypeSStx {
h := stx.Hash()
tickets = append(tickets, *h)
ticketT... | go | func TicketTxnsInBlock(bl *dcrutil.Block) ([]chainhash.Hash, []*dcrutil.Tx) {
tickets := make([]chainhash.Hash, 0)
ticketTxns := make([]*dcrutil.Tx, 0)
for _, stx := range bl.STransactions() {
if stake.DetermineTxType(stx.MsgTx()) == stake.TxTypeSStx {
h := stx.Hash()
tickets = append(tickets, *h)
ticketT... | [
"func",
"TicketTxnsInBlock",
"(",
"bl",
"*",
"dcrutil",
".",
"Block",
")",
"(",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"[",
"]",
"*",
"dcrutil",
".",
"Tx",
")",
"{",
"tickets",
":=",
"make",
"(",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"0",
")... | // TicketTxnsInBlock finds all the new tickets in the block. | [
"TicketTxnsInBlock",
"finds",
"all",
"the",
"new",
"tickets",
"in",
"the",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/staketree.go#L161-L173 |
142,340 | decred/dcrdata | txhelpers/staketree.go | TicketsSpentInBlock | func TicketsSpentInBlock(bl *dcrutil.Block) []chainhash.Hash {
tickets := make([]chainhash.Hash, 0)
for _, stx := range bl.STransactions() {
if stake.DetermineTxType(stx.MsgTx()) == stake.TxTypeSSGen {
// Hash of the original STtx
tickets = append(tickets, stx.MsgTx().TxIn[1].PreviousOutPoint.Hash)
}
}
r... | go | func TicketsSpentInBlock(bl *dcrutil.Block) []chainhash.Hash {
tickets := make([]chainhash.Hash, 0)
for _, stx := range bl.STransactions() {
if stake.DetermineTxType(stx.MsgTx()) == stake.TxTypeSSGen {
// Hash of the original STtx
tickets = append(tickets, stx.MsgTx().TxIn[1].PreviousOutPoint.Hash)
}
}
r... | [
"func",
"TicketsSpentInBlock",
"(",
"bl",
"*",
"dcrutil",
".",
"Block",
")",
"[",
"]",
"chainhash",
".",
"Hash",
"{",
"tickets",
":=",
"make",
"(",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"0",
")",
"\n",
"for",
"_",
",",
"stx",
":=",
"range",
"bl"... | // TicketsSpentInBlock finds all the tickets spent in the block. | [
"TicketsSpentInBlock",
"finds",
"all",
"the",
"tickets",
"spent",
"in",
"the",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/staketree.go#L176-L186 |
142,341 | decred/dcrdata | txhelpers/staketree.go | VotesInBlock | func VotesInBlock(bl *dcrutil.Block) []chainhash.Hash {
votes := make([]chainhash.Hash, 0)
for _, stx := range bl.STransactions() {
if stake.DetermineTxType(stx.MsgTx()) == stake.TxTypeSSGen {
h := stx.Hash()
votes = append(votes, *h)
}
}
return votes
} | go | func VotesInBlock(bl *dcrutil.Block) []chainhash.Hash {
votes := make([]chainhash.Hash, 0)
for _, stx := range bl.STransactions() {
if stake.DetermineTxType(stx.MsgTx()) == stake.TxTypeSSGen {
h := stx.Hash()
votes = append(votes, *h)
}
}
return votes
} | [
"func",
"VotesInBlock",
"(",
"bl",
"*",
"dcrutil",
".",
"Block",
")",
"[",
"]",
"chainhash",
".",
"Hash",
"{",
"votes",
":=",
"make",
"(",
"[",
"]",
"chainhash",
".",
"Hash",
",",
"0",
")",
"\n",
"for",
"_",
",",
"stx",
":=",
"range",
"bl",
".",
... | // VotesInBlock finds all the votes in the block. | [
"VotesInBlock",
"finds",
"all",
"the",
"votes",
"in",
"the",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/staketree.go#L189-L199 |
142,342 | decred/dcrdata | pubsub/democlient/main.go | AnotInB | func AnotInB(sA []string, sB []string) (AnotB []string) {
for _, s := range sA {
if found, _ := strInSlice(sB, s); found {
continue
}
AnotB = append(AnotB, s)
}
return
} | go | func AnotInB(sA []string, sB []string) (AnotB []string) {
for _, s := range sA {
if found, _ := strInSlice(sB, s); found {
continue
}
AnotB = append(AnotB, s)
}
return
} | [
"func",
"AnotInB",
"(",
"sA",
"[",
"]",
"string",
",",
"sB",
"[",
"]",
"string",
")",
"(",
"AnotB",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"sA",
"{",
"if",
"found",
",",
"_",
":=",
"strInSlice",
"(",
"sB",
",",
"s"... | // AnotInB returns strings in the slice sA that are not in slice sB. | [
"AnotInB",
"returns",
"strings",
"in",
"the",
"slice",
"sA",
"that",
"are",
"not",
"in",
"slice",
"sB",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/democlient/main.go#L237-L245 |
142,343 | decred/dcrdata | db/dcrsqlite/sync.go | RewindStakeDB | func (db *WiredDB) RewindStakeDB(ctx context.Context, toHeight int64, quiet ...bool) (stakeDBHeight int64, err error) {
// Target height must be non-negative. It is not possible to disconnect the
// genesis block.
if toHeight < 0 {
toHeight = 0
}
// Periodically log progress unless quiet[0]==true
showProgress ... | go | func (db *WiredDB) RewindStakeDB(ctx context.Context, toHeight int64, quiet ...bool) (stakeDBHeight int64, err error) {
// Target height must be non-negative. It is not possible to disconnect the
// genesis block.
if toHeight < 0 {
toHeight = 0
}
// Periodically log progress unless quiet[0]==true
showProgress ... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"RewindStakeDB",
"(",
"ctx",
"context",
".",
"Context",
",",
"toHeight",
"int64",
",",
"quiet",
"...",
"bool",
")",
"(",
"stakeDBHeight",
"int64",
",",
"err",
"error",
")",
"{",
"// Target height must be non-negative. It... | // RewindStakeDB attempts to disconnect blocks from the stake database to reach
// the specified height. A channel must be provided for signaling if the rewind
// should abort. If the specified height is greater than the current stake DB
// height, RewindStakeDB will exit without error, returning the current stake DB
/... | [
"RewindStakeDB",
"attempts",
"to",
"disconnect",
"blocks",
"from",
"the",
"stake",
"database",
"to",
"reach",
"the",
"specified",
"height",
".",
"A",
"channel",
"must",
"be",
"provided",
"for",
"signaling",
"if",
"the",
"rewind",
"should",
"abort",
".",
"If",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sync.go#L103-L148 |
142,344 | decred/dcrdata | db/dcrsqlite/sync.go | ImportSideChains | func (db *WiredDB) ImportSideChains(collector *blockdata.Collector) error {
tips, err := rpcutils.SideChains(db.client)
if err != nil {
return err
}
var hashlist []*chainhash.Hash
for it := range tips {
log.Tracef("Primary DB -> Getting base DB side chain with tip %s at %d.", tips[it].Hash, tips[it].Height)
... | go | func (db *WiredDB) ImportSideChains(collector *blockdata.Collector) error {
tips, err := rpcutils.SideChains(db.client)
if err != nil {
return err
}
var hashlist []*chainhash.Hash
for it := range tips {
log.Tracef("Primary DB -> Getting base DB side chain with tip %s at %d.", tips[it].Hash, tips[it].Height)
... | [
"func",
"(",
"db",
"*",
"WiredDB",
")",
"ImportSideChains",
"(",
"collector",
"*",
"blockdata",
".",
"Collector",
")",
"error",
"{",
"tips",
",",
"err",
":=",
"rpcutils",
".",
"SideChains",
"(",
"db",
".",
"client",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // ImportSideChains imports all side chains. Similar to pgblockchain.MissingSideChainBlocks
// plus the rest from main.go | [
"ImportSideChains",
"imports",
"all",
"side",
"chains",
".",
"Similar",
"to",
"pgblockchain",
".",
"MissingSideChainBlocks",
"plus",
"the",
"rest",
"from",
"main",
".",
"go"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dcrsqlite/sync.go#L452-L497 |
142,345 | decred/dcrdata | gov/agendas/deployments.go | NewAgendasDB | func NewAgendasDB(client DeploymentSource, dbPath string) (*AgendaDB, error) {
if dbPath == "" {
return nil, fmt.Errorf("empty db Path found")
}
if client == DeploymentSource(nil) {
return nil, fmt.Errorf("invalid deployment source found")
}
_, err := os.Stat(dbPath)
if err != nil && !os.IsNotExist(err) {
... | go | func NewAgendasDB(client DeploymentSource, dbPath string) (*AgendaDB, error) {
if dbPath == "" {
return nil, fmt.Errorf("empty db Path found")
}
if client == DeploymentSource(nil) {
return nil, fmt.Errorf("invalid deployment source found")
}
_, err := os.Stat(dbPath)
if err != nil && !os.IsNotExist(err) {
... | [
"func",
"NewAgendasDB",
"(",
"client",
"DeploymentSource",
",",
"dbPath",
"string",
")",
"(",
"*",
"AgendaDB",
",",
"error",
")",
"{",
"if",
"dbPath",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",... | // NewAgendasDB opens an existing database or create a new one using with the
// specified file name. An initialized agendas db connection is returned.
// It also checks the db version, Reindexes the db if need be and sets the
// required db version. | [
"NewAgendasDB",
"opens",
"an",
"existing",
"database",
"or",
"create",
"a",
"new",
"one",
"using",
"with",
"the",
"specified",
"file",
"name",
".",
"An",
"initialized",
"agendas",
"db",
"connection",
"is",
"returned",
".",
"It",
"also",
"checks",
"the",
"db"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L66-L111 |
142,346 | decred/dcrdata | gov/agendas/deployments.go | countProperties | func (db *AgendaDB) countProperties() error {
numAgendas, err := db.sdb.Count(&AgendaTagged{})
if err != nil {
log.Errorf("Agendas count failed: %v\n", err)
return err
}
db.NumAgendas = numAgendas
return nil
} | go | func (db *AgendaDB) countProperties() error {
numAgendas, err := db.sdb.Count(&AgendaTagged{})
if err != nil {
log.Errorf("Agendas count failed: %v\n", err)
return err
}
db.NumAgendas = numAgendas
return nil
} | [
"func",
"(",
"db",
"*",
"AgendaDB",
")",
"countProperties",
"(",
")",
"error",
"{",
"numAgendas",
",",
"err",
":=",
"db",
".",
"sdb",
".",
"Count",
"(",
"&",
"AgendaTagged",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Errorf",
... | // countProperties fetches the Agendas count and appends it to the AgendaDB
// receiver. | [
"countProperties",
"fetches",
"the",
"Agendas",
"count",
"and",
"appends",
"it",
"to",
"the",
"AgendaDB",
"receiver",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L115-L124 |
142,347 | decred/dcrdata | gov/agendas/deployments.go | Close | func (db *AgendaDB) Close() error {
if db == nil || db.sdb == nil {
return nil
}
return db.sdb.Close()
} | go | func (db *AgendaDB) Close() error {
if db == nil || db.sdb == nil {
return nil
}
return db.sdb.Close()
} | [
"func",
"(",
"db",
"*",
"AgendaDB",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"db",
"==",
"nil",
"||",
"db",
".",
"sdb",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"db",
".",
"sdb",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close should be called when you are done with the AgendaDB to close the
// underlying database. | [
"Close",
"should",
"be",
"called",
"when",
"you",
"are",
"done",
"with",
"the",
"AgendaDB",
"to",
"close",
"the",
"underlying",
"database",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L128-L133 |
142,348 | decred/dcrdata | gov/agendas/deployments.go | loadAgenda | func (db *AgendaDB) loadAgenda(agendaID string) (*AgendaTagged, error) {
agenda := new(AgendaTagged)
if err := db.sdb.One("ID", agendaID, agenda); err != nil {
return nil, err
}
return agenda, nil
} | go | func (db *AgendaDB) loadAgenda(agendaID string) (*AgendaTagged, error) {
agenda := new(AgendaTagged)
if err := db.sdb.One("ID", agendaID, agenda); err != nil {
return nil, err
}
return agenda, nil
} | [
"func",
"(",
"db",
"*",
"AgendaDB",
")",
"loadAgenda",
"(",
"agendaID",
"string",
")",
"(",
"*",
"AgendaTagged",
",",
"error",
")",
"{",
"agenda",
":=",
"new",
"(",
"AgendaTagged",
")",
"\n",
"if",
"err",
":=",
"db",
".",
"sdb",
".",
"One",
"(",
"\... | // loadAgenda retrieves an agenda corresponding to the specified unique agenda
// ID, or returns nil if it does not exist. | [
"loadAgenda",
"retrieves",
"an",
"agenda",
"corresponding",
"to",
"the",
"specified",
"unique",
"agenda",
"ID",
"or",
"returns",
"nil",
"if",
"it",
"does",
"not",
"exist",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L137-L144 |
142,349 | decred/dcrdata | gov/agendas/deployments.go | agendasForVoteVersion | func agendasForVoteVersion(ver uint32, client DeploymentSource) ([]AgendaTagged, error) {
voteInfo, err := client.GetVoteInfo(ver)
if err != nil {
return nil, err
}
// Set the agendas slice capacity.
agendas := make([]AgendaTagged, 0, len(voteInfo.Agendas))
for i := range voteInfo.Agendas {
v := &voteInfo.Ag... | go | func agendasForVoteVersion(ver uint32, client DeploymentSource) ([]AgendaTagged, error) {
voteInfo, err := client.GetVoteInfo(ver)
if err != nil {
return nil, err
}
// Set the agendas slice capacity.
agendas := make([]AgendaTagged, 0, len(voteInfo.Agendas))
for i := range voteInfo.Agendas {
v := &voteInfo.Ag... | [
"func",
"agendasForVoteVersion",
"(",
"ver",
"uint32",
",",
"client",
"DeploymentSource",
")",
"(",
"[",
"]",
"AgendaTagged",
",",
"error",
")",
"{",
"voteInfo",
",",
"err",
":=",
"client",
".",
"GetVoteInfo",
"(",
"ver",
")",
"\n",
"if",
"err",
"!=",
"n... | // agendasForVoteVersion fetches the agendas using the vote versions provided. | [
"agendasForVoteVersion",
"fetches",
"the",
"agendas",
"using",
"the",
"vote",
"versions",
"provided",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L147-L171 |
142,350 | decred/dcrdata | gov/agendas/deployments.go | updatedb | func (db *AgendaDB) updatedb(activeVersions map[uint32][]chaincfg.ConsensusDeployment) (int, error) {
var agendas []AgendaTagged
for voteVersion := range activeVersions {
taggedAgendas, err := agendasForVoteVersion(voteVersion, db.rpcClient)
if err != nil || len(taggedAgendas) == 0 {
return -1, fmt.Errorf("vot... | go | func (db *AgendaDB) updatedb(activeVersions map[uint32][]chaincfg.ConsensusDeployment) (int, error) {
var agendas []AgendaTagged
for voteVersion := range activeVersions {
taggedAgendas, err := agendasForVoteVersion(voteVersion, db.rpcClient)
if err != nil || len(taggedAgendas) == 0 {
return -1, fmt.Errorf("vot... | [
"func",
"(",
"db",
"*",
"AgendaDB",
")",
"updatedb",
"(",
"activeVersions",
"map",
"[",
"uint32",
"]",
"[",
"]",
"chaincfg",
".",
"ConsensusDeployment",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"agendas",
"[",
"]",
"AgendaTagged",
"\n",
"for",
"... | // updatedb checks if vote versions available in chaincfg.ConsensusDeployment
// are already updated in the agendas db, if not yet their data is updated.
// dcrjson.GetVoteInfoResult and chaincfg.ConsensusDeployment hold almost similar
// data contents but chaincfg.Vote does not contain the important vote status
// fie... | [
"updatedb",
"checks",
"if",
"vote",
"versions",
"available",
"in",
"chaincfg",
".",
"ConsensusDeployment",
"are",
"already",
"updated",
"in",
"the",
"agendas",
"db",
"if",
"not",
"yet",
"their",
"data",
"is",
"updated",
".",
"dcrjson",
".",
"GetVoteInfoResult",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L178-L200 |
142,351 | decred/dcrdata | gov/agendas/deployments.go | storeAgenda | func (db *AgendaDB) storeAgenda(agenda *AgendaTagged) error {
return db.sdb.Save(agenda)
} | go | func (db *AgendaDB) storeAgenda(agenda *AgendaTagged) error {
return db.sdb.Save(agenda)
} | [
"func",
"(",
"db",
"*",
"AgendaDB",
")",
"storeAgenda",
"(",
"agenda",
"*",
"AgendaTagged",
")",
"error",
"{",
"return",
"db",
".",
"sdb",
".",
"Save",
"(",
"agenda",
")",
"\n",
"}"
] | // storeAgenda saves an agenda in the database. | [
"storeAgenda",
"saves",
"an",
"agenda",
"in",
"the",
"database",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L203-L205 |
142,352 | decred/dcrdata | gov/agendas/deployments.go | CheckAgendasUpdates | func (db *AgendaDB) CheckAgendasUpdates(activeVersions map[uint32][]chaincfg.ConsensusDeployment) error {
if db == nil || db.sdb == nil {
return errDefault
}
if len(activeVersions) == 0 {
return nil
}
numRecords, err := db.updatedb(activeVersions)
if err != nil {
return fmt.Errorf("agendas.CheckAgendasUpd... | go | func (db *AgendaDB) CheckAgendasUpdates(activeVersions map[uint32][]chaincfg.ConsensusDeployment) error {
if db == nil || db.sdb == nil {
return errDefault
}
if len(activeVersions) == 0 {
return nil
}
numRecords, err := db.updatedb(activeVersions)
if err != nil {
return fmt.Errorf("agendas.CheckAgendasUpd... | [
"func",
"(",
"db",
"*",
"AgendaDB",
")",
"CheckAgendasUpdates",
"(",
"activeVersions",
"map",
"[",
"uint32",
"]",
"[",
"]",
"chaincfg",
".",
"ConsensusDeployment",
")",
"error",
"{",
"if",
"db",
"==",
"nil",
"||",
"db",
".",
"sdb",
"==",
"nil",
"{",
"r... | // CheckAgendasUpdates checks for update at the start of the process and will
// proceed to update when necessary. | [
"CheckAgendasUpdates",
"checks",
"for",
"update",
"at",
"the",
"start",
"of",
"the",
"process",
"and",
"will",
"proceed",
"to",
"update",
"when",
"necessary",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L209-L226 |
142,353 | decred/dcrdata | gov/agendas/deployments.go | AgendaInfo | func (db *AgendaDB) AgendaInfo(agendaID string) (*AgendaTagged, error) {
if db == nil || db.sdb == nil {
return nil, errDefault
}
agenda, err := db.loadAgenda(agendaID)
if err != nil {
return nil, err
}
return agenda, nil
} | go | func (db *AgendaDB) AgendaInfo(agendaID string) (*AgendaTagged, error) {
if db == nil || db.sdb == nil {
return nil, errDefault
}
agenda, err := db.loadAgenda(agendaID)
if err != nil {
return nil, err
}
return agenda, nil
} | [
"func",
"(",
"db",
"*",
"AgendaDB",
")",
"AgendaInfo",
"(",
"agendaID",
"string",
")",
"(",
"*",
"AgendaTagged",
",",
"error",
")",
"{",
"if",
"db",
"==",
"nil",
"||",
"db",
".",
"sdb",
"==",
"nil",
"{",
"return",
"nil",
",",
"errDefault",
"\n",
"}... | // AgendaInfo fetches an agenda's details given it's agendaID. | [
"AgendaInfo",
"fetches",
"an",
"agenda",
"s",
"details",
"given",
"it",
"s",
"agendaID",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L229-L240 |
142,354 | decred/dcrdata | gov/agendas/deployments.go | AllAgendas | func (db *AgendaDB) AllAgendas() (agendas []*AgendaTagged, err error) {
if db == nil || db.sdb == nil {
return nil, errDefault
}
err = db.sdb.All(&agendas)
if err != nil {
log.Errorf("Failed to fetch data from Agendas DB: %v", err)
}
return
} | go | func (db *AgendaDB) AllAgendas() (agendas []*AgendaTagged, err error) {
if db == nil || db.sdb == nil {
return nil, errDefault
}
err = db.sdb.All(&agendas)
if err != nil {
log.Errorf("Failed to fetch data from Agendas DB: %v", err)
}
return
} | [
"func",
"(",
"db",
"*",
"AgendaDB",
")",
"AllAgendas",
"(",
")",
"(",
"agendas",
"[",
"]",
"*",
"AgendaTagged",
",",
"err",
"error",
")",
"{",
"if",
"db",
"==",
"nil",
"||",
"db",
".",
"sdb",
"==",
"nil",
"{",
"return",
"nil",
",",
"errDefault",
... | // AllAgendas returns all agendas and their info in the db. | [
"AllAgendas",
"returns",
"all",
"agendas",
"and",
"their",
"info",
"in",
"the",
"db",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/agendas/deployments.go#L243-L253 |
142,355 | decred/dcrdata | db/dbtypes/extraction.go | DevSubsidyAddress | func DevSubsidyAddress(params *chaincfg.Params) (string, error) {
var devSubsidyAddress string
var err error
switch params.Name {
case "testnet2":
// TestNet2 uses an invalid organization PkScript
devSubsidyAddress = "TccTkqj8wFqrUemmHMRSx8SYEueQYLmuuFk"
err = fmt.Errorf("testnet2 has invalid project fund scr... | go | func DevSubsidyAddress(params *chaincfg.Params) (string, error) {
var devSubsidyAddress string
var err error
switch params.Name {
case "testnet2":
// TestNet2 uses an invalid organization PkScript
devSubsidyAddress = "TccTkqj8wFqrUemmHMRSx8SYEueQYLmuuFk"
err = fmt.Errorf("testnet2 has invalid project fund scr... | [
"func",
"DevSubsidyAddress",
"(",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"devSubsidyAddress",
"string",
"\n",
"var",
"err",
"error",
"\n",
"switch",
"params",
".",
"Name",
"{",
"case",
"\"",
"\"",
":"... | // DevSubsidyAddress returns the development subsidy address for the specified
// network. | [
"DevSubsidyAddress",
"returns",
"the",
"development",
"subsidy",
"address",
"for",
"the",
"specified",
"network",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dbtypes/extraction.go#L17-L35 |
142,356 | decred/dcrdata | db/dbtypes/extraction.go | ExtractBlockTransactions | func ExtractBlockTransactions(msgBlock *wire.MsgBlock, txTree int8,
chainParams *chaincfg.Params, isValid, isMainchain bool) ([]*Tx, [][]*Vout, []VinTxPropertyARRAY) {
dbTxs, dbTxVouts, dbTxVins := processTransactions(msgBlock, txTree,
chainParams, isValid, isMainchain)
if txTree != wire.TxTreeRegular && txTree !=... | go | func ExtractBlockTransactions(msgBlock *wire.MsgBlock, txTree int8,
chainParams *chaincfg.Params, isValid, isMainchain bool) ([]*Tx, [][]*Vout, []VinTxPropertyARRAY) {
dbTxs, dbTxVouts, dbTxVins := processTransactions(msgBlock, txTree,
chainParams, isValid, isMainchain)
if txTree != wire.TxTreeRegular && txTree !=... | [
"func",
"ExtractBlockTransactions",
"(",
"msgBlock",
"*",
"wire",
".",
"MsgBlock",
",",
"txTree",
"int8",
",",
"chainParams",
"*",
"chaincfg",
".",
"Params",
",",
"isValid",
",",
"isMainchain",
"bool",
")",
"(",
"[",
"]",
"*",
"Tx",
",",
"[",
"]",
"[",
... | // ExtractBlockTransactions extracts transaction information from a
// wire.MsgBlock and returns the processed information in slices of the dbtypes
// Tx, Vout, and VinTxPropertyARRAY. | [
"ExtractBlockTransactions",
"extracts",
"transaction",
"information",
"from",
"a",
"wire",
".",
"MsgBlock",
"and",
"returns",
"the",
"processed",
"information",
"in",
"slices",
"of",
"the",
"dbtypes",
"Tx",
"Vout",
"and",
"VinTxPropertyARRAY",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/db/dbtypes/extraction.go#L40-L48 |
142,357 | decred/dcrdata | gov/politeia/piclient/piclient.go | RetrieveAllProposals | func RetrieveAllProposals(client *http.Client, APIRootPath, URLParams string) (
*pitypes.Proposals, error) {
// Constructs the full vetted proposals API URL
URLpath := APIRootPath + piapi.RouteAllVetted + URLParams
data, err := HandleGetRequests(client, URLpath)
if err != nil {
return nil, err
}
var publicPro... | go | func RetrieveAllProposals(client *http.Client, APIRootPath, URLParams string) (
*pitypes.Proposals, error) {
// Constructs the full vetted proposals API URL
URLpath := APIRootPath + piapi.RouteAllVetted + URLParams
data, err := HandleGetRequests(client, URLpath)
if err != nil {
return nil, err
}
var publicPro... | [
"func",
"RetrieveAllProposals",
"(",
"client",
"*",
"http",
".",
"Client",
",",
"APIRootPath",
",",
"URLParams",
"string",
")",
"(",
"*",
"pitypes",
".",
"Proposals",
",",
"error",
")",
"{",
"// Constructs the full vetted proposals API URL",
"URLpath",
":=",
"APIR... | // RetrieveAllProposals returns a list of Proposals whose maximum count is defined
// by piapi.ProposalListPageSize. Data returned is queried from Politeia API. | [
"RetrieveAllProposals",
"returns",
"a",
"list",
"of",
"Proposals",
"whose",
"maximum",
"count",
"is",
"defined",
"by",
"piapi",
".",
"ProposalListPageSize",
".",
"Data",
"returned",
"is",
"queried",
"from",
"Politeia",
"API",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/piclient/piclient.go#L54-L94 |
142,358 | decred/dcrdata | gov/politeia/piclient/piclient.go | RetrieveProposalByToken | func RetrieveProposalByToken(client *http.Client, APIRootPath, token string) (*pitypes.Proposal, error) {
// Constructs the full proposal's URl and fetch is data.
proposalRoute := APIRootPath + DropURLRegex(piapi.RouteProposalDetails, token)
data, err := HandleGetRequests(client, proposalRoute)
if err != nil {
re... | go | func RetrieveProposalByToken(client *http.Client, APIRootPath, token string) (*pitypes.Proposal, error) {
// Constructs the full proposal's URl and fetch is data.
proposalRoute := APIRootPath + DropURLRegex(piapi.RouteProposalDetails, token)
data, err := HandleGetRequests(client, proposalRoute)
if err != nil {
re... | [
"func",
"RetrieveProposalByToken",
"(",
"client",
"*",
"http",
".",
"Client",
",",
"APIRootPath",
",",
"token",
"string",
")",
"(",
"*",
"pitypes",
".",
"Proposal",
",",
"error",
")",
"{",
"// Constructs the full proposal's URl and fetch is data.",
"proposalRoute",
... | // RetrieveProposalByToken returns a single proposal identified by the token
// hash provided if it exists. Data returned is queried from Politeia API. | [
"RetrieveProposalByToken",
"returns",
"a",
"single",
"proposal",
"identified",
"by",
"the",
"token",
"hash",
"provided",
"if",
"it",
"exists",
".",
"Data",
"returned",
"is",
"queried",
"from",
"Politeia",
"API",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/gov/politeia/piclient/piclient.go#L98-L130 |
142,359 | decred/dcrdata | explorer/syncstatus.go | ShowingSyncStatusPage | func (exp *explorerUI) ShowingSyncStatusPage() bool {
display, ok := exp.displaySyncStatusPage.Load().(bool)
return ok && display
} | go | func (exp *explorerUI) ShowingSyncStatusPage() bool {
display, ok := exp.displaySyncStatusPage.Load().(bool)
return ok && display
} | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"ShowingSyncStatusPage",
"(",
")",
"bool",
"{",
"display",
",",
"ok",
":=",
"exp",
".",
"displaySyncStatusPage",
".",
"Load",
"(",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"&&",
"display",
"\n",
"}"
... | // ShowingSyncStatusPage is a thread-safe way to fetch the
// displaySyncStatusPage. | [
"ShowingSyncStatusPage",
"is",
"a",
"thread",
"-",
"safe",
"way",
"to",
"fetch",
"the",
"displaySyncStatusPage",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/syncstatus.go#L50-L53 |
142,360 | decred/dcrdata | explorer/syncstatus.go | BeginSyncStatusUpdates | func (exp *explorerUI) BeginSyncStatusUpdates(barLoad chan *dbtypes.ProgressBarLoad) {
// Do not start listening for updates if channel is nil.
if barLoad == nil {
log.Warnf("Not updating sync status page.")
return
}
// stopTimer allows safe exit of the goroutine that triggers periodic
// websocket progress u... | go | func (exp *explorerUI) BeginSyncStatusUpdates(barLoad chan *dbtypes.ProgressBarLoad) {
// Do not start listening for updates if channel is nil.
if barLoad == nil {
log.Warnf("Not updating sync status page.")
return
}
// stopTimer allows safe exit of the goroutine that triggers periodic
// websocket progress u... | [
"func",
"(",
"exp",
"*",
"explorerUI",
")",
"BeginSyncStatusUpdates",
"(",
"barLoad",
"chan",
"*",
"dbtypes",
".",
"ProgressBarLoad",
")",
"{",
"// Do not start listening for updates if channel is nil.",
"if",
"barLoad",
"==",
"nil",
"{",
"log",
".",
"Warnf",
"(",
... | // BeginSyncStatusUpdates receives the progress updates and and updates the
// blockchainSyncStatus.ProgressBars. | [
"BeginSyncStatusUpdates",
"receives",
"the",
"progress",
"updates",
"and",
"and",
"updates",
"the",
"blockchainSyncStatus",
".",
"ProgressBars",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/explorer/syncstatus.go#L62-L152 |
142,361 | decred/dcrdata | pubsub/pubsubhub.go | NewPubSubHub | func NewPubSubHub(dataSource wsDataSource) (*PubSubHub, error) {
psh := new(PubSubHub)
psh.sourceBase = dataSource
// Allocate Mempool fields.
psh.invs = new(exptypes.MempoolInfo)
// Retrieve chain parameters.
params := psh.sourceBase.GetChainParams()
psh.params = params
// Development subsidy address of the... | go | func NewPubSubHub(dataSource wsDataSource) (*PubSubHub, error) {
psh := new(PubSubHub)
psh.sourceBase = dataSource
// Allocate Mempool fields.
psh.invs = new(exptypes.MempoolInfo)
// Retrieve chain parameters.
params := psh.sourceBase.GetChainParams()
psh.params = params
// Development subsidy address of the... | [
"func",
"NewPubSubHub",
"(",
"dataSource",
"wsDataSource",
")",
"(",
"*",
"PubSubHub",
",",
"error",
")",
"{",
"psh",
":=",
"new",
"(",
"PubSubHub",
")",
"\n",
"psh",
".",
"sourceBase",
"=",
"dataSource",
"\n\n",
"// Allocate Mempool fields.",
"psh",
".",
"i... | // NewPubSubHub constructs a PubSubHub given a primary and auxiliary data
// source. The primary data source is required, while the aux. source may be
// nil, which indicates a "lite" mode of operation. The WebSocketHub is
// automatically started. | [
"NewPubSubHub",
"constructs",
"a",
"PubSubHub",
"given",
"a",
"primary",
"and",
"auxiliary",
"data",
"source",
".",
"The",
"primary",
"data",
"source",
"is",
"required",
"while",
"the",
"aux",
".",
"source",
"may",
"be",
"nil",
"which",
"indicates",
"a",
"li... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/pubsubhub.go#L89-L127 |
142,362 | decred/dcrdata | pubsub/pubsubhub.go | StopWebsocketHub | func (psh *PubSubHub) StopWebsocketHub() {
if psh == nil {
return
}
log.Info("Stopping websocket hub.")
psh.wsHub.Stop()
} | go | func (psh *PubSubHub) StopWebsocketHub() {
if psh == nil {
return
}
log.Info("Stopping websocket hub.")
psh.wsHub.Stop()
} | [
"func",
"(",
"psh",
"*",
"PubSubHub",
")",
"StopWebsocketHub",
"(",
")",
"{",
"if",
"psh",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"psh",
".",
"wsHub",
".",
"Stop",
"(",
")",
"\n",
"}"
] | // StopWebsocketHub stops the websocket hub. | [
"StopWebsocketHub",
"stops",
"the",
"websocket",
"hub",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/pubsubhub.go#L130-L136 |
142,363 | decred/dcrdata | pubsub/pubsubhub.go | closeWS | func closeWS(ws *websocket.Conn) {
err := ws.Close()
// Do not log error if connection is just closed
if err != nil && !pstypes.IsWSClosedErr(err) && !pstypes.IsIOTimeoutErr(err) {
log.Errorf("Failed to close websocket: %v", err)
}
} | go | func closeWS(ws *websocket.Conn) {
err := ws.Close()
// Do not log error if connection is just closed
if err != nil && !pstypes.IsWSClosedErr(err) && !pstypes.IsIOTimeoutErr(err) {
log.Errorf("Failed to close websocket: %v", err)
}
} | [
"func",
"closeWS",
"(",
"ws",
"*",
"websocket",
".",
"Conn",
")",
"{",
"err",
":=",
"ws",
".",
"Close",
"(",
")",
"\n",
"// Do not log error if connection is just closed",
"if",
"err",
"!=",
"nil",
"&&",
"!",
"pstypes",
".",
"IsWSClosedErr",
"(",
"err",
")... | // closeWS attempts to close a websocket.Conn, logging errors other than those
// with messages containing ErrWsClosed. | [
"closeWS",
"attempts",
"to",
"close",
"a",
"websocket",
".",
"Conn",
"logging",
"errors",
"other",
"than",
"those",
"with",
"messages",
"containing",
"ErrWsClosed",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/pubsubhub.go#L163-L169 |
142,364 | decred/dcrdata | pubsub/websocket.go | Ready | func (wsh *WebsocketHub) Ready() bool {
syncing, ok := wsh.ready.Load().(bool)
return ok && syncing
} | go | func (wsh *WebsocketHub) Ready() bool {
syncing, ok := wsh.ready.Load().(bool)
return ok && syncing
} | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"Ready",
"(",
")",
"bool",
"{",
"syncing",
",",
"ok",
":=",
"wsh",
".",
"ready",
".",
"Load",
"(",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"&&",
"syncing",
"\n",
"}"
] | // Ready is a thread-safe way to fetch the boolean in ready. | [
"Ready",
"is",
"a",
"thread",
"-",
"safe",
"way",
"to",
"fetch",
"the",
"boolean",
"in",
"ready",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/websocket.go#L92-L95 |
142,365 | decred/dcrdata | pubsub/websocket.go | NewWebsocketHub | func NewWebsocketHub() *WebsocketHub {
return &WebsocketHub{
clients: make(map[*hubSpoke]*client),
Register: make(chan *clientHubSpoke),
Unregister: make(chan *hubSpoke),
HubRelay: make(chan pstypes.HubMessage),
bufferTickerChan: make(chan int, clientSignalSize),
quitWSHandle... | go | func NewWebsocketHub() *WebsocketHub {
return &WebsocketHub{
clients: make(map[*hubSpoke]*client),
Register: make(chan *clientHubSpoke),
Unregister: make(chan *hubSpoke),
HubRelay: make(chan pstypes.HubMessage),
bufferTickerChan: make(chan int, clientSignalSize),
quitWSHandle... | [
"func",
"NewWebsocketHub",
"(",
")",
"*",
"WebsocketHub",
"{",
"return",
"&",
"WebsocketHub",
"{",
"clients",
":",
"make",
"(",
"map",
"[",
"*",
"hubSpoke",
"]",
"*",
"client",
")",
",",
"Register",
":",
"make",
"(",
"chan",
"*",
"clientHubSpoke",
")",
... | // NewWebsocketHub creates a new WebsocketHub. | [
"NewWebsocketHub",
"creates",
"a",
"new",
"WebsocketHub",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/websocket.go#L189-L199 |
142,366 | decred/dcrdata | pubsub/websocket.go | NewClientHubSpoke | func (wsh *WebsocketHub) NewClientHubSpoke() *clientHubSpoke {
c := make(hubSpoke, 16)
ch := &clientHubSpoke{
cl: newClient(),
c: &c,
}
wsh.Register <- ch
return ch
} | go | func (wsh *WebsocketHub) NewClientHubSpoke() *clientHubSpoke {
c := make(hubSpoke, 16)
ch := &clientHubSpoke{
cl: newClient(),
c: &c,
}
wsh.Register <- ch
return ch
} | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"NewClientHubSpoke",
"(",
")",
"*",
"clientHubSpoke",
"{",
"c",
":=",
"make",
"(",
"hubSpoke",
",",
"16",
")",
"\n",
"ch",
":=",
"&",
"clientHubSpoke",
"{",
"cl",
":",
"newClient",
"(",
")",
",",
"c",
":"... | // NewClientHubSpoke registers a connection with the hub, and returns a pointer
// to the new client data object. Use UnregisterClient on this object to stop
// signaling messages, and close the signal channel. | [
"NewClientHubSpoke",
"registers",
"a",
"connection",
"with",
"the",
"hub",
"and",
"returns",
"a",
"pointer",
"to",
"the",
"new",
"client",
"data",
"object",
".",
"Use",
"UnregisterClient",
"on",
"this",
"object",
"to",
"stop",
"signaling",
"messages",
"and",
"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/websocket.go#L211-L219 |
142,367 | decred/dcrdata | pubsub/websocket.go | registerClient | func (wsh *WebsocketHub) registerClient(ch *clientHubSpoke) {
wsh.clients[ch.c] = ch.cl
wsh.setNumClients(len(wsh.clients))
log.Debugf("Registered new websocket client (%d).", wsh.NumClients())
} | go | func (wsh *WebsocketHub) registerClient(ch *clientHubSpoke) {
wsh.clients[ch.c] = ch.cl
wsh.setNumClients(len(wsh.clients))
log.Debugf("Registered new websocket client (%d).", wsh.NumClients())
} | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"registerClient",
"(",
"ch",
"*",
"clientHubSpoke",
")",
"{",
"wsh",
".",
"clients",
"[",
"ch",
".",
"c",
"]",
"=",
"ch",
".",
"cl",
"\n",
"wsh",
".",
"setNumClients",
"(",
"len",
"(",
"wsh",
".",
"clie... | // registerClient should only be called from the run loop. | [
"registerClient",
"should",
"only",
"be",
"called",
"from",
"the",
"run",
"loop",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/websocket.go#L233-L237 |
142,368 | decred/dcrdata | pubsub/websocket.go | addTxToBuffer | func (wsh *WebsocketHub) addTxToBuffer(tx *exptypes.MempoolTx) (someReadyToSend bool) {
for _, client := range wsh.clients {
someReadyToSend = client.newTxs.addTxToBuffer(tx)
}
return
} | go | func (wsh *WebsocketHub) addTxToBuffer(tx *exptypes.MempoolTx) (someReadyToSend bool) {
for _, client := range wsh.clients {
someReadyToSend = client.newTxs.addTxToBuffer(tx)
}
return
} | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"addTxToBuffer",
"(",
"tx",
"*",
"exptypes",
".",
"MempoolTx",
")",
"(",
"someReadyToSend",
"bool",
")",
"{",
"for",
"_",
",",
"client",
":=",
"range",
"wsh",
".",
"clients",
"{",
"someReadyToSend",
"=",
"cli... | // addTxToBuffer adds a tx to each client's tx buffer. The return boolean value
// indicates if at least one buffer is ready to be sent. | [
"addTxToBuffer",
"adds",
"a",
"tx",
"to",
"each",
"client",
"s",
"tx",
"buffer",
".",
"The",
"return",
"boolean",
"value",
"indicates",
"if",
"at",
"least",
"one",
"buffer",
"is",
"ready",
"to",
"be",
"sent",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/websocket.go#L465-L470 |
142,369 | decred/dcrdata | pubsub/websocket.go | periodicTxBufferSend | func (wsh *WebsocketHub) periodicTxBufferSend() {
ticker := time.NewTicker(bufferTickerInterval * time.Second)
for {
select {
case <-ticker.C:
wsh.SetTimeToSendTxBuffer(true)
case sig := <-wsh.bufferTickerChan:
switch sig {
case tickerSigReset:
ticker.Stop()
ticker = time.NewTicker(bufferTicker... | go | func (wsh *WebsocketHub) periodicTxBufferSend() {
ticker := time.NewTicker(bufferTickerInterval * time.Second)
for {
select {
case <-ticker.C:
wsh.SetTimeToSendTxBuffer(true)
case sig := <-wsh.bufferTickerChan:
switch sig {
case tickerSigReset:
ticker.Stop()
ticker = time.NewTicker(bufferTicker... | [
"func",
"(",
"wsh",
"*",
"WebsocketHub",
")",
"periodicTxBufferSend",
"(",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"bufferTickerInterval",
"*",
"time",
".",
"Second",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"ticker",
".",
"C"... | // periodicTxBufferSend initiates a transaction buffer send via sendTxBufferChan
// every bufferTickerInterval seconds. | [
"periodicTxBufferSend",
"initiates",
"a",
"transaction",
"buffer",
"send",
"via",
"sendTxBufferChan",
"every",
"bufferTickerInterval",
"seconds",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/pubsub/websocket.go#L474-L491 |
142,370 | decred/dcrdata | txhelpers/txhelpers.go | HashInSlice | func HashInSlice(h chainhash.Hash, list []chainhash.Hash) bool {
for _, hash := range list {
if h == hash {
return true
}
}
return false
} | go | func HashInSlice(h chainhash.Hash, list []chainhash.Hash) bool {
for _, hash := range list {
if h == hash {
return true
}
}
return false
} | [
"func",
"HashInSlice",
"(",
"h",
"chainhash",
".",
"Hash",
",",
"list",
"[",
"]",
"chainhash",
".",
"Hash",
")",
"bool",
"{",
"for",
"_",
",",
"hash",
":=",
"range",
"list",
"{",
"if",
"h",
"==",
"hash",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}... | // HashInSlice determines if a hash exists in a slice of hashes. | [
"HashInSlice",
"determines",
"if",
"a",
"hash",
"exists",
"in",
"a",
"slice",
"of",
"hashes",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L100-L107 |
142,371 | decred/dcrdata | txhelpers/txhelpers.go | IncludesStakeTx | func IncludesStakeTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8) {
blockTxs := block.STransactions()
if tx := TxhashInSlice(blockTxs, txHash); tx != nil {
return tx.Index(), tx.Tree()
}
return -1, -1
} | go | func IncludesStakeTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8) {
blockTxs := block.STransactions()
if tx := TxhashInSlice(blockTxs, txHash); tx != nil {
return tx.Index(), tx.Tree()
}
return -1, -1
} | [
"func",
"IncludesStakeTx",
"(",
"txHash",
"*",
"chainhash",
".",
"Hash",
",",
"block",
"*",
"dcrutil",
".",
"Block",
")",
"(",
"int",
",",
"int8",
")",
"{",
"blockTxs",
":=",
"block",
".",
"STransactions",
"(",
")",
"\n\n",
"if",
"tx",
":=",
"TxhashInS... | // IncludesStakeTx checks if a block contains a stake transaction hash | [
"IncludesStakeTx",
"checks",
"if",
"a",
"block",
"contains",
"a",
"stake",
"transaction",
"hash"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L126-L133 |
142,372 | decred/dcrdata | txhelpers/txhelpers.go | IncludesTx | func IncludesTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8) {
blockTxs := block.Transactions()
if tx := TxhashInSlice(blockTxs, txHash); tx != nil {
return tx.Index(), tx.Tree()
}
return -1, -1
} | go | func IncludesTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8) {
blockTxs := block.Transactions()
if tx := TxhashInSlice(blockTxs, txHash); tx != nil {
return tx.Index(), tx.Tree()
}
return -1, -1
} | [
"func",
"IncludesTx",
"(",
"txHash",
"*",
"chainhash",
".",
"Hash",
",",
"block",
"*",
"dcrutil",
".",
"Block",
")",
"(",
"int",
",",
"int8",
")",
"{",
"blockTxs",
":=",
"block",
".",
"Transactions",
"(",
")",
"\n\n",
"if",
"tx",
":=",
"TxhashInSlice",... | // IncludesTx checks if a block contains a transaction hash | [
"IncludesTx",
"checks",
"if",
"a",
"block",
"contains",
"a",
"transaction",
"hash"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L136-L143 |
142,373 | decred/dcrdata | txhelpers/txhelpers.go | Update | func (a *AddressOutpoints) Update(txns []*TxWithBlockData,
outpoints []*wire.OutPoint, prevOutpoint []PrevOut) {
// Relevant outpoints
a.Outpoints = append(a.Outpoints, outpoints...)
// Previous outpoints (inputs)
a.PrevOuts = append(a.PrevOuts, prevOutpoint...)
// Referenced transactions
for _, t := range txn... | go | func (a *AddressOutpoints) Update(txns []*TxWithBlockData,
outpoints []*wire.OutPoint, prevOutpoint []PrevOut) {
// Relevant outpoints
a.Outpoints = append(a.Outpoints, outpoints...)
// Previous outpoints (inputs)
a.PrevOuts = append(a.PrevOuts, prevOutpoint...)
// Referenced transactions
for _, t := range txn... | [
"func",
"(",
"a",
"*",
"AddressOutpoints",
")",
"Update",
"(",
"txns",
"[",
"]",
"*",
"TxWithBlockData",
",",
"outpoints",
"[",
"]",
"*",
"wire",
".",
"OutPoint",
",",
"prevOutpoint",
"[",
"]",
"PrevOut",
")",
"{",
"// Relevant outpoints",
"a",
".",
"Out... | // Update appends the provided outpoints, and merges the transactions. | [
"Update",
"appends",
"the",
"provided",
"outpoints",
"and",
"merges",
"the",
"transactions",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L209-L221 |
142,374 | decred/dcrdata | txhelpers/txhelpers.go | Merge | func (a *AddressOutpoints) Merge(ao *AddressOutpoints) {
// Relevant outpoints
a.Outpoints = append(a.Outpoints, ao.Outpoints...)
// Previous outpoints (inputs)
a.PrevOuts = append(a.PrevOuts, ao.PrevOuts...)
// Referenced transactions
for h, t := range ao.TxnsStore {
a.TxnsStore[h] = t
}
} | go | func (a *AddressOutpoints) Merge(ao *AddressOutpoints) {
// Relevant outpoints
a.Outpoints = append(a.Outpoints, ao.Outpoints...)
// Previous outpoints (inputs)
a.PrevOuts = append(a.PrevOuts, ao.PrevOuts...)
// Referenced transactions
for h, t := range ao.TxnsStore {
a.TxnsStore[h] = t
}
} | [
"func",
"(",
"a",
"*",
"AddressOutpoints",
")",
"Merge",
"(",
"ao",
"*",
"AddressOutpoints",
")",
"{",
"// Relevant outpoints",
"a",
".",
"Outpoints",
"=",
"append",
"(",
"a",
".",
"Outpoints",
",",
"ao",
".",
"Outpoints",
"...",
")",
"\n\n",
"// Previous ... | // Merge concatenates the outpoints of two AddressOutpoints, and merges the
// transactions. | [
"Merge",
"concatenates",
"the",
"outpoints",
"of",
"two",
"AddressOutpoints",
"and",
"merges",
"the",
"transactions",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L225-L236 |
142,375 | decred/dcrdata | txhelpers/txhelpers.go | TxInvolvesAddress | func TxInvolvesAddress(msgTx *wire.MsgTx, addr string, c VerboseTransactionGetter,
params *chaincfg.Params) (outpoints []*wire.OutPoint,
prevOuts []PrevOut, prevTxs []*TxWithBlockData) {
// The outpoints of this transaction paying to the address
outpoints = TxPaysToAddress(msgTx, addr, params)
// The inputs of thi... | go | func TxInvolvesAddress(msgTx *wire.MsgTx, addr string, c VerboseTransactionGetter,
params *chaincfg.Params) (outpoints []*wire.OutPoint,
prevOuts []PrevOut, prevTxs []*TxWithBlockData) {
// The outpoints of this transaction paying to the address
outpoints = TxPaysToAddress(msgTx, addr, params)
// The inputs of thi... | [
"func",
"TxInvolvesAddress",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
",",
"addr",
"string",
",",
"c",
"VerboseTransactionGetter",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"outpoints",
"[",
"]",
"*",
"wire",
".",
"OutPoint",
",",
"prevOuts"... | // TxInvolvesAddress checks the inputs and outputs of a transaction for
// involvement of the given address. | [
"TxInvolvesAddress",
"checks",
"the",
"inputs",
"and",
"outputs",
"of",
"a",
"transaction",
"for",
"involvement",
"of",
"the",
"given",
"address",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L240-L249 |
142,376 | decred/dcrdata | txhelpers/txhelpers.go | TxOutpointsByAddr | func TxOutpointsByAddr(txAddrOuts MempoolAddressStore, msgTx *wire.MsgTx, params *chaincfg.Params) (newOuts int, addrs map[string]bool) {
if txAddrOuts == nil {
panic("TxAddressOutpoints: input map must be initialized: map[string]*AddressOutpoints")
}
// Check the addresses associated with the PkScript of each Tx... | go | func TxOutpointsByAddr(txAddrOuts MempoolAddressStore, msgTx *wire.MsgTx, params *chaincfg.Params) (newOuts int, addrs map[string]bool) {
if txAddrOuts == nil {
panic("TxAddressOutpoints: input map must be initialized: map[string]*AddressOutpoints")
}
// Check the addresses associated with the PkScript of each Tx... | [
"func",
"TxOutpointsByAddr",
"(",
"txAddrOuts",
"MempoolAddressStore",
",",
"msgTx",
"*",
"wire",
".",
"MsgTx",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"newOuts",
"int",
",",
"addrs",
"map",
"[",
"string",
"]",
"bool",
")",
"{",
"if",
"t... | // TxOutpointsByAddr sets the Outpoints field for the AddressOutpoints stored in
// the input MempoolAddressStore. For addresses not yet present in the
// MempoolAddressStore, a new AddressOutpoints is added to the store. The
// provided MempoolAddressStore must be initialized. The number of msgTx outputs
// that pay t... | [
"TxOutpointsByAddr",
"sets",
"the",
"Outpoints",
"field",
"for",
"the",
"AddressOutpoints",
"stored",
"in",
"the",
"input",
"MempoolAddressStore",
".",
"For",
"addresses",
"not",
"yet",
"present",
"in",
"the",
"MempoolAddressStore",
"a",
"new",
"AddressOutpoints",
"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L264-L308 |
142,377 | decred/dcrdata | txhelpers/txhelpers.go | TxPrevOutsByAddr | func TxPrevOutsByAddr(txAddrOuts MempoolAddressStore, txnsStore TxnsStore, msgTx *wire.MsgTx, c VerboseTransactionGetter, params *chaincfg.Params) (newPrevOuts int, addrs map[string]bool) {
if txAddrOuts == nil {
panic("TxPrevOutAddresses: input map must be initialized: map[string]*AddressOutpoints")
}
if txnsStor... | go | func TxPrevOutsByAddr(txAddrOuts MempoolAddressStore, txnsStore TxnsStore, msgTx *wire.MsgTx, c VerboseTransactionGetter, params *chaincfg.Params) (newPrevOuts int, addrs map[string]bool) {
if txAddrOuts == nil {
panic("TxPrevOutAddresses: input map must be initialized: map[string]*AddressOutpoints")
}
if txnsStor... | [
"func",
"TxPrevOutsByAddr",
"(",
"txAddrOuts",
"MempoolAddressStore",
",",
"txnsStore",
"TxnsStore",
",",
"msgTx",
"*",
"wire",
".",
"MsgTx",
",",
"c",
"VerboseTransactionGetter",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"newPrevOuts",
"int",
","... | // TxPrevOutsByAddr sets the PrevOuts field for the AddressOutpoints stored in
// the MempoolAddressStore. For addresses not yet present in the
// MempoolAddressStore, a new AddressOutpoints is added to the store. The
// provided MempoolAddressStore must be initialized. A VerboseTransactionGetter
// is required to retr... | [
"TxPrevOutsByAddr",
"sets",
"the",
"PrevOuts",
"field",
"for",
"the",
"AddressOutpoints",
"stored",
"in",
"the",
"MempoolAddressStore",
".",
"For",
"addresses",
"not",
"yet",
"present",
"in",
"the",
"MempoolAddressStore",
"a",
"new",
"AddressOutpoints",
"is",
"added... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L319-L436 |
142,378 | decred/dcrdata | txhelpers/txhelpers.go | TxConsumesOutpointWithAddress | func TxConsumesOutpointWithAddress(msgTx *wire.MsgTx, addr string,
c VerboseTransactionGetter, params *chaincfg.Params) (prevOuts []PrevOut, prevTxs []*TxWithBlockData) {
// Send all the raw transaction requests
type promiseGetRawTransaction struct {
result rpcclient.FutureGetRawTransactionVerboseResult
inIdx i... | go | func TxConsumesOutpointWithAddress(msgTx *wire.MsgTx, addr string,
c VerboseTransactionGetter, params *chaincfg.Params) (prevOuts []PrevOut, prevTxs []*TxWithBlockData) {
// Send all the raw transaction requests
type promiseGetRawTransaction struct {
result rpcclient.FutureGetRawTransactionVerboseResult
inIdx i... | [
"func",
"TxConsumesOutpointWithAddress",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
",",
"addr",
"string",
",",
"c",
"VerboseTransactionGetter",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"prevOuts",
"[",
"]",
"PrevOut",
",",
"prevTxs",
"[",
"]",... | // TxConsumesOutpointWithAddress checks a transaction for inputs that spend an
// outpoint paying to the given address. Returned are the identified input
// indexes and the corresponding previous outpoints determined. | [
"TxConsumesOutpointWithAddress",
"checks",
"a",
"transaction",
"for",
"inputs",
"that",
"spend",
"an",
"outpoint",
"paying",
"to",
"the",
"given",
"address",
".",
"Returned",
"are",
"the",
"identified",
"input",
"indexes",
"and",
"the",
"corresponding",
"previous",
... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L441-L518 |
142,379 | decred/dcrdata | txhelpers/txhelpers.go | BlockConsumesOutpointWithAddresses | func BlockConsumesOutpointWithAddresses(block *dcrutil.Block, addrs map[string]TxAction,
c RawTransactionGetter, params *chaincfg.Params) map[string][]*dcrutil.Tx {
addrMap := make(map[string][]*dcrutil.Tx)
checkForOutpointAddr := func(blockTxs []*dcrutil.Tx) {
for _, tx := range blockTxs {
for _, txIn := rang... | go | func BlockConsumesOutpointWithAddresses(block *dcrutil.Block, addrs map[string]TxAction,
c RawTransactionGetter, params *chaincfg.Params) map[string][]*dcrutil.Tx {
addrMap := make(map[string][]*dcrutil.Tx)
checkForOutpointAddr := func(blockTxs []*dcrutil.Tx) {
for _, tx := range blockTxs {
for _, txIn := rang... | [
"func",
"BlockConsumesOutpointWithAddresses",
"(",
"block",
"*",
"dcrutil",
".",
"Block",
",",
"addrs",
"map",
"[",
"string",
"]",
"TxAction",
",",
"c",
"RawTransactionGetter",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"map",
"[",
"string",
"]",
"[... | // BlockConsumesOutpointWithAddresses checks the specified block to see if it
// includes transactions that spend from outputs created using any of the
// addresses in addrs. The TxAction for each address is not important, but it
// would logically be TxMined. Both regular and stake transactions are checked.
// The RPC... | [
"BlockConsumesOutpointWithAddresses",
"checks",
"the",
"specified",
"block",
"to",
"see",
"if",
"it",
"includes",
"transactions",
"that",
"spend",
"from",
"outputs",
"created",
"using",
"any",
"of",
"the",
"addresses",
"in",
"addrs",
".",
"The",
"TxAction",
"for",... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L527-L574 |
142,380 | decred/dcrdata | txhelpers/txhelpers.go | TxPaysToAddress | func TxPaysToAddress(msgTx *wire.MsgTx, addr string,
params *chaincfg.Params) (outpoints []*wire.OutPoint) {
// Check the addresses associated with the PkScript of each TxOut
txTree := TxTree(msgTx)
hash := msgTx.TxHash()
for outIndex, txOut := range msgTx.TxOut {
_, txOutAddrs, _, err := txscript.ExtractPkScrip... | go | func TxPaysToAddress(msgTx *wire.MsgTx, addr string,
params *chaincfg.Params) (outpoints []*wire.OutPoint) {
// Check the addresses associated with the PkScript of each TxOut
txTree := TxTree(msgTx)
hash := msgTx.TxHash()
for outIndex, txOut := range msgTx.TxOut {
_, txOutAddrs, _, err := txscript.ExtractPkScrip... | [
"func",
"TxPaysToAddress",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
",",
"addr",
"string",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"outpoints",
"[",
"]",
"*",
"wire",
".",
"OutPoint",
")",
"{",
"// Check the addresses associated with the PkScr... | // TxPaysToAddress returns a slice of outpoints of a transaction which pay to
// specified address. | [
"TxPaysToAddress",
"returns",
"a",
"slice",
"of",
"outpoints",
"of",
"a",
"transaction",
"which",
"pay",
"to",
"specified",
"address",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L578-L601 |
142,381 | decred/dcrdata | txhelpers/txhelpers.go | BlockReceivesToAddresses | func BlockReceivesToAddresses(block *dcrutil.Block, addrs map[string]TxAction,
params *chaincfg.Params) map[string][]*dcrutil.Tx {
addrMap := make(map[string][]*dcrutil.Tx)
checkForAddrOut := func(blockTxs []*dcrutil.Tx) {
for _, tx := range blockTxs {
// Check the addresses associated with the PkScript of eac... | go | func BlockReceivesToAddresses(block *dcrutil.Block, addrs map[string]TxAction,
params *chaincfg.Params) map[string][]*dcrutil.Tx {
addrMap := make(map[string][]*dcrutil.Tx)
checkForAddrOut := func(blockTxs []*dcrutil.Tx) {
for _, tx := range blockTxs {
// Check the addresses associated with the PkScript of eac... | [
"func",
"BlockReceivesToAddresses",
"(",
"block",
"*",
"dcrutil",
".",
"Block",
",",
"addrs",
"map",
"[",
"string",
"]",
"TxAction",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"*",
"dcrutil",
".",
"Tx",
"{"... | // BlockReceivesToAddresses checks a block for transactions paying to the
// specified addresses, and creates a map of addresses to a slice of dcrutil.Tx
// involving the address. | [
"BlockReceivesToAddresses",
"checks",
"a",
"block",
"for",
"transactions",
"paying",
"to",
"the",
"specified",
"addresses",
"and",
"creates",
"a",
"map",
"of",
"addresses",
"to",
"a",
"slice",
"of",
"dcrutil",
".",
"Tx",
"involving",
"the",
"address",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L606-L639 |
142,382 | decred/dcrdata | txhelpers/txhelpers.go | OutPointAddresses | func OutPointAddresses(outPoint *wire.OutPoint, c RawTransactionGetter,
params *chaincfg.Params) ([]string, dcrutil.Amount, error) {
// The addresses are encoded in the pkScript, so we need to get the
// raw transaction, and the TxOut that contains the pkScript.
prevTx, err := c.GetRawTransaction(&outPoint.Hash)
i... | go | func OutPointAddresses(outPoint *wire.OutPoint, c RawTransactionGetter,
params *chaincfg.Params) ([]string, dcrutil.Amount, error) {
// The addresses are encoded in the pkScript, so we need to get the
// raw transaction, and the TxOut that contains the pkScript.
prevTx, err := c.GetRawTransaction(&outPoint.Hash)
i... | [
"func",
"OutPointAddresses",
"(",
"outPoint",
"*",
"wire",
".",
"OutPoint",
",",
"c",
"RawTransactionGetter",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"[",
"]",
"string",
",",
"dcrutil",
".",
"Amount",
",",
"error",
")",
"{",
"// The addres... | // OutPointAddresses gets the addresses paid to by a transaction output. | [
"OutPointAddresses",
"gets",
"the",
"addresses",
"paid",
"to",
"by",
"a",
"transaction",
"output",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L642-L671 |
142,383 | decred/dcrdata | txhelpers/txhelpers.go | OutPointAddressesFromString | func OutPointAddressesFromString(txid string, index uint32, tree int8,
c RawTransactionGetter, params *chaincfg.Params) ([]string, error) {
hash, err := chainhash.NewHashFromStr(txid)
if err != nil {
return nil, fmt.Errorf("Invalid hash %s", txid)
}
outPoint := wire.NewOutPoint(hash, index, tree)
outPointAddre... | go | func OutPointAddressesFromString(txid string, index uint32, tree int8,
c RawTransactionGetter, params *chaincfg.Params) ([]string, error) {
hash, err := chainhash.NewHashFromStr(txid)
if err != nil {
return nil, fmt.Errorf("Invalid hash %s", txid)
}
outPoint := wire.NewOutPoint(hash, index, tree)
outPointAddre... | [
"func",
"OutPointAddressesFromString",
"(",
"txid",
"string",
",",
"index",
"uint32",
",",
"tree",
"int8",
",",
"c",
"RawTransactionGetter",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"hash",
",",
... | // OutPointAddressesFromString is the same as OutPointAddresses, but it takes
// the outpoint as the tx string, vout index, and tree. | [
"OutPointAddressesFromString",
"is",
"the",
"same",
"as",
"OutPointAddresses",
"but",
"it",
"takes",
"the",
"outpoint",
"as",
"the",
"tx",
"string",
"vout",
"index",
"and",
"tree",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L675-L685 |
142,384 | decred/dcrdata | txhelpers/txhelpers.go | MedianAmount | func MedianAmount(s []dcrutil.Amount) dcrutil.Amount {
if len(s) == 0 {
return 0
}
sort.Sort(dcrutil.AmountSorter(s))
middle := len(s) / 2
if len(s) == 0 {
return 0
} else if (len(s) % 2) != 0 {
return s[middle]
}
return (s[middle] + s[middle-1]) / 2
} | go | func MedianAmount(s []dcrutil.Amount) dcrutil.Amount {
if len(s) == 0 {
return 0
}
sort.Sort(dcrutil.AmountSorter(s))
middle := len(s) / 2
if len(s) == 0 {
return 0
} else if (len(s) % 2) != 0 {
return s[middle]
}
return (s[middle] + s[middle-1]) / 2
} | [
"func",
"MedianAmount",
"(",
"s",
"[",
"]",
"dcrutil",
".",
"Amount",
")",
"dcrutil",
".",
"Amount",
"{",
"if",
"len",
"(",
"s",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"sort",
".",
"Sort",
"(",
"dcrutil",
".",
"AmountSorter",
"(",
... | // MedianAmount gets the median Amount from a slice of Amounts | [
"MedianAmount",
"gets",
"the",
"median",
"Amount",
"from",
"a",
"slice",
"of",
"Amounts"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L688-L703 |
142,385 | decred/dcrdata | txhelpers/txhelpers.go | MedianCoin | func MedianCoin(s []float64) float64 {
if len(s) == 0 {
return 0
}
sort.Float64s(s)
middle := len(s) / 2
if len(s) == 0 {
return 0
} else if (len(s) % 2) != 0 {
return s[middle]
}
return (s[middle] + s[middle-1]) / 2
} | go | func MedianCoin(s []float64) float64 {
if len(s) == 0 {
return 0
}
sort.Float64s(s)
middle := len(s) / 2
if len(s) == 0 {
return 0
} else if (len(s) % 2) != 0 {
return s[middle]
}
return (s[middle] + s[middle-1]) / 2
} | [
"func",
"MedianCoin",
"(",
"s",
"[",
"]",
"float64",
")",
"float64",
"{",
"if",
"len",
"(",
"s",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"sort",
".",
"Float64s",
"(",
"s",
")",
"\n\n",
"middle",
":=",
"len",
"(",
"s",
")",
"/",
... | // MedianCoin gets the median DCR from a slice of float64s | [
"MedianCoin",
"gets",
"the",
"median",
"DCR",
"from",
"a",
"slice",
"of",
"float64s"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L706-L721 |
142,386 | decred/dcrdata | txhelpers/txhelpers.go | GetDifficultyRatio | func GetDifficultyRatio(bits uint32, params *chaincfg.Params) float64 {
// The minimum difficulty is the max possible proof-of-work limit bits
// converted back to a number. Note this is not the same as the proof of
// work limit directly because the block difficulty is encoded in a block
// with the compact form ... | go | func GetDifficultyRatio(bits uint32, params *chaincfg.Params) float64 {
// The minimum difficulty is the max possible proof-of-work limit bits
// converted back to a number. Note this is not the same as the proof of
// work limit directly because the block difficulty is encoded in a block
// with the compact form ... | [
"func",
"GetDifficultyRatio",
"(",
"bits",
"uint32",
",",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"float64",
"{",
"// The minimum difficulty is the max possible proof-of-work limit bits",
"// converted back to a number. Note this is not the same as the proof of",
"// work lim... | // GetDifficultyRatio returns the proof-of-work difficulty as a multiple of the
// minimum difficulty using the passed bits field from the header of a block. | [
"GetDifficultyRatio",
"returns",
"the",
"proof",
"-",
"of",
"-",
"work",
"difficulty",
"as",
"a",
"multiple",
"of",
"the",
"minimum",
"difficulty",
"using",
"the",
"passed",
"bits",
"field",
"from",
"the",
"header",
"of",
"a",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L725-L741 |
142,387 | decred/dcrdata | txhelpers/txhelpers.go | SSTXInBlock | func SSTXInBlock(block *dcrutil.Block) []*dcrutil.Tx {
_, txns := TicketTxnsInBlock(block)
return txns
} | go | func SSTXInBlock(block *dcrutil.Block) []*dcrutil.Tx {
_, txns := TicketTxnsInBlock(block)
return txns
} | [
"func",
"SSTXInBlock",
"(",
"block",
"*",
"dcrutil",
".",
"Block",
")",
"[",
"]",
"*",
"dcrutil",
".",
"Tx",
"{",
"_",
",",
"txns",
":=",
"TicketTxnsInBlock",
"(",
"block",
")",
"\n",
"return",
"txns",
"\n",
"}"
] | // SSTXInBlock gets a slice containing all of the SSTX mined in a block | [
"SSTXInBlock",
"gets",
"a",
"slice",
"containing",
"all",
"of",
"the",
"SSTX",
"mined",
"in",
"a",
"block"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L744-L747 |
142,388 | decred/dcrdata | txhelpers/txhelpers.go | VoteBitsInBlock | func VoteBitsInBlock(block *dcrutil.Block) []stake.VoteVersionTuple {
var voteBits []stake.VoteVersionTuple
for _, stx := range block.MsgBlock().STransactions {
if !stake.IsSSGen(stx) {
continue
}
voteBits = append(voteBits, stake.VoteVersionTuple{
Version: stake.SSGenVersion(stx),
Bits: stake.SSGe... | go | func VoteBitsInBlock(block *dcrutil.Block) []stake.VoteVersionTuple {
var voteBits []stake.VoteVersionTuple
for _, stx := range block.MsgBlock().STransactions {
if !stake.IsSSGen(stx) {
continue
}
voteBits = append(voteBits, stake.VoteVersionTuple{
Version: stake.SSGenVersion(stx),
Bits: stake.SSGe... | [
"func",
"VoteBitsInBlock",
"(",
"block",
"*",
"dcrutil",
".",
"Block",
")",
"[",
"]",
"stake",
".",
"VoteVersionTuple",
"{",
"var",
"voteBits",
"[",
"]",
"stake",
".",
"VoteVersionTuple",
"\n",
"for",
"_",
",",
"stx",
":=",
"range",
"block",
".",
"MsgBlo... | // VoteBitsInBlock returns a list of vote bits for the votes in a block | [
"VoteBitsInBlock",
"returns",
"a",
"list",
"of",
"vote",
"bits",
"for",
"the",
"votes",
"in",
"a",
"block"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L769-L783 |
142,389 | decred/dcrdata | txhelpers/txhelpers.go | VoteVersion | func VoteVersion(pkScript []byte) uint32 {
if len(pkScript) < 8 {
return stake.VoteConsensusVersionAbsent
}
return binary.LittleEndian.Uint32(pkScript[4:8])
} | go | func VoteVersion(pkScript []byte) uint32 {
if len(pkScript) < 8 {
return stake.VoteConsensusVersionAbsent
}
return binary.LittleEndian.Uint32(pkScript[4:8])
} | [
"func",
"VoteVersion",
"(",
"pkScript",
"[",
"]",
"byte",
")",
"uint32",
"{",
"if",
"len",
"(",
"pkScript",
")",
"<",
"8",
"{",
"return",
"stake",
".",
"VoteConsensusVersionAbsent",
"\n",
"}",
"\n\n",
"return",
"binary",
".",
"LittleEndian",
".",
"Uint32",... | // VoteVersion extracts the vote version from the input pubkey script. | [
"VoteVersion",
"extracts",
"the",
"vote",
"version",
"from",
"the",
"input",
"pubkey",
"script",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L840-L846 |
142,390 | decred/dcrdata | txhelpers/txhelpers.go | FeeInfoBlock | func FeeInfoBlock(block *dcrutil.Block) *dcrjson.FeeInfoBlock {
feeInfo := new(dcrjson.FeeInfoBlock)
_, sstxMsgTxns := TicketsInBlock(block)
feeInfo.Height = uint32(block.Height())
feeInfo.Number = uint32(len(sstxMsgTxns))
var minFee, maxFee, meanFee float64
minFee = math.MaxFloat64
fees := make([]float64, fee... | go | func FeeInfoBlock(block *dcrutil.Block) *dcrjson.FeeInfoBlock {
feeInfo := new(dcrjson.FeeInfoBlock)
_, sstxMsgTxns := TicketsInBlock(block)
feeInfo.Height = uint32(block.Height())
feeInfo.Number = uint32(len(sstxMsgTxns))
var minFee, maxFee, meanFee float64
minFee = math.MaxFloat64
fees := make([]float64, fee... | [
"func",
"FeeInfoBlock",
"(",
"block",
"*",
"dcrutil",
".",
"Block",
")",
"*",
"dcrjson",
".",
"FeeInfoBlock",
"{",
"feeInfo",
":=",
"new",
"(",
"dcrjson",
".",
"FeeInfoBlock",
")",
"\n",
"_",
",",
"sstxMsgTxns",
":=",
"TicketsInBlock",
"(",
"block",
")",
... | // FeeInfoBlock computes ticket fee statistics for the tickets included in the
// specified block. | [
"FeeInfoBlock",
"computes",
"ticket",
"fee",
"statistics",
"for",
"the",
"tickets",
"included",
"in",
"the",
"specified",
"block",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L889-L938 |
142,391 | decred/dcrdata | txhelpers/txhelpers.go | MsgTxFromHex | func MsgTxFromHex(txhex string) (*wire.MsgTx, error) {
msgTx := wire.NewMsgTx()
if err := msgTx.Deserialize(hex.NewDecoder(strings.NewReader(txhex))); err != nil {
return nil, err
}
return msgTx, nil
} | go | func MsgTxFromHex(txhex string) (*wire.MsgTx, error) {
msgTx := wire.NewMsgTx()
if err := msgTx.Deserialize(hex.NewDecoder(strings.NewReader(txhex))); err != nil {
return nil, err
}
return msgTx, nil
} | [
"func",
"MsgTxFromHex",
"(",
"txhex",
"string",
")",
"(",
"*",
"wire",
".",
"MsgTx",
",",
"error",
")",
"{",
"msgTx",
":=",
"wire",
".",
"NewMsgTx",
"(",
")",
"\n",
"if",
"err",
":=",
"msgTx",
".",
"Deserialize",
"(",
"hex",
".",
"NewDecoder",
"(",
... | // MsgTxFromHex returns a wire.MsgTx struct built from the transaction hex string. | [
"MsgTxFromHex",
"returns",
"a",
"wire",
".",
"MsgTx",
"struct",
"built",
"from",
"the",
"transaction",
"hex",
"string",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L993-L999 |
142,392 | decred/dcrdata | txhelpers/txhelpers.go | DetermineTxTypeString | func DetermineTxTypeString(msgTx *wire.MsgTx) string {
switch stake.DetermineTxType(msgTx) {
case stake.TxTypeSSGen:
return "Vote"
case stake.TxTypeSStx:
return "Ticket"
case stake.TxTypeSSRtx:
return "Revocation"
default:
return "Regular"
}
} | go | func DetermineTxTypeString(msgTx *wire.MsgTx) string {
switch stake.DetermineTxType(msgTx) {
case stake.TxTypeSSGen:
return "Vote"
case stake.TxTypeSStx:
return "Ticket"
case stake.TxTypeSSRtx:
return "Revocation"
default:
return "Regular"
}
} | [
"func",
"DetermineTxTypeString",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
")",
"string",
"{",
"switch",
"stake",
".",
"DetermineTxType",
"(",
"msgTx",
")",
"{",
"case",
"stake",
".",
"TxTypeSSGen",
":",
"return",
"\"",
"\"",
"\n",
"case",
"stake",
".",
"... | // DetermineTxTypeString returns a string representing the transaction type given
// a wire.MsgTx struct | [
"DetermineTxTypeString",
"returns",
"a",
"string",
"representing",
"the",
"transaction",
"type",
"given",
"a",
"wire",
".",
"MsgTx",
"struct"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L1003-L1014 |
142,393 | decred/dcrdata | txhelpers/txhelpers.go | TxTypeToString | func TxTypeToString(txType int) string {
switch stake.TxType(txType) {
case stake.TxTypeSSGen:
return "Vote"
case stake.TxTypeSStx:
return "Ticket"
case stake.TxTypeSSRtx:
return "Revocation"
default:
return "Regular"
}
} | go | func TxTypeToString(txType int) string {
switch stake.TxType(txType) {
case stake.TxTypeSSGen:
return "Vote"
case stake.TxTypeSStx:
return "Ticket"
case stake.TxTypeSSRtx:
return "Revocation"
default:
return "Regular"
}
} | [
"func",
"TxTypeToString",
"(",
"txType",
"int",
")",
"string",
"{",
"switch",
"stake",
".",
"TxType",
"(",
"txType",
")",
"{",
"case",
"stake",
".",
"TxTypeSSGen",
":",
"return",
"\"",
"\"",
"\n",
"case",
"stake",
".",
"TxTypeSStx",
":",
"return",
"\"",
... | // TxTypeToString returns a string representation of the provided transaction
// type, which corresponds to the txn types defined for stake.TxType type. | [
"TxTypeToString",
"returns",
"a",
"string",
"representation",
"of",
"the",
"provided",
"transaction",
"type",
"which",
"corresponds",
"to",
"the",
"txn",
"types",
"defined",
"for",
"stake",
".",
"TxType",
"type",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L1018-L1029 |
142,394 | decred/dcrdata | txhelpers/txhelpers.go | IsStakeTx | func IsStakeTx(msgTx *wire.MsgTx) bool {
switch stake.DetermineTxType(msgTx) {
case stake.TxTypeSSGen:
fallthrough
case stake.TxTypeSStx:
fallthrough
case stake.TxTypeSSRtx:
return true
default:
return false
}
} | go | func IsStakeTx(msgTx *wire.MsgTx) bool {
switch stake.DetermineTxType(msgTx) {
case stake.TxTypeSSGen:
fallthrough
case stake.TxTypeSStx:
fallthrough
case stake.TxTypeSSRtx:
return true
default:
return false
}
} | [
"func",
"IsStakeTx",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
")",
"bool",
"{",
"switch",
"stake",
".",
"DetermineTxType",
"(",
"msgTx",
")",
"{",
"case",
"stake",
".",
"TxTypeSSGen",
":",
"fallthrough",
"\n",
"case",
"stake",
".",
"TxTypeSStx",
":",
"fa... | // IsStakeTx indicates if the input MsgTx is a stake transaction. | [
"IsStakeTx",
"indicates",
"if",
"the",
"input",
"MsgTx",
"is",
"a",
"stake",
"transaction",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L1053-L1064 |
142,395 | decred/dcrdata | txhelpers/txhelpers.go | TxTree | func TxTree(msgTx *wire.MsgTx) int8 {
if IsStakeTx(msgTx) {
return wire.TxTreeStake
}
return wire.TxTreeRegular
} | go | func TxTree(msgTx *wire.MsgTx) int8 {
if IsStakeTx(msgTx) {
return wire.TxTreeStake
}
return wire.TxTreeRegular
} | [
"func",
"TxTree",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
")",
"int8",
"{",
"if",
"IsStakeTx",
"(",
"msgTx",
")",
"{",
"return",
"wire",
".",
"TxTreeStake",
"\n",
"}",
"\n",
"return",
"wire",
".",
"TxTreeRegular",
"\n",
"}"
] | // TxTree returns for a wire.MsgTx either wire.TxTreeStake or wire.TxTreeRegular
// depending on the type of transaction. | [
"TxTree",
"returns",
"for",
"a",
"wire",
".",
"MsgTx",
"either",
"wire",
".",
"TxTreeStake",
"or",
"wire",
".",
"TxTreeRegular",
"depending",
"on",
"the",
"type",
"of",
"transaction",
"."
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L1068-L1073 |
142,396 | decred/dcrdata | txhelpers/txhelpers.go | TxFee | func TxFee(msgTx *wire.MsgTx) dcrutil.Amount {
var amtIn int64
for iv := range msgTx.TxIn {
amtIn += msgTx.TxIn[iv].ValueIn
}
var amtOut int64
for iv := range msgTx.TxOut {
amtOut += msgTx.TxOut[iv].Value
}
return dcrutil.Amount(amtIn - amtOut)
} | go | func TxFee(msgTx *wire.MsgTx) dcrutil.Amount {
var amtIn int64
for iv := range msgTx.TxIn {
amtIn += msgTx.TxIn[iv].ValueIn
}
var amtOut int64
for iv := range msgTx.TxOut {
amtOut += msgTx.TxOut[iv].Value
}
return dcrutil.Amount(amtIn - amtOut)
} | [
"func",
"TxFee",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
")",
"dcrutil",
".",
"Amount",
"{",
"var",
"amtIn",
"int64",
"\n",
"for",
"iv",
":=",
"range",
"msgTx",
".",
"TxIn",
"{",
"amtIn",
"+=",
"msgTx",
".",
"TxIn",
"[",
"iv",
"]",
".",
"ValueIn",... | // TxFee computes and returns the fee for a given tx | [
"TxFee",
"computes",
"and",
"returns",
"the",
"fee",
"for",
"a",
"given",
"tx"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L1076-L1086 |
142,397 | decred/dcrdata | txhelpers/txhelpers.go | TotalOutFromMsgTx | func TotalOutFromMsgTx(msgTx *wire.MsgTx) dcrutil.Amount {
var amtOut int64
for _, v := range msgTx.TxOut {
amtOut += v.Value
}
return dcrutil.Amount(amtOut)
} | go | func TotalOutFromMsgTx(msgTx *wire.MsgTx) dcrutil.Amount {
var amtOut int64
for _, v := range msgTx.TxOut {
amtOut += v.Value
}
return dcrutil.Amount(amtOut)
} | [
"func",
"TotalOutFromMsgTx",
"(",
"msgTx",
"*",
"wire",
".",
"MsgTx",
")",
"dcrutil",
".",
"Amount",
"{",
"var",
"amtOut",
"int64",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"msgTx",
".",
"TxOut",
"{",
"amtOut",
"+=",
"v",
".",
"Value",
"\n",
"}",
... | // TotalOutFromMsgTx computes the total value out of a MsgTx | [
"TotalOutFromMsgTx",
"computes",
"the",
"total",
"value",
"out",
"of",
"a",
"MsgTx"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L1115-L1121 |
142,398 | decred/dcrdata | txhelpers/txhelpers.go | TotalVout | func TotalVout(vouts []dcrjson.Vout) dcrutil.Amount {
var total dcrutil.Amount
for _, v := range vouts {
a, err := dcrutil.NewAmount(v.Value)
if err != nil {
continue
}
total += a
}
return total
} | go | func TotalVout(vouts []dcrjson.Vout) dcrutil.Amount {
var total dcrutil.Amount
for _, v := range vouts {
a, err := dcrutil.NewAmount(v.Value)
if err != nil {
continue
}
total += a
}
return total
} | [
"func",
"TotalVout",
"(",
"vouts",
"[",
"]",
"dcrjson",
".",
"Vout",
")",
"dcrutil",
".",
"Amount",
"{",
"var",
"total",
"dcrutil",
".",
"Amount",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"vouts",
"{",
"a",
",",
"err",
":=",
"dcrutil",
".",
"NewA... | // TotalVout computes the total value of a slice of dcrjson.Vout | [
"TotalVout",
"computes",
"the",
"total",
"value",
"of",
"a",
"slice",
"of",
"dcrjson",
".",
"Vout"
] | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L1124-L1134 |
142,399 | decred/dcrdata | txhelpers/txhelpers.go | GenesisTxHash | func GenesisTxHash(params *chaincfg.Params) chainhash.Hash {
return params.GenesisBlock.Transactions[0].TxHash()
} | go | func GenesisTxHash(params *chaincfg.Params) chainhash.Hash {
return params.GenesisBlock.Transactions[0].TxHash()
} | [
"func",
"GenesisTxHash",
"(",
"params",
"*",
"chaincfg",
".",
"Params",
")",
"chainhash",
".",
"Hash",
"{",
"return",
"params",
".",
"GenesisBlock",
".",
"Transactions",
"[",
"0",
"]",
".",
"TxHash",
"(",
")",
"\n",
"}"
] | // GenesisTxHash returns the hash of the single coinbase transaction in the
// genesis block of the specified network. This transaction is hard coded, and
// the pubkey script for its one output only decodes for simnet. | [
"GenesisTxHash",
"returns",
"the",
"hash",
"of",
"the",
"single",
"coinbase",
"transaction",
"in",
"the",
"genesis",
"block",
"of",
"the",
"specified",
"network",
".",
"This",
"transaction",
"is",
"hard",
"coded",
"and",
"the",
"pubkey",
"script",
"for",
"its"... | 02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6 | https://github.com/decred/dcrdata/blob/02d6f8e648f7e2c5cf78ea92fb17b1d4aa4a99f6/txhelpers/txhelpers.go#L1139-L1141 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.