id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
163,500 | btcsuite/btcd | blockchain/blockindex.go | Header | func (node *blockNode) Header() wire.BlockHeader {
// No lock is needed because all accessed fields are immutable.
prevHash := &zeroHash
if node.parent != nil {
prevHash = &node.parent.hash
}
return wire.BlockHeader{
Version: node.version,
PrevBlock: *prevHash,
MerkleRoot: node.merkleRoot,
Timestamp:... | go | func (node *blockNode) Header() wire.BlockHeader {
// No lock is needed because all accessed fields are immutable.
prevHash := &zeroHash
if node.parent != nil {
prevHash = &node.parent.hash
}
return wire.BlockHeader{
Version: node.version,
PrevBlock: *prevHash,
MerkleRoot: node.merkleRoot,
Timestamp:... | [
"func",
"(",
"node",
"*",
"blockNode",
")",
"Header",
"(",
")",
"wire",
".",
"BlockHeader",
"{",
"// No lock is needed because all accessed fields are immutable.",
"prevHash",
":=",
"&",
"zeroHash",
"\n",
"if",
"node",
".",
"parent",
"!=",
"nil",
"{",
"prevHash",
... | // Header constructs a block header from the node and returns it.
//
// This function is safe for concurrent access. | [
"Header",
"constructs",
"a",
"block",
"header",
"from",
"the",
"node",
"and",
"returns",
"it",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"access",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L137-L151 |
163,501 | btcsuite/btcd | blockchain/blockindex.go | Ancestor | func (node *blockNode) Ancestor(height int32) *blockNode {
if height < 0 || height > node.height {
return nil
}
n := node
for ; n != nil && n.height != height; n = n.parent {
// Intentionally left blank
}
return n
} | go | func (node *blockNode) Ancestor(height int32) *blockNode {
if height < 0 || height > node.height {
return nil
}
n := node
for ; n != nil && n.height != height; n = n.parent {
// Intentionally left blank
}
return n
} | [
"func",
"(",
"node",
"*",
"blockNode",
")",
"Ancestor",
"(",
"height",
"int32",
")",
"*",
"blockNode",
"{",
"if",
"height",
"<",
"0",
"||",
"height",
">",
"node",
".",
"height",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"n",
":=",
"node",
"\n",
"for... | // Ancestor returns the ancestor block node at the provided height by following
// the chain backwards from this node. The returned block will be nil when a
// height is requested that is after the height of the passed node or is less
// than zero.
//
// This function is safe for concurrent access. | [
"Ancestor",
"returns",
"the",
"ancestor",
"block",
"node",
"at",
"the",
"provided",
"height",
"by",
"following",
"the",
"chain",
"backwards",
"from",
"this",
"node",
".",
"The",
"returned",
"block",
"will",
"be",
"nil",
"when",
"a",
"height",
"is",
"requeste... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L159-L170 |
163,502 | btcsuite/btcd | blockchain/blockindex.go | RelativeAncestor | func (node *blockNode) RelativeAncestor(distance int32) *blockNode {
return node.Ancestor(node.height - distance)
} | go | func (node *blockNode) RelativeAncestor(distance int32) *blockNode {
return node.Ancestor(node.height - distance)
} | [
"func",
"(",
"node",
"*",
"blockNode",
")",
"RelativeAncestor",
"(",
"distance",
"int32",
")",
"*",
"blockNode",
"{",
"return",
"node",
".",
"Ancestor",
"(",
"node",
".",
"height",
"-",
"distance",
")",
"\n",
"}"
] | // RelativeAncestor returns the ancestor block node a relative 'distance' blocks
// before this node. This is equivalent to calling Ancestor with the node's
// height minus provided distance.
//
// This function is safe for concurrent access. | [
"RelativeAncestor",
"returns",
"the",
"ancestor",
"block",
"node",
"a",
"relative",
"distance",
"blocks",
"before",
"this",
"node",
".",
"This",
"is",
"equivalent",
"to",
"calling",
"Ancestor",
"with",
"the",
"node",
"s",
"height",
"minus",
"provided",
"distance... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L177-L179 |
163,503 | btcsuite/btcd | blockchain/blockindex.go | CalcPastMedianTime | func (node *blockNode) CalcPastMedianTime() time.Time {
// Create a slice of the previous few block timestamps used to calculate
// the median per the number defined by the constant medianTimeBlocks.
timestamps := make([]int64, medianTimeBlocks)
numNodes := 0
iterNode := node
for i := 0; i < medianTimeBlocks && i... | go | func (node *blockNode) CalcPastMedianTime() time.Time {
// Create a slice of the previous few block timestamps used to calculate
// the median per the number defined by the constant medianTimeBlocks.
timestamps := make([]int64, medianTimeBlocks)
numNodes := 0
iterNode := node
for i := 0; i < medianTimeBlocks && i... | [
"func",
"(",
"node",
"*",
"blockNode",
")",
"CalcPastMedianTime",
"(",
")",
"time",
".",
"Time",
"{",
"// Create a slice of the previous few block timestamps used to calculate",
"// the median per the number defined by the constant medianTimeBlocks.",
"timestamps",
":=",
"make",
... | // CalcPastMedianTime calculates the median time of the previous few blocks
// prior to, and including, the block node.
//
// This function is safe for concurrent access. | [
"CalcPastMedianTime",
"calculates",
"the",
"median",
"time",
"of",
"the",
"previous",
"few",
"blocks",
"prior",
"to",
"and",
"including",
"the",
"block",
"node",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"access",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L185-L218 |
163,504 | btcsuite/btcd | blockchain/blockindex.go | newBlockIndex | func newBlockIndex(db database.DB, chainParams *chaincfg.Params) *blockIndex {
return &blockIndex{
db: db,
chainParams: chainParams,
index: make(map[chainhash.Hash]*blockNode),
dirty: make(map[*blockNode]struct{}),
}
} | go | func newBlockIndex(db database.DB, chainParams *chaincfg.Params) *blockIndex {
return &blockIndex{
db: db,
chainParams: chainParams,
index: make(map[chainhash.Hash]*blockNode),
dirty: make(map[*blockNode]struct{}),
}
} | [
"func",
"newBlockIndex",
"(",
"db",
"database",
".",
"DB",
",",
"chainParams",
"*",
"chaincfg",
".",
"Params",
")",
"*",
"blockIndex",
"{",
"return",
"&",
"blockIndex",
"{",
"db",
":",
"db",
",",
"chainParams",
":",
"chainParams",
",",
"index",
":",
"mak... | // newBlockIndex returns a new empty instance of a block index. The index will
// be dynamically populated as block nodes are loaded from the database and
// manually added. | [
"newBlockIndex",
"returns",
"a",
"new",
"empty",
"instance",
"of",
"a",
"block",
"index",
".",
"The",
"index",
"will",
"be",
"dynamically",
"populated",
"as",
"block",
"nodes",
"are",
"loaded",
"from",
"the",
"database",
"and",
"manually",
"added",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L240-L247 |
163,505 | btcsuite/btcd | blockchain/blockindex.go | HaveBlock | func (bi *blockIndex) HaveBlock(hash *chainhash.Hash) bool {
bi.RLock()
_, hasBlock := bi.index[*hash]
bi.RUnlock()
return hasBlock
} | go | func (bi *blockIndex) HaveBlock(hash *chainhash.Hash) bool {
bi.RLock()
_, hasBlock := bi.index[*hash]
bi.RUnlock()
return hasBlock
} | [
"func",
"(",
"bi",
"*",
"blockIndex",
")",
"HaveBlock",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"bool",
"{",
"bi",
".",
"RLock",
"(",
")",
"\n",
"_",
",",
"hasBlock",
":=",
"bi",
".",
"index",
"[",
"*",
"hash",
"]",
"\n",
"bi",
".",
"R... | // HaveBlock returns whether or not the block index contains the provided hash.
//
// This function is safe for concurrent access. | [
"HaveBlock",
"returns",
"whether",
"or",
"not",
"the",
"block",
"index",
"contains",
"the",
"provided",
"hash",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"access",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L252-L257 |
163,506 | btcsuite/btcd | blockchain/blockindex.go | LookupNode | func (bi *blockIndex) LookupNode(hash *chainhash.Hash) *blockNode {
bi.RLock()
node := bi.index[*hash]
bi.RUnlock()
return node
} | go | func (bi *blockIndex) LookupNode(hash *chainhash.Hash) *blockNode {
bi.RLock()
node := bi.index[*hash]
bi.RUnlock()
return node
} | [
"func",
"(",
"bi",
"*",
"blockIndex",
")",
"LookupNode",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"*",
"blockNode",
"{",
"bi",
".",
"RLock",
"(",
")",
"\n",
"node",
":=",
"bi",
".",
"index",
"[",
"*",
"hash",
"]",
"\n",
"bi",
".",
"RUnloc... | // LookupNode returns the block node identified by the provided hash. It will
// return nil if there is no entry for the hash.
//
// This function is safe for concurrent access. | [
"LookupNode",
"returns",
"the",
"block",
"node",
"identified",
"by",
"the",
"provided",
"hash",
".",
"It",
"will",
"return",
"nil",
"if",
"there",
"is",
"no",
"entry",
"for",
"the",
"hash",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"acces... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L263-L268 |
163,507 | btcsuite/btcd | blockchain/blockindex.go | AddNode | func (bi *blockIndex) AddNode(node *blockNode) {
bi.Lock()
bi.addNode(node)
bi.dirty[node] = struct{}{}
bi.Unlock()
} | go | func (bi *blockIndex) AddNode(node *blockNode) {
bi.Lock()
bi.addNode(node)
bi.dirty[node] = struct{}{}
bi.Unlock()
} | [
"func",
"(",
"bi",
"*",
"blockIndex",
")",
"AddNode",
"(",
"node",
"*",
"blockNode",
")",
"{",
"bi",
".",
"Lock",
"(",
")",
"\n",
"bi",
".",
"addNode",
"(",
"node",
")",
"\n",
"bi",
".",
"dirty",
"[",
"node",
"]",
"=",
"struct",
"{",
"}",
"{",
... | // AddNode adds the provided node to the block index and marks it as dirty.
// Duplicate entries are not checked so it is up to caller to avoid adding them.
//
// This function is safe for concurrent access. | [
"AddNode",
"adds",
"the",
"provided",
"node",
"to",
"the",
"block",
"index",
"and",
"marks",
"it",
"as",
"dirty",
".",
"Duplicate",
"entries",
"are",
"not",
"checked",
"so",
"it",
"is",
"up",
"to",
"caller",
"to",
"avoid",
"adding",
"them",
".",
"This",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L274-L279 |
163,508 | btcsuite/btcd | blockchain/blockindex.go | addNode | func (bi *blockIndex) addNode(node *blockNode) {
bi.index[node.hash] = node
} | go | func (bi *blockIndex) addNode(node *blockNode) {
bi.index[node.hash] = node
} | [
"func",
"(",
"bi",
"*",
"blockIndex",
")",
"addNode",
"(",
"node",
"*",
"blockNode",
")",
"{",
"bi",
".",
"index",
"[",
"node",
".",
"hash",
"]",
"=",
"node",
"\n",
"}"
] | // addNode adds the provided node to the block index, but does not mark it as
// dirty. This can be used while initializing the block index.
//
// This function is NOT safe for concurrent access. | [
"addNode",
"adds",
"the",
"provided",
"node",
"to",
"the",
"block",
"index",
"but",
"does",
"not",
"mark",
"it",
"as",
"dirty",
".",
"This",
"can",
"be",
"used",
"while",
"initializing",
"the",
"block",
"index",
".",
"This",
"function",
"is",
"NOT",
"saf... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L285-L287 |
163,509 | btcsuite/btcd | blockchain/blockindex.go | NodeStatus | func (bi *blockIndex) NodeStatus(node *blockNode) blockStatus {
bi.RLock()
status := node.status
bi.RUnlock()
return status
} | go | func (bi *blockIndex) NodeStatus(node *blockNode) blockStatus {
bi.RLock()
status := node.status
bi.RUnlock()
return status
} | [
"func",
"(",
"bi",
"*",
"blockIndex",
")",
"NodeStatus",
"(",
"node",
"*",
"blockNode",
")",
"blockStatus",
"{",
"bi",
".",
"RLock",
"(",
")",
"\n",
"status",
":=",
"node",
".",
"status",
"\n",
"bi",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"status"... | // NodeStatus provides concurrent-safe access to the status field of a node.
//
// This function is safe for concurrent access. | [
"NodeStatus",
"provides",
"concurrent",
"-",
"safe",
"access",
"to",
"the",
"status",
"field",
"of",
"a",
"node",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"access",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L292-L297 |
163,510 | btcsuite/btcd | blockchain/blockindex.go | SetStatusFlags | func (bi *blockIndex) SetStatusFlags(node *blockNode, flags blockStatus) {
bi.Lock()
node.status |= flags
bi.dirty[node] = struct{}{}
bi.Unlock()
} | go | func (bi *blockIndex) SetStatusFlags(node *blockNode, flags blockStatus) {
bi.Lock()
node.status |= flags
bi.dirty[node] = struct{}{}
bi.Unlock()
} | [
"func",
"(",
"bi",
"*",
"blockIndex",
")",
"SetStatusFlags",
"(",
"node",
"*",
"blockNode",
",",
"flags",
"blockStatus",
")",
"{",
"bi",
".",
"Lock",
"(",
")",
"\n",
"node",
".",
"status",
"|=",
"flags",
"\n",
"bi",
".",
"dirty",
"[",
"node",
"]",
... | // SetStatusFlags flips the provided status flags on the block node to on,
// regardless of whether they were on or off previously. This does not unset any
// flags currently on.
//
// This function is safe for concurrent access. | [
"SetStatusFlags",
"flips",
"the",
"provided",
"status",
"flags",
"on",
"the",
"block",
"node",
"to",
"on",
"regardless",
"of",
"whether",
"they",
"were",
"on",
"or",
"off",
"previously",
".",
"This",
"does",
"not",
"unset",
"any",
"flags",
"currently",
"on",... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L304-L309 |
163,511 | btcsuite/btcd | blockchain/blockindex.go | flushToDB | func (bi *blockIndex) flushToDB() error {
bi.Lock()
if len(bi.dirty) == 0 {
bi.Unlock()
return nil
}
err := bi.db.Update(func(dbTx database.Tx) error {
for node := range bi.dirty {
err := dbStoreBlockNode(dbTx, node)
if err != nil {
return err
}
}
return nil
})
// If write was successful,... | go | func (bi *blockIndex) flushToDB() error {
bi.Lock()
if len(bi.dirty) == 0 {
bi.Unlock()
return nil
}
err := bi.db.Update(func(dbTx database.Tx) error {
for node := range bi.dirty {
err := dbStoreBlockNode(dbTx, node)
if err != nil {
return err
}
}
return nil
})
// If write was successful,... | [
"func",
"(",
"bi",
"*",
"blockIndex",
")",
"flushToDB",
"(",
")",
"error",
"{",
"bi",
".",
"Lock",
"(",
")",
"\n",
"if",
"len",
"(",
"bi",
".",
"dirty",
")",
"==",
"0",
"{",
"bi",
".",
"Unlock",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n... | // flushToDB writes all dirty block nodes to the database. If all writes
// succeed, this clears the dirty set. | [
"flushToDB",
"writes",
"all",
"dirty",
"block",
"nodes",
"to",
"the",
"database",
".",
"If",
"all",
"writes",
"succeed",
"this",
"clears",
"the",
"dirty",
"set",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/blockindex.go#L324-L348 |
163,512 | btcsuite/btcd | txscript/engine.go | hasFlag | func (vm *Engine) hasFlag(flag ScriptFlags) bool {
return vm.flags&flag == flag
} | go | func (vm *Engine) hasFlag(flag ScriptFlags) bool {
return vm.flags&flag == flag
} | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"hasFlag",
"(",
"flag",
"ScriptFlags",
")",
"bool",
"{",
"return",
"vm",
".",
"flags",
"&",
"flag",
"==",
"flag",
"\n",
"}"
] | // hasFlag returns whether the script engine instance has the passed flag set. | [
"hasFlag",
"returns",
"whether",
"the",
"script",
"engine",
"instance",
"has",
"the",
"passed",
"flag",
"set",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L142-L144 |
163,513 | btcsuite/btcd | txscript/engine.go | isBranchExecuting | func (vm *Engine) isBranchExecuting() bool {
if len(vm.condStack) == 0 {
return true
}
return vm.condStack[len(vm.condStack)-1] == OpCondTrue
} | go | func (vm *Engine) isBranchExecuting() bool {
if len(vm.condStack) == 0 {
return true
}
return vm.condStack[len(vm.condStack)-1] == OpCondTrue
} | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"isBranchExecuting",
"(",
")",
"bool",
"{",
"if",
"len",
"(",
"vm",
".",
"condStack",
")",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"vm",
".",
"condStack",
"[",
"len",
"(",
"vm",
".",
"co... | // isBranchExecuting returns whether or not the current conditional branch is
// actively executing. For example, when the data stack has an OP_FALSE on it
// and an OP_IF is encountered, the branch is inactive until an OP_ELSE or
// OP_ENDIF is encountered. It properly handles nested conditionals. | [
"isBranchExecuting",
"returns",
"whether",
"or",
"not",
"the",
"current",
"conditional",
"branch",
"is",
"actively",
"executing",
".",
"For",
"example",
"when",
"the",
"data",
"stack",
"has",
"an",
"OP_FALSE",
"on",
"it",
"and",
"an",
"OP_IF",
"is",
"encounter... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L150-L155 |
163,514 | btcsuite/btcd | txscript/engine.go | executeOpcode | func (vm *Engine) executeOpcode(pop *parsedOpcode) error {
// Disabled opcodes are fail on program counter.
if pop.isDisabled() {
str := fmt.Sprintf("attempt to execute disabled opcode %s",
pop.opcode.name)
return scriptError(ErrDisabledOpcode, str)
}
// Always-illegal opcodes are fail on program counter.
... | go | func (vm *Engine) executeOpcode(pop *parsedOpcode) error {
// Disabled opcodes are fail on program counter.
if pop.isDisabled() {
str := fmt.Sprintf("attempt to execute disabled opcode %s",
pop.opcode.name)
return scriptError(ErrDisabledOpcode, str)
}
// Always-illegal opcodes are fail on program counter.
... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"executeOpcode",
"(",
"pop",
"*",
"parsedOpcode",
")",
"error",
"{",
"// Disabled opcodes are fail on program counter.",
"if",
"pop",
".",
"isDisabled",
"(",
")",
"{",
"str",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\""... | // executeOpcode peforms execution on the passed opcode. It takes into account
// whether or not it is hidden by conditionals, but some rules still must be
// tested in this case. | [
"executeOpcode",
"peforms",
"execution",
"on",
"the",
"passed",
"opcode",
".",
"It",
"takes",
"into",
"account",
"whether",
"or",
"not",
"it",
"is",
"hidden",
"by",
"conditionals",
"but",
"some",
"rules",
"still",
"must",
"be",
"tested",
"in",
"this",
"case"... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L160-L207 |
163,515 | btcsuite/btcd | txscript/engine.go | disasm | func (vm *Engine) disasm(scriptIdx int, scriptOff int) string {
return fmt.Sprintf("%02x:%04x: %s", scriptIdx, scriptOff,
vm.scripts[scriptIdx][scriptOff].print(false))
} | go | func (vm *Engine) disasm(scriptIdx int, scriptOff int) string {
return fmt.Sprintf("%02x:%04x: %s", scriptIdx, scriptOff,
vm.scripts[scriptIdx][scriptOff].print(false))
} | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"disasm",
"(",
"scriptIdx",
"int",
",",
"scriptOff",
"int",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"scriptIdx",
",",
"scriptOff",
",",
"vm",
".",
"scripts",
"[",
"scriptIdx",
... | // disasm is a helper function to produce the output for DisasmPC and
// DisasmScript. It produces the opcode prefixed by the program counter at the
// provided position in the script. It does no error checking and leaves that
// to the caller to provide a valid offset. | [
"disasm",
"is",
"a",
"helper",
"function",
"to",
"produce",
"the",
"output",
"for",
"DisasmPC",
"and",
"DisasmScript",
".",
"It",
"produces",
"the",
"opcode",
"prefixed",
"by",
"the",
"program",
"counter",
"at",
"the",
"provided",
"position",
"in",
"the",
"s... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L213-L216 |
163,516 | btcsuite/btcd | txscript/engine.go | validPC | func (vm *Engine) validPC() error {
if vm.scriptIdx >= len(vm.scripts) {
str := fmt.Sprintf("past input scripts %v:%v %v:xxxx",
vm.scriptIdx, vm.scriptOff, len(vm.scripts))
return scriptError(ErrInvalidProgramCounter, str)
}
if vm.scriptOff >= len(vm.scripts[vm.scriptIdx]) {
str := fmt.Sprintf("past input s... | go | func (vm *Engine) validPC() error {
if vm.scriptIdx >= len(vm.scripts) {
str := fmt.Sprintf("past input scripts %v:%v %v:xxxx",
vm.scriptIdx, vm.scriptOff, len(vm.scripts))
return scriptError(ErrInvalidProgramCounter, str)
}
if vm.scriptOff >= len(vm.scripts[vm.scriptIdx]) {
str := fmt.Sprintf("past input s... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"validPC",
"(",
")",
"error",
"{",
"if",
"vm",
".",
"scriptIdx",
">=",
"len",
"(",
"vm",
".",
"scripts",
")",
"{",
"str",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"vm",
".",
"scriptIdx",
",",
"vm... | // validPC returns an error if the current script position is valid for
// execution, nil otherwise. | [
"validPC",
"returns",
"an",
"error",
"if",
"the",
"current",
"script",
"position",
"is",
"valid",
"for",
"execution",
"nil",
"otherwise",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L220-L233 |
163,517 | btcsuite/btcd | txscript/engine.go | curPC | func (vm *Engine) curPC() (script int, off int, err error) {
err = vm.validPC()
if err != nil {
return 0, 0, err
}
return vm.scriptIdx, vm.scriptOff, nil
} | go | func (vm *Engine) curPC() (script int, off int, err error) {
err = vm.validPC()
if err != nil {
return 0, 0, err
}
return vm.scriptIdx, vm.scriptOff, nil
} | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"curPC",
"(",
")",
"(",
"script",
"int",
",",
"off",
"int",
",",
"err",
"error",
")",
"{",
"err",
"=",
"vm",
".",
"validPC",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"0",
",",
... | // curPC returns either the current script and offset, or an error if the
// position isn't valid. | [
"curPC",
"returns",
"either",
"the",
"current",
"script",
"and",
"offset",
"or",
"an",
"error",
"if",
"the",
"position",
"isn",
"t",
"valid",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L237-L243 |
163,518 | btcsuite/btcd | txscript/engine.go | isWitnessVersionActive | func (vm *Engine) isWitnessVersionActive(version uint) bool {
return vm.witnessProgram != nil && uint(vm.witnessVersion) == version
} | go | func (vm *Engine) isWitnessVersionActive(version uint) bool {
return vm.witnessProgram != nil && uint(vm.witnessVersion) == version
} | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"isWitnessVersionActive",
"(",
"version",
"uint",
")",
"bool",
"{",
"return",
"vm",
".",
"witnessProgram",
"!=",
"nil",
"&&",
"uint",
"(",
"vm",
".",
"witnessVersion",
")",
"==",
"version",
"\n",
"}"
] | // isWitnessVersionActive returns true if a witness program was extracted
// during the initialization of the Engine, and the program's version matches
// the specified version. | [
"isWitnessVersionActive",
"returns",
"true",
"if",
"a",
"witness",
"program",
"was",
"extracted",
"during",
"the",
"initialization",
"of",
"the",
"Engine",
"and",
"the",
"program",
"s",
"version",
"matches",
"the",
"specified",
"version",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L248-L250 |
163,519 | btcsuite/btcd | txscript/engine.go | verifyWitnessProgram | func (vm *Engine) verifyWitnessProgram(witness [][]byte) error {
if vm.isWitnessVersionActive(0) {
switch len(vm.witnessProgram) {
case payToWitnessPubKeyHashDataSize: // P2WKH
// The witness stack should consist of exactly two
// items: the signature, and the pubkey.
if len(witness) != 2 {
err := fmt... | go | func (vm *Engine) verifyWitnessProgram(witness [][]byte) error {
if vm.isWitnessVersionActive(0) {
switch len(vm.witnessProgram) {
case payToWitnessPubKeyHashDataSize: // P2WKH
// The witness stack should consist of exactly two
// items: the signature, and the pubkey.
if len(witness) != 2 {
err := fmt... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"verifyWitnessProgram",
"(",
"witness",
"[",
"]",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"vm",
".",
"isWitnessVersionActive",
"(",
"0",
")",
"{",
"switch",
"len",
"(",
"vm",
".",
"witnessProgram",
")",
"{",
... | // verifyWitnessProgram validates the stored witness program using the passed
// witness as input. | [
"verifyWitnessProgram",
"validates",
"the",
"stored",
"witness",
"program",
"using",
"the",
"passed",
"witness",
"as",
"input",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L254-L359 |
163,520 | btcsuite/btcd | txscript/engine.go | DisasmScript | func (vm *Engine) DisasmScript(idx int) (string, error) {
if idx >= len(vm.scripts) {
str := fmt.Sprintf("script index %d >= total scripts %d", idx,
len(vm.scripts))
return "", scriptError(ErrInvalidIndex, str)
}
var disstr string
for i := range vm.scripts[idx] {
disstr = disstr + vm.disasm(idx, i) + "\n"... | go | func (vm *Engine) DisasmScript(idx int) (string, error) {
if idx >= len(vm.scripts) {
str := fmt.Sprintf("script index %d >= total scripts %d", idx,
len(vm.scripts))
return "", scriptError(ErrInvalidIndex, str)
}
var disstr string
for i := range vm.scripts[idx] {
disstr = disstr + vm.disasm(idx, i) + "\n"... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"DisasmScript",
"(",
"idx",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"idx",
">=",
"len",
"(",
"vm",
".",
"scripts",
")",
"{",
"str",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"idx"... | // DisasmScript returns the disassembly string for the script at the requested
// offset index. Index 0 is the signature script and 1 is the public key
// script. | [
"DisasmScript",
"returns",
"the",
"disassembly",
"string",
"for",
"the",
"script",
"at",
"the",
"requested",
"offset",
"index",
".",
"Index",
"0",
"is",
"the",
"signature",
"script",
"and",
"1",
"is",
"the",
"public",
"key",
"script",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L374-L386 |
163,521 | btcsuite/btcd | txscript/engine.go | CheckErrorCondition | func (vm *Engine) CheckErrorCondition(finalScript bool) error {
// Check execution is actually done. When pc is past the end of script
// array there are no more scripts to run.
if vm.scriptIdx < len(vm.scripts) {
return scriptError(ErrScriptUnfinished,
"error check when script unfinished")
}
// If we're in... | go | func (vm *Engine) CheckErrorCondition(finalScript bool) error {
// Check execution is actually done. When pc is past the end of script
// array there are no more scripts to run.
if vm.scriptIdx < len(vm.scripts) {
return scriptError(ErrScriptUnfinished,
"error check when script unfinished")
}
// If we're in... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"CheckErrorCondition",
"(",
"finalScript",
"bool",
")",
"error",
"{",
"// Check execution is actually done. When pc is past the end of script",
"// array there are no more scripts to run.",
"if",
"vm",
".",
"scriptIdx",
"<",
"len",
"(... | // CheckErrorCondition returns nil if the running script has ended and was
// successful, leaving a a true boolean on the stack. An error otherwise,
// including if the script has not finished. | [
"CheckErrorCondition",
"returns",
"nil",
"if",
"the",
"running",
"script",
"has",
"ended",
"and",
"was",
"successful",
"leaving",
"a",
"a",
"true",
"boolean",
"on",
"the",
"stack",
".",
"An",
"error",
"otherwise",
"including",
"if",
"the",
"script",
"has",
"... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L391-L434 |
163,522 | btcsuite/btcd | txscript/engine.go | Step | func (vm *Engine) Step() (done bool, err error) {
// Verify that it is pointing to a valid script address.
err = vm.validPC()
if err != nil {
return true, err
}
opcode := &vm.scripts[vm.scriptIdx][vm.scriptOff]
vm.scriptOff++
// Execute the opcode while taking into account several things such as
// disabled ... | go | func (vm *Engine) Step() (done bool, err error) {
// Verify that it is pointing to a valid script address.
err = vm.validPC()
if err != nil {
return true, err
}
opcode := &vm.scripts[vm.scriptIdx][vm.scriptOff]
vm.scriptOff++
// Execute the opcode while taking into account several things such as
// disabled ... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"Step",
"(",
")",
"(",
"done",
"bool",
",",
"err",
"error",
")",
"{",
"// Verify that it is pointing to a valid script address.",
"err",
"=",
"vm",
".",
"validPC",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ret... | // Step will execute the next instruction and move the program counter to the
// next opcode in the script, or the next script if the current has ended. Step
// will return true in the case that the last opcode was successfully executed.
//
// The result of calling Step or any other method is undefined if an error is
... | [
"Step",
"will",
"execute",
"the",
"next",
"instruction",
"and",
"move",
"the",
"program",
"counter",
"to",
"the",
"next",
"opcode",
"in",
"the",
"script",
"or",
"the",
"next",
"script",
"if",
"the",
"current",
"has",
"ended",
".",
"Step",
"will",
"return",... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L442-L526 |
163,523 | btcsuite/btcd | txscript/engine.go | Execute | func (vm *Engine) Execute() (err error) {
done := false
for !done {
log.Tracef("%v", newLogClosure(func() string {
dis, err := vm.DisasmPC()
if err != nil {
return fmt.Sprintf("stepping (%v)", err)
}
return fmt.Sprintf("stepping %v", dis)
}))
done, err = vm.Step()
if err != nil {
return er... | go | func (vm *Engine) Execute() (err error) {
done := false
for !done {
log.Tracef("%v", newLogClosure(func() string {
dis, err := vm.DisasmPC()
if err != nil {
return fmt.Sprintf("stepping (%v)", err)
}
return fmt.Sprintf("stepping %v", dis)
}))
done, err = vm.Step()
if err != nil {
return er... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"Execute",
"(",
")",
"(",
"err",
"error",
")",
"{",
"done",
":=",
"false",
"\n",
"for",
"!",
"done",
"{",
"log",
".",
"Tracef",
"(",
"\"",
"\"",
",",
"newLogClosure",
"(",
"func",
"(",
")",
"string",
"{",
... | // Execute will execute all scripts in the script engine and return either nil
// for successful validation or an error if one occurred. | [
"Execute",
"will",
"execute",
"all",
"scripts",
"in",
"the",
"script",
"engine",
"and",
"return",
"either",
"nil",
"for",
"successful",
"validation",
"or",
"an",
"error",
"if",
"one",
"occurred",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L530-L561 |
163,524 | btcsuite/btcd | txscript/engine.go | subScript | func (vm *Engine) subScript() []parsedOpcode {
return vm.scripts[vm.scriptIdx][vm.lastCodeSep:]
} | go | func (vm *Engine) subScript() []parsedOpcode {
return vm.scripts[vm.scriptIdx][vm.lastCodeSep:]
} | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"subScript",
"(",
")",
"[",
"]",
"parsedOpcode",
"{",
"return",
"vm",
".",
"scripts",
"[",
"vm",
".",
"scriptIdx",
"]",
"[",
"vm",
".",
"lastCodeSep",
":",
"]",
"\n",
"}"
] | // subScript returns the script since the last OP_CODESEPARATOR. | [
"subScript",
"returns",
"the",
"script",
"since",
"the",
"last",
"OP_CODESEPARATOR",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L564-L566 |
163,525 | btcsuite/btcd | txscript/engine.go | checkHashTypeEncoding | func (vm *Engine) checkHashTypeEncoding(hashType SigHashType) error {
if !vm.hasFlag(ScriptVerifyStrictEncoding) {
return nil
}
sigHashType := hashType & ^SigHashAnyOneCanPay
if sigHashType < SigHashAll || sigHashType > SigHashSingle {
str := fmt.Sprintf("invalid hash type 0x%x", hashType)
return scriptError... | go | func (vm *Engine) checkHashTypeEncoding(hashType SigHashType) error {
if !vm.hasFlag(ScriptVerifyStrictEncoding) {
return nil
}
sigHashType := hashType & ^SigHashAnyOneCanPay
if sigHashType < SigHashAll || sigHashType > SigHashSingle {
str := fmt.Sprintf("invalid hash type 0x%x", hashType)
return scriptError... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"checkHashTypeEncoding",
"(",
"hashType",
"SigHashType",
")",
"error",
"{",
"if",
"!",
"vm",
".",
"hasFlag",
"(",
"ScriptVerifyStrictEncoding",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"sigHashType",
":=",
"hashTyp... | // checkHashTypeEncoding returns whether or not the passed hashtype adheres to
// the strict encoding requirements if enabled. | [
"checkHashTypeEncoding",
"returns",
"whether",
"or",
"not",
"the",
"passed",
"hashtype",
"adheres",
"to",
"the",
"strict",
"encoding",
"requirements",
"if",
"enabled",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L570-L581 |
163,526 | btcsuite/btcd | txscript/engine.go | checkPubKeyEncoding | func (vm *Engine) checkPubKeyEncoding(pubKey []byte) error {
if vm.hasFlag(ScriptVerifyWitnessPubKeyType) &&
vm.isWitnessVersionActive(0) && !btcec.IsCompressedPubKey(pubKey) {
str := "only uncompressed keys are accepted post-segwit"
return scriptError(ErrWitnessPubKeyType, str)
}
if !vm.hasFlag(ScriptVerify... | go | func (vm *Engine) checkPubKeyEncoding(pubKey []byte) error {
if vm.hasFlag(ScriptVerifyWitnessPubKeyType) &&
vm.isWitnessVersionActive(0) && !btcec.IsCompressedPubKey(pubKey) {
str := "only uncompressed keys are accepted post-segwit"
return scriptError(ErrWitnessPubKeyType, str)
}
if !vm.hasFlag(ScriptVerify... | [
"func",
"(",
"vm",
"*",
"Engine",
")",
"checkPubKeyEncoding",
"(",
"pubKey",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"vm",
".",
"hasFlag",
"(",
"ScriptVerifyWitnessPubKeyType",
")",
"&&",
"vm",
".",
"isWitnessVersionActive",
"(",
"0",
")",
"&&",
"!",
... | // checkPubKeyEncoding returns whether or not the passed public key adheres to
// the strict encoding requirements if enabled. | [
"checkPubKeyEncoding",
"returns",
"whether",
"or",
"not",
"the",
"passed",
"public",
"key",
"adheres",
"to",
"the",
"strict",
"encoding",
"requirements",
"if",
"enabled",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L585-L607 |
163,527 | btcsuite/btcd | txscript/engine.go | getStack | func getStack(stack *stack) [][]byte {
array := make([][]byte, stack.Depth())
for i := range array {
// PeekByteArry can't fail due to overflow, already checked
array[len(array)-i-1], _ = stack.PeekByteArray(int32(i))
}
return array
} | go | func getStack(stack *stack) [][]byte {
array := make([][]byte, stack.Depth())
for i := range array {
// PeekByteArry can't fail due to overflow, already checked
array[len(array)-i-1], _ = stack.PeekByteArray(int32(i))
}
return array
} | [
"func",
"getStack",
"(",
"stack",
"*",
"stack",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"array",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"stack",
".",
"Depth",
"(",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"array",
"{",
"// PeekByte... | // getStack returns the contents of stack as a byte array bottom up | [
"getStack",
"returns",
"the",
"contents",
"of",
"stack",
"as",
"a",
"byte",
"array",
"bottom",
"up"
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L808-L815 |
163,528 | btcsuite/btcd | txscript/engine.go | setStack | func setStack(stack *stack, data [][]byte) {
// This can not error. Only errors are for invalid arguments.
_ = stack.DropN(stack.Depth())
for i := range data {
stack.PushByteArray(data[i])
}
} | go | func setStack(stack *stack, data [][]byte) {
// This can not error. Only errors are for invalid arguments.
_ = stack.DropN(stack.Depth())
for i := range data {
stack.PushByteArray(data[i])
}
} | [
"func",
"setStack",
"(",
"stack",
"*",
"stack",
",",
"data",
"[",
"]",
"[",
"]",
"byte",
")",
"{",
"// This can not error. Only errors are for invalid arguments.",
"_",
"=",
"stack",
".",
"DropN",
"(",
"stack",
".",
"Depth",
"(",
")",
")",
"\n\n",
"for",
"... | // setStack sets the stack to the contents of the array where the last item in
// the array is the top item in the stack. | [
"setStack",
"sets",
"the",
"stack",
"to",
"the",
"contents",
"of",
"the",
"array",
"where",
"the",
"last",
"item",
"in",
"the",
"array",
"is",
"the",
"top",
"item",
"in",
"the",
"stack",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/txscript/engine.go#L819-L826 |
163,529 | btcsuite/btcd | database/cmd/dbtool/globalconfig.go | setupGlobalConfig | func setupGlobalConfig() error {
// Multiple networks can't be selected simultaneously.
// Count number of network flags passed; assign active network params
// while we're at it
numNets := 0
if cfg.TestNet3 {
numNets++
activeNetParams = &chaincfg.TestNet3Params
}
if cfg.RegressionTest {
numNets++
active... | go | func setupGlobalConfig() error {
// Multiple networks can't be selected simultaneously.
// Count number of network flags passed; assign active network params
// while we're at it
numNets := 0
if cfg.TestNet3 {
numNets++
activeNetParams = &chaincfg.TestNet3Params
}
if cfg.RegressionTest {
numNets++
active... | [
"func",
"setupGlobalConfig",
"(",
")",
"error",
"{",
"// Multiple networks can't be selected simultaneously.",
"// Count number of network flags passed; assign active network params",
"// while we're at it",
"numNets",
":=",
"0",
"\n",
"if",
"cfg",
".",
"TestNet3",
"{",
"numNets"... | // setupGlobalConfig examine the global configuration options for any conditions
// which are invalid as well as performs any addition setup necessary after the
// initial parse. | [
"setupGlobalConfig",
"examine",
"the",
"global",
"configuration",
"options",
"for",
"any",
"conditions",
"which",
"are",
"invalid",
"as",
"well",
"as",
"performs",
"any",
"addition",
"setup",
"necessary",
"after",
"the",
"initial",
"parse",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/database/cmd/dbtool/globalconfig.go#L83-L121 |
163,530 | btcsuite/btcd | blockchain/scriptval.go | sendResult | func (v *txValidator) sendResult(result error) {
select {
case v.resultChan <- result:
case <-v.quitChan:
}
} | go | func (v *txValidator) sendResult(result error) {
select {
case v.resultChan <- result:
case <-v.quitChan:
}
} | [
"func",
"(",
"v",
"*",
"txValidator",
")",
"sendResult",
"(",
"result",
"error",
")",
"{",
"select",
"{",
"case",
"v",
".",
"resultChan",
"<-",
"result",
":",
"case",
"<-",
"v",
".",
"quitChan",
":",
"}",
"\n",
"}"
] | // sendResult sends the result of a script pair validation on the internal
// result channel while respecting the quit channel. This allows orderly
// shutdown when the validation process is aborted early due to a validation
// error in one of the other goroutines. | [
"sendResult",
"sends",
"the",
"result",
"of",
"a",
"script",
"pair",
"validation",
"on",
"the",
"internal",
"result",
"channel",
"while",
"respecting",
"the",
"quit",
"channel",
".",
"This",
"allows",
"orderly",
"shutdown",
"when",
"the",
"validation",
"process"... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/scriptval.go#L43-L48 |
163,531 | btcsuite/btcd | blockchain/scriptval.go | validateHandler | func (v *txValidator) validateHandler() {
out:
for {
select {
case txVI := <-v.validateChan:
// Ensure the referenced input utxo is available.
txIn := txVI.txIn
utxo := v.utxoView.LookupEntry(txIn.PreviousOutPoint)
if utxo == nil {
str := fmt.Sprintf("unable to find unspent "+
"output %v refer... | go | func (v *txValidator) validateHandler() {
out:
for {
select {
case txVI := <-v.validateChan:
// Ensure the referenced input utxo is available.
txIn := txVI.txIn
utxo := v.utxoView.LookupEntry(txIn.PreviousOutPoint)
if utxo == nil {
str := fmt.Sprintf("unable to find unspent "+
"output %v refer... | [
"func",
"(",
"v",
"*",
"txValidator",
")",
"validateHandler",
"(",
")",
"{",
"out",
":",
"for",
"{",
"select",
"{",
"case",
"txVI",
":=",
"<-",
"v",
".",
"validateChan",
":",
"// Ensure the referenced input utxo is available.",
"txIn",
":=",
"txVI",
".",
"tx... | // validateHandler consumes items to validate from the internal validate channel
// and returns the result of the validation on the internal result channel. It
// must be run as a goroutine. | [
"validateHandler",
"consumes",
"items",
"to",
"validate",
"from",
"the",
"internal",
"validate",
"channel",
"and",
"returns",
"the",
"result",
"of",
"the",
"validation",
"on",
"the",
"internal",
"result",
"channel",
".",
"It",
"must",
"be",
"run",
"as",
"a",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/scriptval.go#L53-L114 |
163,532 | btcsuite/btcd | blockchain/scriptval.go | Validate | func (v *txValidator) Validate(items []*txValidateItem) error {
if len(items) == 0 {
return nil
}
// Limit the number of goroutines to do script validation based on the
// number of processor cores. This helps ensure the system stays
// reasonably responsive under heavy load.
maxGoRoutines := runtime.NumCPU()... | go | func (v *txValidator) Validate(items []*txValidateItem) error {
if len(items) == 0 {
return nil
}
// Limit the number of goroutines to do script validation based on the
// number of processor cores. This helps ensure the system stays
// reasonably responsive under heavy load.
maxGoRoutines := runtime.NumCPU()... | [
"func",
"(",
"v",
"*",
"txValidator",
")",
"Validate",
"(",
"items",
"[",
"]",
"*",
"txValidateItem",
")",
"error",
"{",
"if",
"len",
"(",
"items",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Limit the number of goroutines to do script valid... | // Validate validates the scripts for all of the passed transaction inputs using
// multiple goroutines. | [
"Validate",
"validates",
"the",
"scripts",
"for",
"all",
"of",
"the",
"passed",
"transaction",
"inputs",
"using",
"multiple",
"goroutines",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/scriptval.go#L118-L172 |
163,533 | btcsuite/btcd | blockchain/scriptval.go | newTxValidator | func newTxValidator(utxoView *UtxoViewpoint, flags txscript.ScriptFlags,
sigCache *txscript.SigCache, hashCache *txscript.HashCache) *txValidator {
return &txValidator{
validateChan: make(chan *txValidateItem),
quitChan: make(chan struct{}),
resultChan: make(chan error),
utxoView: utxoView,
sigCac... | go | func newTxValidator(utxoView *UtxoViewpoint, flags txscript.ScriptFlags,
sigCache *txscript.SigCache, hashCache *txscript.HashCache) *txValidator {
return &txValidator{
validateChan: make(chan *txValidateItem),
quitChan: make(chan struct{}),
resultChan: make(chan error),
utxoView: utxoView,
sigCac... | [
"func",
"newTxValidator",
"(",
"utxoView",
"*",
"UtxoViewpoint",
",",
"flags",
"txscript",
".",
"ScriptFlags",
",",
"sigCache",
"*",
"txscript",
".",
"SigCache",
",",
"hashCache",
"*",
"txscript",
".",
"HashCache",
")",
"*",
"txValidator",
"{",
"return",
"&",
... | // newTxValidator returns a new instance of txValidator to be used for
// validating transaction scripts asynchronously. | [
"newTxValidator",
"returns",
"a",
"new",
"instance",
"of",
"txValidator",
"to",
"be",
"used",
"for",
"validating",
"transaction",
"scripts",
"asynchronously",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/scriptval.go#L176-L187 |
163,534 | btcsuite/btcd | blockchain/scriptval.go | ValidateTransactionScripts | func ValidateTransactionScripts(tx *btcutil.Tx, utxoView *UtxoViewpoint,
flags txscript.ScriptFlags, sigCache *txscript.SigCache,
hashCache *txscript.HashCache) error {
// First determine if segwit is active according to the scriptFlags. If
// it isn't then we don't need to interact with the HashCache.
segwitActi... | go | func ValidateTransactionScripts(tx *btcutil.Tx, utxoView *UtxoViewpoint,
flags txscript.ScriptFlags, sigCache *txscript.SigCache,
hashCache *txscript.HashCache) error {
// First determine if segwit is active according to the scriptFlags. If
// it isn't then we don't need to interact with the HashCache.
segwitActi... | [
"func",
"ValidateTransactionScripts",
"(",
"tx",
"*",
"btcutil",
".",
"Tx",
",",
"utxoView",
"*",
"UtxoViewpoint",
",",
"flags",
"txscript",
".",
"ScriptFlags",
",",
"sigCache",
"*",
"txscript",
".",
"SigCache",
",",
"hashCache",
"*",
"txscript",
".",
"HashCac... | // ValidateTransactionScripts validates the scripts for the passed transaction
// using multiple goroutines. | [
"ValidateTransactionScripts",
"validates",
"the",
"scripts",
"for",
"the",
"passed",
"transaction",
"using",
"multiple",
"goroutines",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/scriptval.go#L191-L239 |
163,535 | btcsuite/btcd | blockchain/scriptval.go | checkBlockScripts | func checkBlockScripts(block *btcutil.Block, utxoView *UtxoViewpoint,
scriptFlags txscript.ScriptFlags, sigCache *txscript.SigCache,
hashCache *txscript.HashCache) error {
// First determine if segwit is active according to the scriptFlags. If
// it isn't then we don't need to interact with the HashCache.
segwitA... | go | func checkBlockScripts(block *btcutil.Block, utxoView *UtxoViewpoint,
scriptFlags txscript.ScriptFlags, sigCache *txscript.SigCache,
hashCache *txscript.HashCache) error {
// First determine if segwit is active according to the scriptFlags. If
// it isn't then we don't need to interact with the HashCache.
segwitA... | [
"func",
"checkBlockScripts",
"(",
"block",
"*",
"btcutil",
".",
"Block",
",",
"utxoView",
"*",
"UtxoViewpoint",
",",
"scriptFlags",
"txscript",
".",
"ScriptFlags",
",",
"sigCache",
"*",
"txscript",
".",
"SigCache",
",",
"hashCache",
"*",
"txscript",
".",
"Hash... | // checkBlockScripts executes and validates the scripts for all transactions in
// the passed block using multiple goroutines. | [
"checkBlockScripts",
"executes",
"and",
"validates",
"the",
"scripts",
"for",
"all",
"transactions",
"in",
"the",
"passed",
"block",
"using",
"multiple",
"goroutines",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/scriptval.go#L243-L319 |
163,536 | btcsuite/btcd | blockchain/process.go | blockExists | func (b *BlockChain) blockExists(hash *chainhash.Hash) (bool, error) {
// Check block index first (could be main chain or side chain blocks).
if b.index.HaveBlock(hash) {
return true, nil
}
// Check in the database.
var exists bool
err := b.db.View(func(dbTx database.Tx) error {
var err error
exists, err =... | go | func (b *BlockChain) blockExists(hash *chainhash.Hash) (bool, error) {
// Check block index first (could be main chain or side chain blocks).
if b.index.HaveBlock(hash) {
return true, nil
}
// Check in the database.
var exists bool
err := b.db.View(func(dbTx database.Tx) error {
var err error
exists, err =... | [
"func",
"(",
"b",
"*",
"BlockChain",
")",
"blockExists",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"(",
"bool",
",",
"error",
")",
"{",
"// Check block index first (could be main chain or side chain blocks).",
"if",
"b",
".",
"index",
".",
"HaveBlock",
"(... | // blockExists determines whether a block with the given hash exists either in
// the main chain or any side chains.
//
// This function is safe for concurrent access. | [
"blockExists",
"determines",
"whether",
"a",
"block",
"with",
"the",
"given",
"hash",
"exists",
"either",
"in",
"the",
"main",
"chain",
"or",
"any",
"side",
"chains",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"access",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/process.go#L40-L72 |
163,537 | btcsuite/btcd | blockchain/process.go | ProcessBlock | func (b *BlockChain) ProcessBlock(block *btcutil.Block, flags BehaviorFlags) (bool, bool, error) {
b.chainLock.Lock()
defer b.chainLock.Unlock()
fastAdd := flags&BFFastAdd == BFFastAdd
blockHash := block.Hash()
log.Tracef("Processing block %v", blockHash)
// The block must not already exist in the main chain o... | go | func (b *BlockChain) ProcessBlock(block *btcutil.Block, flags BehaviorFlags) (bool, bool, error) {
b.chainLock.Lock()
defer b.chainLock.Unlock()
fastAdd := flags&BFFastAdd == BFFastAdd
blockHash := block.Hash()
log.Tracef("Processing block %v", blockHash)
// The block must not already exist in the main chain o... | [
"func",
"(",
"b",
"*",
"BlockChain",
")",
"ProcessBlock",
"(",
"block",
"*",
"btcutil",
".",
"Block",
",",
"flags",
"BehaviorFlags",
")",
"(",
"bool",
",",
"bool",
",",
"error",
")",
"{",
"b",
".",
"chainLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
... | // ProcessBlock is the main workhorse for handling insertion of new blocks into
// the block chain. It includes functionality such as rejecting duplicate
// blocks, ensuring blocks follow all rules, orphan handling, and insertion into
// the block chain along with best chain selection and reorganization.
//
// When no... | [
"ProcessBlock",
"is",
"the",
"main",
"workhorse",
"for",
"handling",
"insertion",
"of",
"new",
"blocks",
"into",
"the",
"block",
"chain",
".",
"It",
"includes",
"functionality",
"such",
"as",
"rejecting",
"duplicate",
"blocks",
"ensuring",
"blocks",
"follow",
"a... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/process.go#L142-L244 |
163,538 | btcsuite/btcd | addrmgr/knownaddress.go | chance | func (ka *KnownAddress) chance() float64 {
now := time.Now()
lastAttempt := now.Sub(ka.lastattempt)
if lastAttempt < 0 {
lastAttempt = 0
}
c := 1.0
// Very recent attempts are less likely to be retried.
if lastAttempt < 10*time.Minute {
c *= 0.01
}
// Failed attempts deprioritise.
for i := ka.attempts... | go | func (ka *KnownAddress) chance() float64 {
now := time.Now()
lastAttempt := now.Sub(ka.lastattempt)
if lastAttempt < 0 {
lastAttempt = 0
}
c := 1.0
// Very recent attempts are less likely to be retried.
if lastAttempt < 10*time.Minute {
c *= 0.01
}
// Failed attempts deprioritise.
for i := ka.attempts... | [
"func",
"(",
"ka",
"*",
"KnownAddress",
")",
"chance",
"(",
")",
"float64",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"lastAttempt",
":=",
"now",
".",
"Sub",
"(",
"ka",
".",
"lastattempt",
")",
"\n\n",
"if",
"lastAttempt",
"<",
"0",
"{"... | // chance returns the selection probability for a known address. The priority
// depends upon how recently the address has been seen, how recently it was last
// attempted and how often attempts to connect to it have failed. | [
"chance",
"returns",
"the",
"selection",
"probability",
"for",
"a",
"known",
"address",
".",
"The",
"priority",
"depends",
"upon",
"how",
"recently",
"the",
"address",
"has",
"been",
"seen",
"how",
"recently",
"it",
"was",
"last",
"attempted",
"and",
"how",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/addrmgr/knownaddress.go#L44-L65 |
163,539 | btcsuite/btcd | blockchain/checkpoints.go | verifyCheckpoint | func (b *BlockChain) verifyCheckpoint(height int32, hash *chainhash.Hash) bool {
if !b.HasCheckpoints() {
return true
}
// Nothing to check if there is no checkpoint data for the block height.
checkpoint, exists := b.checkpointsByHeight[height]
if !exists {
return true
}
if !checkpoint.Hash.IsEqual(hash) {... | go | func (b *BlockChain) verifyCheckpoint(height int32, hash *chainhash.Hash) bool {
if !b.HasCheckpoints() {
return true
}
// Nothing to check if there is no checkpoint data for the block height.
checkpoint, exists := b.checkpointsByHeight[height]
if !exists {
return true
}
if !checkpoint.Hash.IsEqual(hash) {... | [
"func",
"(",
"b",
"*",
"BlockChain",
")",
"verifyCheckpoint",
"(",
"height",
"int32",
",",
"hash",
"*",
"chainhash",
".",
"Hash",
")",
"bool",
"{",
"if",
"!",
"b",
".",
"HasCheckpoints",
"(",
")",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"// Nothing t... | // verifyCheckpoint returns whether the passed block height and hash combination
// match the checkpoint data. It also returns true if there is no checkpoint
// data for the passed block height. | [
"verifyCheckpoint",
"returns",
"whether",
"the",
"passed",
"block",
"height",
"and",
"hash",
"combination",
"match",
"the",
"checkpoint",
"data",
".",
"It",
"also",
"returns",
"true",
"if",
"there",
"is",
"no",
"checkpoint",
"data",
"for",
"the",
"passed",
"bl... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/checkpoints.go#L61-L79 |
163,540 | btcsuite/btcd | blockchain/checkpoints.go | isNonstandardTransaction | func isNonstandardTransaction(tx *btcutil.Tx) bool {
// Check all of the output public key scripts for non-standard scripts.
for _, txOut := range tx.MsgTx().TxOut {
scriptClass := txscript.GetScriptClass(txOut.PkScript)
if scriptClass == txscript.NonStandardTy {
return true
}
}
return false
} | go | func isNonstandardTransaction(tx *btcutil.Tx) bool {
// Check all of the output public key scripts for non-standard scripts.
for _, txOut := range tx.MsgTx().TxOut {
scriptClass := txscript.GetScriptClass(txOut.PkScript)
if scriptClass == txscript.NonStandardTy {
return true
}
}
return false
} | [
"func",
"isNonstandardTransaction",
"(",
"tx",
"*",
"btcutil",
".",
"Tx",
")",
"bool",
"{",
"// Check all of the output public key scripts for non-standard scripts.",
"for",
"_",
",",
"txOut",
":=",
"range",
"tx",
".",
"MsgTx",
"(",
")",
".",
"TxOut",
"{",
"script... | // isNonstandardTransaction determines whether a transaction contains any
// scripts which are not one of the standard types. | [
"isNonstandardTransaction",
"determines",
"whether",
"a",
"transaction",
"contains",
"any",
"scripts",
"which",
"are",
"not",
"one",
"of",
"the",
"standard",
"types",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/checkpoints.go#L172-L181 |
163,541 | btcsuite/btcd | rpcclient/net.go | AddNodeAsync | func (c *Client) AddNodeAsync(host string, command AddNodeCommand) FutureAddNodeResult {
cmd := btcjson.NewAddNodeCmd(host, btcjson.AddNodeSubCmd(command))
return c.sendCmd(cmd)
} | go | func (c *Client) AddNodeAsync(host string, command AddNodeCommand) FutureAddNodeResult {
cmd := btcjson.NewAddNodeCmd(host, btcjson.AddNodeSubCmd(command))
return c.sendCmd(cmd)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddNodeAsync",
"(",
"host",
"string",
",",
"command",
"AddNodeCommand",
")",
"FutureAddNodeResult",
"{",
"cmd",
":=",
"btcjson",
".",
"NewAddNodeCmd",
"(",
"host",
",",
"btcjson",
".",
"AddNodeSubCmd",
"(",
"command",
"... | // AddNodeAsync returns an instance of a type that can be used to get the result
// of the RPC at some future time by invoking the Receive function on the
// returned instance.
//
// See AddNode for the blocking version and more details. | [
"AddNodeAsync",
"returns",
"an",
"instance",
"of",
"a",
"type",
"that",
"can",
"be",
"used",
"to",
"get",
"the",
"result",
"of",
"the",
"RPC",
"at",
"some",
"future",
"time",
"by",
"invoking",
"the",
"Receive",
"function",
"on",
"the",
"returned",
"instanc... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L52-L55 |
163,542 | btcsuite/btcd | rpcclient/net.go | AddNode | func (c *Client) AddNode(host string, command AddNodeCommand) error {
return c.AddNodeAsync(host, command).Receive()
} | go | func (c *Client) AddNode(host string, command AddNodeCommand) error {
return c.AddNodeAsync(host, command).Receive()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddNode",
"(",
"host",
"string",
",",
"command",
"AddNodeCommand",
")",
"error",
"{",
"return",
"c",
".",
"AddNodeAsync",
"(",
"host",
",",
"command",
")",
".",
"Receive",
"(",
")",
"\n",
"}"
] | // AddNode attempts to perform the passed command on the passed persistent peer.
// For example, it can be used to add or a remove a persistent peer, or to do
// a one time connection to a peer.
//
// It may not be used to remove non-persistent peers. | [
"AddNode",
"attempts",
"to",
"perform",
"the",
"passed",
"command",
"on",
"the",
"passed",
"persistent",
"peer",
".",
"For",
"example",
"it",
"can",
"be",
"used",
"to",
"add",
"or",
"a",
"remove",
"a",
"persistent",
"peer",
"or",
"to",
"do",
"a",
"one",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L62-L64 |
163,543 | btcsuite/btcd | rpcclient/net.go | NodeAsync | func (c *Client) NodeAsync(command btcjson.NodeSubCmd, host string,
connectSubCmd *string) FutureNodeResult {
cmd := btcjson.NewNodeCmd(command, host, connectSubCmd)
return c.sendCmd(cmd)
} | go | func (c *Client) NodeAsync(command btcjson.NodeSubCmd, host string,
connectSubCmd *string) FutureNodeResult {
cmd := btcjson.NewNodeCmd(command, host, connectSubCmd)
return c.sendCmd(cmd)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"NodeAsync",
"(",
"command",
"btcjson",
".",
"NodeSubCmd",
",",
"host",
"string",
",",
"connectSubCmd",
"*",
"string",
")",
"FutureNodeResult",
"{",
"cmd",
":=",
"btcjson",
".",
"NewNodeCmd",
"(",
"command",
",",
"host... | // NodeAsync returns an instance of a type that can be used to get the result
// of the RPC at some future time by invoking the Receive function on the
// returned instance.
//
// See Node for the blocking version and more details. | [
"NodeAsync",
"returns",
"an",
"instance",
"of",
"a",
"type",
"that",
"can",
"be",
"used",
"to",
"get",
"the",
"result",
"of",
"the",
"RPC",
"at",
"some",
"future",
"time",
"by",
"invoking",
"the",
"Receive",
"function",
"on",
"the",
"returned",
"instance",... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L82-L86 |
163,544 | btcsuite/btcd | rpcclient/net.go | Node | func (c *Client) Node(command btcjson.NodeSubCmd, host string,
connectSubCmd *string) error {
return c.NodeAsync(command, host, connectSubCmd).Receive()
} | go | func (c *Client) Node(command btcjson.NodeSubCmd, host string,
connectSubCmd *string) error {
return c.NodeAsync(command, host, connectSubCmd).Receive()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Node",
"(",
"command",
"btcjson",
".",
"NodeSubCmd",
",",
"host",
"string",
",",
"connectSubCmd",
"*",
"string",
")",
"error",
"{",
"return",
"c",
".",
"NodeAsync",
"(",
"command",
",",
"host",
",",
"connectSubCmd",... | // Node attempts to perform the passed node command on the host.
// For example, it can be used to add or a remove a persistent peer, or to do
// connect or diconnect a non-persistent one.
//
// The connectSubCmd should be set either "perm" or "temp", depending on
// whether we are targetting a persistent or non-persis... | [
"Node",
"attempts",
"to",
"perform",
"the",
"passed",
"node",
"command",
"on",
"the",
"host",
".",
"For",
"example",
"it",
"can",
"be",
"used",
"to",
"add",
"or",
"a",
"remove",
"a",
"persistent",
"peer",
"or",
"to",
"do",
"connect",
"or",
"diconnect",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L95-L98 |
163,545 | btcsuite/btcd | rpcclient/net.go | GetAddedNodeInfoAsync | func (c *Client) GetAddedNodeInfoAsync(peer string) FutureGetAddedNodeInfoResult {
cmd := btcjson.NewGetAddedNodeInfoCmd(true, &peer)
return c.sendCmd(cmd)
} | go | func (c *Client) GetAddedNodeInfoAsync(peer string) FutureGetAddedNodeInfoResult {
cmd := btcjson.NewGetAddedNodeInfoCmd(true, &peer)
return c.sendCmd(cmd)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetAddedNodeInfoAsync",
"(",
"peer",
"string",
")",
"FutureGetAddedNodeInfoResult",
"{",
"cmd",
":=",
"btcjson",
".",
"NewGetAddedNodeInfoCmd",
"(",
"true",
",",
"&",
"peer",
")",
"\n",
"return",
"c",
".",
"sendCmd",
"(... | // GetAddedNodeInfoAsync returns an instance of a type that can be used to get
// the result of the RPC at some future time by invoking the Receive function on
// the returned instance.
//
// See GetAddedNodeInfo for the blocking version and more details. | [
"GetAddedNodeInfoAsync",
"returns",
"an",
"instance",
"of",
"a",
"type",
"that",
"can",
"be",
"used",
"to",
"get",
"the",
"result",
"of",
"the",
"RPC",
"at",
"some",
"future",
"time",
"by",
"invoking",
"the",
"Receive",
"function",
"on",
"the",
"returned",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L127-L130 |
163,546 | btcsuite/btcd | rpcclient/net.go | GetAddedNodeInfoNoDNSAsync | func (c *Client) GetAddedNodeInfoNoDNSAsync(peer string) FutureGetAddedNodeInfoNoDNSResult {
cmd := btcjson.NewGetAddedNodeInfoCmd(false, &peer)
return c.sendCmd(cmd)
} | go | func (c *Client) GetAddedNodeInfoNoDNSAsync(peer string) FutureGetAddedNodeInfoNoDNSResult {
cmd := btcjson.NewGetAddedNodeInfoCmd(false, &peer)
return c.sendCmd(cmd)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetAddedNodeInfoNoDNSAsync",
"(",
"peer",
"string",
")",
"FutureGetAddedNodeInfoNoDNSResult",
"{",
"cmd",
":=",
"btcjson",
".",
"NewGetAddedNodeInfoCmd",
"(",
"false",
",",
"&",
"peer",
")",
"\n",
"return",
"c",
".",
"sen... | // GetAddedNodeInfoNoDNSAsync returns an instance of a type that can be used to
// get the result of the RPC at some future time by invoking the Receive
// function on the returned instance.
//
// See GetAddedNodeInfoNoDNS for the blocking version and more details. | [
"GetAddedNodeInfoNoDNSAsync",
"returns",
"an",
"instance",
"of",
"a",
"type",
"that",
"can",
"be",
"used",
"to",
"get",
"the",
"result",
"of",
"the",
"RPC",
"at",
"some",
"future",
"time",
"by",
"invoking",
"the",
"Receive",
"function",
"on",
"the",
"returne... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L167-L170 |
163,547 | btcsuite/btcd | rpcclient/net.go | GetConnectionCountAsync | func (c *Client) GetConnectionCountAsync() FutureGetConnectionCountResult {
cmd := btcjson.NewGetConnectionCountCmd()
return c.sendCmd(cmd)
} | go | func (c *Client) GetConnectionCountAsync() FutureGetConnectionCountResult {
cmd := btcjson.NewGetConnectionCountCmd()
return c.sendCmd(cmd)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetConnectionCountAsync",
"(",
")",
"FutureGetConnectionCountResult",
"{",
"cmd",
":=",
"btcjson",
".",
"NewGetConnectionCountCmd",
"(",
")",
"\n",
"return",
"c",
".",
"sendCmd",
"(",
"cmd",
")",
"\n",
"}"
] | // GetConnectionCountAsync returns an instance of a type that can be used to get
// the result of the RPC at some future time by invoking the Receive function on
// the returned instance.
//
// See GetConnectionCount for the blocking version and more details. | [
"GetConnectionCountAsync",
"returns",
"an",
"instance",
"of",
"a",
"type",
"that",
"can",
"be",
"used",
"to",
"get",
"the",
"result",
"of",
"the",
"RPC",
"at",
"some",
"future",
"time",
"by",
"invoking",
"the",
"Receive",
"function",
"on",
"the",
"returned",... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L208-L211 |
163,548 | btcsuite/btcd | rpcclient/net.go | PingAsync | func (c *Client) PingAsync() FuturePingResult {
cmd := btcjson.NewPingCmd()
return c.sendCmd(cmd)
} | go | func (c *Client) PingAsync() FuturePingResult {
cmd := btcjson.NewPingCmd()
return c.sendCmd(cmd)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"PingAsync",
"(",
")",
"FuturePingResult",
"{",
"cmd",
":=",
"btcjson",
".",
"NewPingCmd",
"(",
")",
"\n",
"return",
"c",
".",
"sendCmd",
"(",
"cmd",
")",
"\n",
"}"
] | // PingAsync returns an instance of a type that can be used to get the result of
// the RPC at some future time by invoking the Receive function on the returned
// instance.
//
// See Ping for the blocking version and more details. | [
"PingAsync",
"returns",
"an",
"instance",
"of",
"a",
"type",
"that",
"can",
"be",
"used",
"to",
"get",
"the",
"result",
"of",
"the",
"RPC",
"at",
"some",
"future",
"time",
"by",
"invoking",
"the",
"Receive",
"function",
"on",
"the",
"returned",
"instance",... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L234-L237 |
163,549 | btcsuite/btcd | rpcclient/net.go | Receive | func (r FutureGetPeerInfoResult) Receive() ([]btcjson.GetPeerInfoResult, error) {
res, err := receiveFuture(r)
if err != nil {
return nil, err
}
// Unmarshal result as an array of getpeerinfo result objects.
var peerInfo []btcjson.GetPeerInfoResult
err = json.Unmarshal(res, &peerInfo)
if err != nil {
return... | go | func (r FutureGetPeerInfoResult) Receive() ([]btcjson.GetPeerInfoResult, error) {
res, err := receiveFuture(r)
if err != nil {
return nil, err
}
// Unmarshal result as an array of getpeerinfo result objects.
var peerInfo []btcjson.GetPeerInfoResult
err = json.Unmarshal(res, &peerInfo)
if err != nil {
return... | [
"func",
"(",
"r",
"FutureGetPeerInfoResult",
")",
"Receive",
"(",
")",
"(",
"[",
"]",
"btcjson",
".",
"GetPeerInfoResult",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"receiveFuture",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // Receive waits for the response promised by the future and returns data about
// each connected network peer. | [
"Receive",
"waits",
"for",
"the",
"response",
"promised",
"by",
"the",
"future",
"and",
"returns",
"data",
"about",
"each",
"connected",
"network",
"peer",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L253-L267 |
163,550 | btcsuite/btcd | rpcclient/net.go | GetPeerInfoAsync | func (c *Client) GetPeerInfoAsync() FutureGetPeerInfoResult {
cmd := btcjson.NewGetPeerInfoCmd()
return c.sendCmd(cmd)
} | go | func (c *Client) GetPeerInfoAsync() FutureGetPeerInfoResult {
cmd := btcjson.NewGetPeerInfoCmd()
return c.sendCmd(cmd)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetPeerInfoAsync",
"(",
")",
"FutureGetPeerInfoResult",
"{",
"cmd",
":=",
"btcjson",
".",
"NewGetPeerInfoCmd",
"(",
")",
"\n",
"return",
"c",
".",
"sendCmd",
"(",
"cmd",
")",
"\n",
"}"
] | // GetPeerInfoAsync returns an instance of a type that can be used to get the
// result of the RPC at some future time by invoking the Receive function on the
// returned instance.
//
// See GetPeerInfo for the blocking version and more details. | [
"GetPeerInfoAsync",
"returns",
"an",
"instance",
"of",
"a",
"type",
"that",
"can",
"be",
"used",
"to",
"get",
"the",
"result",
"of",
"the",
"RPC",
"at",
"some",
"future",
"time",
"by",
"invoking",
"the",
"Receive",
"function",
"on",
"the",
"returned",
"ins... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L274-L277 |
163,551 | btcsuite/btcd | rpcclient/net.go | Receive | func (r FutureGetNetTotalsResult) Receive() (*btcjson.GetNetTotalsResult, error) {
res, err := receiveFuture(r)
if err != nil {
return nil, err
}
// Unmarshal result as a getnettotals result object.
var totals btcjson.GetNetTotalsResult
err = json.Unmarshal(res, &totals)
if err != nil {
return nil, err
}
... | go | func (r FutureGetNetTotalsResult) Receive() (*btcjson.GetNetTotalsResult, error) {
res, err := receiveFuture(r)
if err != nil {
return nil, err
}
// Unmarshal result as a getnettotals result object.
var totals btcjson.GetNetTotalsResult
err = json.Unmarshal(res, &totals)
if err != nil {
return nil, err
}
... | [
"func",
"(",
"r",
"FutureGetNetTotalsResult",
")",
"Receive",
"(",
")",
"(",
"*",
"btcjson",
".",
"GetNetTotalsResult",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"receiveFuture",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil... | // Receive waits for the response promised by the future and returns network
// traffic statistics. | [
"Receive",
"waits",
"for",
"the",
"response",
"promised",
"by",
"the",
"future",
"and",
"returns",
"network",
"traffic",
"statistics",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L290-L304 |
163,552 | btcsuite/btcd | rpcclient/net.go | GetNetTotalsAsync | func (c *Client) GetNetTotalsAsync() FutureGetNetTotalsResult {
cmd := btcjson.NewGetNetTotalsCmd()
return c.sendCmd(cmd)
} | go | func (c *Client) GetNetTotalsAsync() FutureGetNetTotalsResult {
cmd := btcjson.NewGetNetTotalsCmd()
return c.sendCmd(cmd)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetNetTotalsAsync",
"(",
")",
"FutureGetNetTotalsResult",
"{",
"cmd",
":=",
"btcjson",
".",
"NewGetNetTotalsCmd",
"(",
")",
"\n",
"return",
"c",
".",
"sendCmd",
"(",
"cmd",
")",
"\n",
"}"
] | // GetNetTotalsAsync returns an instance of a type that can be used to get the
// result of the RPC at some future time by invoking the Receive function on the
// returned instance.
//
// See GetNetTotals for the blocking version and more details. | [
"GetNetTotalsAsync",
"returns",
"an",
"instance",
"of",
"a",
"type",
"that",
"can",
"be",
"used",
"to",
"get",
"the",
"result",
"of",
"the",
"RPC",
"at",
"some",
"future",
"time",
"by",
"invoking",
"the",
"Receive",
"function",
"on",
"the",
"returned",
"in... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcclient/net.go#L311-L314 |
163,553 | btcsuite/btcd | blockchain/mediantime.go | Swap | func (s int64Sorter) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
} | go | func (s int64Sorter) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
} | [
"func",
"(",
"s",
"int64Sorter",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"s",
"[",
"i",
"]",
",",
"s",
"[",
"j",
"]",
"=",
"s",
"[",
"j",
"]",
",",
"s",
"[",
"i",
"]",
"\n",
"}"
] | // Swap swaps the 64-bit integers at the passed indices. It is part of the
// sort.Interface implementation. | [
"Swap",
"swaps",
"the",
"64",
"-",
"bit",
"integers",
"at",
"the",
"passed",
"indices",
".",
"It",
"is",
"part",
"of",
"the",
"sort",
".",
"Interface",
"implementation",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/mediantime.go#L62-L64 |
163,554 | btcsuite/btcd | blockchain/mediantime.go | Less | func (s int64Sorter) Less(i, j int) bool {
return s[i] < s[j]
} | go | func (s int64Sorter) Less(i, j int) bool {
return s[i] < s[j]
} | [
"func",
"(",
"s",
"int64Sorter",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"s",
"[",
"i",
"]",
"<",
"s",
"[",
"j",
"]",
"\n",
"}"
] | // Less returns whether the 64-bit integer with index i should sort before the
// 64-bit integer with index j. It is part of the sort.Interface
// implementation. | [
"Less",
"returns",
"whether",
"the",
"64",
"-",
"bit",
"integer",
"with",
"index",
"i",
"should",
"sort",
"before",
"the",
"64",
"-",
"bit",
"integer",
"with",
"index",
"j",
".",
"It",
"is",
"part",
"of",
"the",
"sort",
".",
"Interface",
"implementation"... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/mediantime.go#L69-L71 |
163,555 | btcsuite/btcd | blockchain/mediantime.go | AdjustedTime | func (m *medianTime) AdjustedTime() time.Time {
m.mtx.Lock()
defer m.mtx.Unlock()
// Limit the adjusted time to 1 second precision.
now := time.Unix(time.Now().Unix(), 0)
return now.Add(time.Duration(m.offsetSecs) * time.Second)
} | go | func (m *medianTime) AdjustedTime() time.Time {
m.mtx.Lock()
defer m.mtx.Unlock()
// Limit the adjusted time to 1 second precision.
now := time.Unix(time.Now().Unix(), 0)
return now.Add(time.Duration(m.offsetSecs) * time.Second)
} | [
"func",
"(",
"m",
"*",
"medianTime",
")",
"AdjustedTime",
"(",
")",
"time",
".",
"Time",
"{",
"m",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"// Limit the adjusted time to 1 second precision.",
"n... | // AdjustedTime returns the current time adjusted by the median time offset as
// calculated from the time samples added by AddTimeSample.
//
// This function is safe for concurrent access and is part of the
// MedianTimeSource interface implementation. | [
"AdjustedTime",
"returns",
"the",
"current",
"time",
"adjusted",
"by",
"the",
"median",
"time",
"offset",
"as",
"calculated",
"from",
"the",
"time",
"samples",
"added",
"by",
"AddTimeSample",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"access",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/mediantime.go#L93-L100 |
163,556 | btcsuite/btcd | blockchain/mediantime.go | AddTimeSample | func (m *medianTime) AddTimeSample(sourceID string, timeVal time.Time) {
m.mtx.Lock()
defer m.mtx.Unlock()
// Don't add time data from the same source.
if _, exists := m.knownIDs[sourceID]; exists {
return
}
m.knownIDs[sourceID] = struct{}{}
// Truncate the provided offset to seconds and append it to the sli... | go | func (m *medianTime) AddTimeSample(sourceID string, timeVal time.Time) {
m.mtx.Lock()
defer m.mtx.Unlock()
// Don't add time data from the same source.
if _, exists := m.knownIDs[sourceID]; exists {
return
}
m.knownIDs[sourceID] = struct{}{}
// Truncate the provided offset to seconds and append it to the sli... | [
"func",
"(",
"m",
"*",
"medianTime",
")",
"AddTimeSample",
"(",
"sourceID",
"string",
",",
"timeVal",
"time",
".",
"Time",
")",
"{",
"m",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"// Don't ... | // AddTimeSample adds a time sample that is used when determining the median
// time of the added samples.
//
// This function is safe for concurrent access and is part of the
// MedianTimeSource interface implementation. | [
"AddTimeSample",
"adds",
"a",
"time",
"sample",
"that",
"is",
"used",
"when",
"determining",
"the",
"median",
"time",
"of",
"the",
"added",
"samples",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"access",
"and",
"is",
"part",
"of",
"the",
"... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/mediantime.go#L107-L194 |
163,557 | btcsuite/btcd | blockchain/mediantime.go | Offset | func (m *medianTime) Offset() time.Duration {
m.mtx.Lock()
defer m.mtx.Unlock()
return time.Duration(m.offsetSecs) * time.Second
} | go | func (m *medianTime) Offset() time.Duration {
m.mtx.Lock()
defer m.mtx.Unlock()
return time.Duration(m.offsetSecs) * time.Second
} | [
"func",
"(",
"m",
"*",
"medianTime",
")",
"Offset",
"(",
")",
"time",
".",
"Duration",
"{",
"m",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"time",
".",
"Duration",
"(",
"m",
".... | // Offset returns the number of seconds to adjust the local clock based upon the
// median of the time samples added by AddTimeData.
//
// This function is safe for concurrent access and is part of the
// MedianTimeSource interface implementation. | [
"Offset",
"returns",
"the",
"number",
"of",
"seconds",
"to",
"adjust",
"the",
"local",
"clock",
"based",
"upon",
"the",
"median",
"of",
"the",
"time",
"samples",
"added",
"by",
"AddTimeData",
".",
"This",
"function",
"is",
"safe",
"for",
"concurrent",
"acces... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/mediantime.go#L201-L206 |
163,558 | btcsuite/btcd | blockchain/mediantime.go | NewMedianTime | func NewMedianTime() MedianTimeSource {
return &medianTime{
knownIDs: make(map[string]struct{}),
offsets: make([]int64, 0, maxMedianTimeEntries),
}
} | go | func NewMedianTime() MedianTimeSource {
return &medianTime{
knownIDs: make(map[string]struct{}),
offsets: make([]int64, 0, maxMedianTimeEntries),
}
} | [
"func",
"NewMedianTime",
"(",
")",
"MedianTimeSource",
"{",
"return",
"&",
"medianTime",
"{",
"knownIDs",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
")",
",",
"offsets",
":",
"make",
"(",
"[",
"]",
"int64",
",",
"0",
",",
"maxMe... | // NewMedianTime returns a new instance of concurrency-safe implementation of
// the MedianTimeSource interface. The returned implementation contains the
// rules necessary for proper time handling in the chain consensus rules and
// expects the time samples to be added from the timestamp field of the version
// messa... | [
"NewMedianTime",
"returns",
"a",
"new",
"instance",
"of",
"concurrency",
"-",
"safe",
"implementation",
"of",
"the",
"MedianTimeSource",
"interface",
".",
"The",
"returned",
"implementation",
"contains",
"the",
"rules",
"necessary",
"for",
"proper",
"time",
"handlin... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/blockchain/mediantime.go#L213-L218 |
163,559 | btcsuite/btcd | rpcwebsocket.go | WebsocketHandler | func (s *rpcServer) WebsocketHandler(conn *websocket.Conn, remoteAddr string,
authenticated bool, isAdmin bool) {
// Clear the read deadline that was set before the websocket hijacked
// the connection.
conn.SetReadDeadline(timeZeroVal)
// Limit max number of websocket clients.
rpcsLog.Infof("New websocket clie... | go | func (s *rpcServer) WebsocketHandler(conn *websocket.Conn, remoteAddr string,
authenticated bool, isAdmin bool) {
// Clear the read deadline that was set before the websocket hijacked
// the connection.
conn.SetReadDeadline(timeZeroVal)
// Limit max number of websocket clients.
rpcsLog.Infof("New websocket clie... | [
"func",
"(",
"s",
"*",
"rpcServer",
")",
"WebsocketHandler",
"(",
"conn",
"*",
"websocket",
".",
"Conn",
",",
"remoteAddr",
"string",
",",
"authenticated",
"bool",
",",
"isAdmin",
"bool",
")",
"{",
"// Clear the read deadline that was set before the websocket hijacked... | // WebsocketHandler handles a new websocket client by creating a new wsClient,
// starting it, and blocking until the connection closes. Since it blocks, it
// must be run in a separate goroutine. It should be invoked from the websocket
// server handler which runs each new connection in a new goroutine thereby
// sa... | [
"WebsocketHandler",
"handles",
"a",
"new",
"websocket",
"client",
"by",
"creating",
"a",
"new",
"wsClient",
"starting",
"it",
"and",
"blocking",
"until",
"the",
"connection",
"closes",
".",
"Since",
"it",
"blocks",
"it",
"must",
"be",
"run",
"in",
"a",
"sepa... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L86-L117 |
163,560 | btcsuite/btcd | rpcwebsocket.go | queueHandler | func queueHandler(in <-chan interface{}, out chan<- interface{}, quit <-chan struct{}) {
var q []interface{}
var dequeue chan<- interface{}
skipQueue := out
var next interface{}
out:
for {
select {
case n, ok := <-in:
if !ok {
// Sender closed input channel.
break out
}
// Either send to out ... | go | func queueHandler(in <-chan interface{}, out chan<- interface{}, quit <-chan struct{}) {
var q []interface{}
var dequeue chan<- interface{}
skipQueue := out
var next interface{}
out:
for {
select {
case n, ok := <-in:
if !ok {
// Sender closed input channel.
break out
}
// Either send to out ... | [
"func",
"queueHandler",
"(",
"in",
"<-",
"chan",
"interface",
"{",
"}",
",",
"out",
"chan",
"<-",
"interface",
"{",
"}",
",",
"quit",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"var",
"q",
"[",
"]",
"interface",
"{",
"}",
"\n",
"var",
"dequeue",
... | // queueHandler manages a queue of empty interfaces, reading from in and
// sending the oldest unsent to out. This handler stops when either of the
// in or quit channels are closed, and closes out before returning, without
// waiting to send any variables still remaining in the queue. | [
"queueHandler",
"manages",
"a",
"queue",
"of",
"empty",
"interfaces",
"reading",
"from",
"in",
"and",
"sending",
"the",
"oldest",
"unsent",
"to",
"out",
".",
"This",
"handler",
"stops",
"when",
"either",
"of",
"the",
"in",
"or",
"quit",
"channels",
"are",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L151-L193 |
163,561 | btcsuite/btcd | rpcwebsocket.go | queueHandler | func (m *wsNotificationManager) queueHandler() {
queueHandler(m.queueNotification, m.notificationMsgs, m.quit)
m.wg.Done()
} | go | func (m *wsNotificationManager) queueHandler() {
queueHandler(m.queueNotification, m.notificationMsgs, m.quit)
m.wg.Done()
} | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"queueHandler",
"(",
")",
"{",
"queueHandler",
"(",
"m",
".",
"queueNotification",
",",
"m",
".",
"notificationMsgs",
",",
"m",
".",
"quit",
")",
"\n",
"m",
".",
"wg",
".",
"Done",
"(",
")",
"\n",
... | // queueHandler maintains a queue of notifications and notification handler
// control messages. | [
"queueHandler",
"maintains",
"a",
"queue",
"of",
"notifications",
"and",
"notification",
"handler",
"control",
"messages",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L197-L200 |
163,562 | btcsuite/btcd | rpcwebsocket.go | NotifyBlockConnected | func (m *wsNotificationManager) NotifyBlockConnected(block *btcutil.Block) {
// As NotifyBlockConnected will be called by the block manager
// and the RPC server may no longer be running, use a select
// statement to unblock enqueuing the notification once the RPC
// server has begun shutting down.
select {
case ... | go | func (m *wsNotificationManager) NotifyBlockConnected(block *btcutil.Block) {
// As NotifyBlockConnected will be called by the block manager
// and the RPC server may no longer be running, use a select
// statement to unblock enqueuing the notification once the RPC
// server has begun shutting down.
select {
case ... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"NotifyBlockConnected",
"(",
"block",
"*",
"btcutil",
".",
"Block",
")",
"{",
"// As NotifyBlockConnected will be called by the block manager",
"// and the RPC server may no longer be running, use a select",
"// statement to unbl... | // NotifyBlockConnected passes a block newly-connected to the best chain
// to the notification manager for block and transaction notification
// processing. | [
"NotifyBlockConnected",
"passes",
"a",
"block",
"newly",
"-",
"connected",
"to",
"the",
"best",
"chain",
"to",
"the",
"notification",
"manager",
"for",
"block",
"and",
"transaction",
"notification",
"processing",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L205-L214 |
163,563 | btcsuite/btcd | rpcwebsocket.go | NotifyBlockDisconnected | func (m *wsNotificationManager) NotifyBlockDisconnected(block *btcutil.Block) {
// As NotifyBlockDisconnected will be called by the block manager
// and the RPC server may no longer be running, use a select
// statement to unblock enqueuing the notification once the RPC
// server has begun shutting down.
select {
... | go | func (m *wsNotificationManager) NotifyBlockDisconnected(block *btcutil.Block) {
// As NotifyBlockDisconnected will be called by the block manager
// and the RPC server may no longer be running, use a select
// statement to unblock enqueuing the notification once the RPC
// server has begun shutting down.
select {
... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"NotifyBlockDisconnected",
"(",
"block",
"*",
"btcutil",
".",
"Block",
")",
"{",
"// As NotifyBlockDisconnected will be called by the block manager",
"// and the RPC server may no longer be running, use a select",
"// statement t... | // NotifyBlockDisconnected passes a block disconnected from the best chain
// to the notification manager for block notification processing. | [
"NotifyBlockDisconnected",
"passes",
"a",
"block",
"disconnected",
"from",
"the",
"best",
"chain",
"to",
"the",
"notification",
"manager",
"for",
"block",
"notification",
"processing",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L218-L227 |
163,564 | btcsuite/btcd | rpcwebsocket.go | NotifyMempoolTx | func (m *wsNotificationManager) NotifyMempoolTx(tx *btcutil.Tx, isNew bool) {
n := ¬ificationTxAcceptedByMempool{
isNew: isNew,
tx: tx,
}
// As NotifyMempoolTx will be called by mempool and the RPC server
// may no longer be running, use a select statement to unblock
// enqueuing the notification once t... | go | func (m *wsNotificationManager) NotifyMempoolTx(tx *btcutil.Tx, isNew bool) {
n := ¬ificationTxAcceptedByMempool{
isNew: isNew,
tx: tx,
}
// As NotifyMempoolTx will be called by mempool and the RPC server
// may no longer be running, use a select statement to unblock
// enqueuing the notification once t... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"NotifyMempoolTx",
"(",
"tx",
"*",
"btcutil",
".",
"Tx",
",",
"isNew",
"bool",
")",
"{",
"n",
":=",
"&",
"notificationTxAcceptedByMempool",
"{",
"isNew",
":",
"isNew",
",",
"tx",
":",
"tx",
",",
"}",
... | // NotifyMempoolTx passes a transaction accepted by mempool to the
// notification manager for transaction notification processing. If
// isNew is true, the tx is is a new transaction, rather than one
// added to the mempool during a reorg. | [
"NotifyMempoolTx",
"passes",
"a",
"transaction",
"accepted",
"by",
"mempool",
"to",
"the",
"notification",
"manager",
"for",
"transaction",
"notification",
"processing",
".",
"If",
"isNew",
"is",
"true",
"the",
"tx",
"is",
"is",
"a",
"new",
"transaction",
"rathe... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L233-L247 |
163,565 | btcsuite/btcd | rpcwebsocket.go | NumClients | func (m *wsNotificationManager) NumClients() (n int) {
select {
case n = <-m.numClients:
case <-m.quit: // Use default n (0) if server has shut down.
}
return
} | go | func (m *wsNotificationManager) NumClients() (n int) {
select {
case n = <-m.numClients:
case <-m.quit: // Use default n (0) if server has shut down.
}
return
} | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"NumClients",
"(",
")",
"(",
"n",
"int",
")",
"{",
"select",
"{",
"case",
"n",
"=",
"<-",
"m",
".",
"numClients",
":",
"case",
"<-",
"m",
".",
"quit",
":",
"// Use default n (0) if server has shut down."... | // NumClients returns the number of clients actively being served. | [
"NumClients",
"returns",
"the",
"number",
"of",
"clients",
"actively",
"being",
"served",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L608-L614 |
163,566 | btcsuite/btcd | rpcwebsocket.go | subscribedClients | func (m *wsNotificationManager) subscribedClients(tx *btcutil.Tx,
clients map[chan struct{}]*wsClient) map[chan struct{}]struct{} {
// Use a map of client quit channels as keys to prevent duplicates when
// multiple inputs and/or outputs are relevant to the client.
subscribed := make(map[chan struct{}]struct{})
... | go | func (m *wsNotificationManager) subscribedClients(tx *btcutil.Tx,
clients map[chan struct{}]*wsClient) map[chan struct{}]struct{} {
// Use a map of client quit channels as keys to prevent duplicates when
// multiple inputs and/or outputs are relevant to the client.
subscribed := make(map[chan struct{}]struct{})
... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"subscribedClients",
"(",
"tx",
"*",
"btcutil",
".",
"Tx",
",",
"clients",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
")",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"struct",
... | // subscribedClients returns the set of all websocket client quit channels that
// are registered to receive notifications regarding tx, either due to tx
// spending a watched output or outputting to a watched address. Matching
// client's filters are updated based on this transaction's outputs and output
// addresses... | [
"subscribedClients",
"returns",
"the",
"set",
"of",
"all",
"websocket",
"client",
"quit",
"channels",
"that",
"are",
"registered",
"to",
"receive",
"notifications",
"regarding",
"tx",
"either",
"due",
"to",
"tx",
"spending",
"a",
"watched",
"output",
"or",
"outp... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L633-L688 |
163,567 | btcsuite/btcd | rpcwebsocket.go | notifyBlockConnected | func (*wsNotificationManager) notifyBlockConnected(clients map[chan struct{}]*wsClient,
block *btcutil.Block) {
// Notify interested websocket clients about the connected block.
ntfn := btcjson.NewBlockConnectedNtfn(block.Hash().String(), block.Height(),
block.MsgBlock().Header.Timestamp.Unix())
marshalledJSON, ... | go | func (*wsNotificationManager) notifyBlockConnected(clients map[chan struct{}]*wsClient,
block *btcutil.Block) {
// Notify interested websocket clients about the connected block.
ntfn := btcjson.NewBlockConnectedNtfn(block.Hash().String(), block.Height(),
block.MsgBlock().Header.Timestamp.Unix())
marshalledJSON, ... | [
"func",
"(",
"*",
"wsNotificationManager",
")",
"notifyBlockConnected",
"(",
"clients",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"block",
"*",
"btcutil",
".",
"Block",
")",
"{",
"// Notify interested websocket clients about the connected bl... | // notifyBlockConnected notifies websocket clients that have registered for
// block updates when a block is connected to the main chain. | [
"notifyBlockConnected",
"notifies",
"websocket",
"clients",
"that",
"have",
"registered",
"for",
"block",
"updates",
"when",
"a",
"block",
"is",
"connected",
"to",
"the",
"main",
"chain",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L692-L707 |
163,568 | btcsuite/btcd | rpcwebsocket.go | notifyFilteredBlockConnected | func (m *wsNotificationManager) notifyFilteredBlockConnected(clients map[chan struct{}]*wsClient,
block *btcutil.Block) {
// Create the common portion of the notification that is the same for
// every client.
var w bytes.Buffer
err := block.MsgBlock().Header.Serialize(&w)
if err != nil {
rpcsLog.Errorf("Failed... | go | func (m *wsNotificationManager) notifyFilteredBlockConnected(clients map[chan struct{}]*wsClient,
block *btcutil.Block) {
// Create the common portion of the notification that is the same for
// every client.
var w bytes.Buffer
err := block.MsgBlock().Header.Serialize(&w)
if err != nil {
rpcsLog.Errorf("Failed... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"notifyFilteredBlockConnected",
"(",
"clients",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"block",
"*",
"btcutil",
".",
"Block",
")",
"{",
"// Create the common portion of the notificati... | // notifyFilteredBlockConnected notifies websocket clients that have registered for
// block updates when a block is connected to the main chain. | [
"notifyFilteredBlockConnected",
"notifies",
"websocket",
"clients",
"that",
"have",
"registered",
"for",
"block",
"updates",
"when",
"a",
"block",
"is",
"connected",
"to",
"the",
"main",
"chain",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L735-L776 |
163,569 | btcsuite/btcd | rpcwebsocket.go | notifyForNewTx | func (m *wsNotificationManager) notifyForNewTx(clients map[chan struct{}]*wsClient, tx *btcutil.Tx) {
txHashStr := tx.Hash().String()
mtx := tx.MsgTx()
var amount int64
for _, txOut := range mtx.TxOut {
amount += txOut.Value
}
ntfn := btcjson.NewTxAcceptedNtfn(txHashStr, btcutil.Amount(amount).ToBTC())
marsh... | go | func (m *wsNotificationManager) notifyForNewTx(clients map[chan struct{}]*wsClient, tx *btcutil.Tx) {
txHashStr := tx.Hash().String()
mtx := tx.MsgTx()
var amount int64
for _, txOut := range mtx.TxOut {
amount += txOut.Value
}
ntfn := btcjson.NewTxAcceptedNtfn(txHashStr, btcutil.Amount(amount).ToBTC())
marsh... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"notifyForNewTx",
"(",
"clients",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"tx",
"*",
"btcutil",
".",
"Tx",
")",
"{",
"txHashStr",
":=",
"tx",
".",
"Hash",
"(",
")",
".",
... | // notifyForNewTx notifies websocket clients that have registered for updates
// when a new transaction is added to the memory pool. | [
"notifyForNewTx",
"notifies",
"websocket",
"clients",
"that",
"have",
"registered",
"for",
"updates",
"when",
"a",
"new",
"transaction",
"is",
"added",
"to",
"the",
"memory",
"pool",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L824-L869 |
163,570 | btcsuite/btcd | rpcwebsocket.go | addSpentRequests | func (m *wsNotificationManager) addSpentRequests(opMap map[wire.OutPoint]map[chan struct{}]*wsClient,
wsc *wsClient, ops []*wire.OutPoint) {
for _, op := range ops {
// Track the request in the client as well so it can be quickly
// be removed on disconnect.
wsc.spentRequests[*op] = struct{}{}
// Add the cl... | go | func (m *wsNotificationManager) addSpentRequests(opMap map[wire.OutPoint]map[chan struct{}]*wsClient,
wsc *wsClient, ops []*wire.OutPoint) {
for _, op := range ops {
// Track the request in the client as well so it can be quickly
// be removed on disconnect.
wsc.spentRequests[*op] = struct{}{}
// Add the cl... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"addSpentRequests",
"(",
"opMap",
"map",
"[",
"wire",
".",
"OutPoint",
"]",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"wsc",
"*",
"wsClient",
",",
"ops",
"[",
"]",
"*",
"wi... | // addSpentRequests modifies a map of watched outpoints to sets of websocket
// clients to add a new request watch all of the outpoints in ops and create
// and send a notification when spent to the websocket client wsc. | [
"addSpentRequests",
"modifies",
"a",
"map",
"of",
"watched",
"outpoints",
"to",
"sets",
"of",
"websocket",
"clients",
"to",
"add",
"a",
"new",
"request",
"watch",
"all",
"of",
"the",
"outpoints",
"in",
"ops",
"and",
"create",
"and",
"send",
"a",
"notificatio... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L885-L918 |
163,571 | btcsuite/btcd | rpcwebsocket.go | removeSpentRequest | func (*wsNotificationManager) removeSpentRequest(ops map[wire.OutPoint]map[chan struct{}]*wsClient,
wsc *wsClient, op *wire.OutPoint) {
// Remove the request tracking from the client.
delete(wsc.spentRequests, *op)
// Remove the client from the list to notify.
notifyMap, ok := ops[*op]
if !ok {
rpcsLog.Warnf(... | go | func (*wsNotificationManager) removeSpentRequest(ops map[wire.OutPoint]map[chan struct{}]*wsClient,
wsc *wsClient, op *wire.OutPoint) {
// Remove the request tracking from the client.
delete(wsc.spentRequests, *op)
// Remove the client from the list to notify.
notifyMap, ok := ops[*op]
if !ok {
rpcsLog.Warnf(... | [
"func",
"(",
"*",
"wsNotificationManager",
")",
"removeSpentRequest",
"(",
"ops",
"map",
"[",
"wire",
".",
"OutPoint",
"]",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"wsc",
"*",
"wsClient",
",",
"op",
"*",
"wire",
".",
"OutPoin... | // removeSpentRequest modifies a map of watched outpoints to remove the
// websocket client wsc from the set of clients to be notified when a
// watched outpoint is spent. If wsc is the last client, the outpoint
// key is removed from the map. | [
"removeSpentRequest",
"modifies",
"a",
"map",
"of",
"watched",
"outpoints",
"to",
"remove",
"the",
"websocket",
"client",
"wsc",
"from",
"the",
"set",
"of",
"clients",
"to",
"be",
"notified",
"when",
"a",
"watched",
"outpoint",
"is",
"spent",
".",
"If",
"wsc... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L934-L954 |
163,572 | btcsuite/btcd | rpcwebsocket.go | txHexString | func txHexString(tx *wire.MsgTx) string {
buf := bytes.NewBuffer(make([]byte, 0, tx.SerializeSize()))
// Ignore Serialize's error, as writing to a bytes.buffer cannot fail.
tx.Serialize(buf)
return hex.EncodeToString(buf.Bytes())
} | go | func txHexString(tx *wire.MsgTx) string {
buf := bytes.NewBuffer(make([]byte, 0, tx.SerializeSize()))
// Ignore Serialize's error, as writing to a bytes.buffer cannot fail.
tx.Serialize(buf)
return hex.EncodeToString(buf.Bytes())
} | [
"func",
"txHexString",
"(",
"tx",
"*",
"wire",
".",
"MsgTx",
")",
"string",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"tx",
".",
"SerializeSize",
"(",
")",
")",
")",
"\n",
"// Ignore Serialize's e... | // txHexString returns the serialized transaction encoded in hexadecimal. | [
"txHexString",
"returns",
"the",
"serialized",
"transaction",
"encoded",
"in",
"hexadecimal",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L957-L962 |
163,573 | btcsuite/btcd | rpcwebsocket.go | blockDetails | func blockDetails(block *btcutil.Block, txIndex int) *btcjson.BlockDetails {
if block == nil {
return nil
}
return &btcjson.BlockDetails{
Height: block.Height(),
Hash: block.Hash().String(),
Index: txIndex,
Time: block.MsgBlock().Header.Timestamp.Unix(),
}
} | go | func blockDetails(block *btcutil.Block, txIndex int) *btcjson.BlockDetails {
if block == nil {
return nil
}
return &btcjson.BlockDetails{
Height: block.Height(),
Hash: block.Hash().String(),
Index: txIndex,
Time: block.MsgBlock().Header.Timestamp.Unix(),
}
} | [
"func",
"blockDetails",
"(",
"block",
"*",
"btcutil",
".",
"Block",
",",
"txIndex",
"int",
")",
"*",
"btcjson",
".",
"BlockDetails",
"{",
"if",
"block",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"btcjson",
".",
"BlockDetails",
... | // blockDetails creates a BlockDetails struct to include in btcws notifications
// from a block and a transaction's block index. | [
"blockDetails",
"creates",
"a",
"BlockDetails",
"struct",
"to",
"include",
"in",
"btcws",
"notifications",
"from",
"a",
"block",
"and",
"a",
"transaction",
"s",
"block",
"index",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L966-L976 |
163,574 | btcsuite/btcd | rpcwebsocket.go | newRedeemingTxNotification | func newRedeemingTxNotification(txHex string, index int, block *btcutil.Block) ([]byte, error) {
// Create and marshal the notification.
ntfn := btcjson.NewRedeemingTxNtfn(txHex, blockDetails(block, index))
return btcjson.MarshalCmd(nil, ntfn)
} | go | func newRedeemingTxNotification(txHex string, index int, block *btcutil.Block) ([]byte, error) {
// Create and marshal the notification.
ntfn := btcjson.NewRedeemingTxNtfn(txHex, blockDetails(block, index))
return btcjson.MarshalCmd(nil, ntfn)
} | [
"func",
"newRedeemingTxNotification",
"(",
"txHex",
"string",
",",
"index",
"int",
",",
"block",
"*",
"btcutil",
".",
"Block",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Create and marshal the notification.",
"ntfn",
":=",
"btcjson",
".",
"NewRede... | // newRedeemingTxNotification returns a new marshalled redeemingtx notification
// with the passed parameters. | [
"newRedeemingTxNotification",
"returns",
"a",
"new",
"marshalled",
"redeemingtx",
"notification",
"with",
"the",
"passed",
"parameters",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L980-L984 |
163,575 | btcsuite/btcd | rpcwebsocket.go | notifyForTxOuts | func (m *wsNotificationManager) notifyForTxOuts(ops map[wire.OutPoint]map[chan struct{}]*wsClient,
addrs map[string]map[chan struct{}]*wsClient, tx *btcutil.Tx, block *btcutil.Block) {
// Nothing to do if nobody is listening for address notifications.
if len(addrs) == 0 {
return
}
txHex := ""
wscNotified := m... | go | func (m *wsNotificationManager) notifyForTxOuts(ops map[wire.OutPoint]map[chan struct{}]*wsClient,
addrs map[string]map[chan struct{}]*wsClient, tx *btcutil.Tx, block *btcutil.Block) {
// Nothing to do if nobody is listening for address notifications.
if len(addrs) == 0 {
return
}
txHex := ""
wscNotified := m... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"notifyForTxOuts",
"(",
"ops",
"map",
"[",
"wire",
".",
"OutPoint",
"]",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"addrs",
"map",
"[",
"string",
"]",
"map",
"[",
"chan",
"... | // notifyForTxOuts examines each transaction output, notifying interested
// websocket clients of the transaction if an output spends to a watched
// address. A spent notification request is automatically registered for
// the client for each matching output. | [
"notifyForTxOuts",
"examines",
"each",
"transaction",
"output",
"notifying",
"interested",
"websocket",
"clients",
"of",
"the",
"transaction",
"if",
"an",
"output",
"spends",
"to",
"a",
"watched",
"address",
".",
"A",
"spent",
"notification",
"request",
"is",
"aut... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L990-L1036 |
163,576 | btcsuite/btcd | rpcwebsocket.go | notifyRelevantTxAccepted | func (m *wsNotificationManager) notifyRelevantTxAccepted(tx *btcutil.Tx,
clients map[chan struct{}]*wsClient) {
clientsToNotify := m.subscribedClients(tx, clients)
if len(clientsToNotify) != 0 {
n := btcjson.NewRelevantTxAcceptedNtfn(txHexString(tx.MsgTx()))
marshalled, err := btcjson.MarshalCmd(nil, n)
if e... | go | func (m *wsNotificationManager) notifyRelevantTxAccepted(tx *btcutil.Tx,
clients map[chan struct{}]*wsClient) {
clientsToNotify := m.subscribedClients(tx, clients)
if len(clientsToNotify) != 0 {
n := btcjson.NewRelevantTxAcceptedNtfn(txHexString(tx.MsgTx()))
marshalled, err := btcjson.MarshalCmd(nil, n)
if e... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"notifyRelevantTxAccepted",
"(",
"tx",
"*",
"btcutil",
".",
"Tx",
",",
"clients",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
")",
"{",
"clientsToNotify",
":=",
"m",
".",
"subscribedCli... | // notifyRelevantTxAccepted examines the inputs and outputs of the passed
// transaction, notifying websocket clients of outputs spending to a watched
// address and inputs spending a watched outpoint. Any outputs paying to a
// watched address result in the output being watched as well for future
// notifications. | [
"notifyRelevantTxAccepted",
"examines",
"the",
"inputs",
"and",
"outputs",
"of",
"the",
"passed",
"transaction",
"notifying",
"websocket",
"clients",
"of",
"outputs",
"spending",
"to",
"a",
"watched",
"address",
"and",
"inputs",
"spending",
"a",
"watched",
"outpoint... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1043-L1059 |
163,577 | btcsuite/btcd | rpcwebsocket.go | notifyForTx | func (m *wsNotificationManager) notifyForTx(ops map[wire.OutPoint]map[chan struct{}]*wsClient,
addrs map[string]map[chan struct{}]*wsClient, tx *btcutil.Tx, block *btcutil.Block) {
if len(ops) != 0 {
m.notifyForTxIns(ops, tx, block)
}
if len(addrs) != 0 {
m.notifyForTxOuts(ops, addrs, tx, block)
}
} | go | func (m *wsNotificationManager) notifyForTx(ops map[wire.OutPoint]map[chan struct{}]*wsClient,
addrs map[string]map[chan struct{}]*wsClient, tx *btcutil.Tx, block *btcutil.Block) {
if len(ops) != 0 {
m.notifyForTxIns(ops, tx, block)
}
if len(addrs) != 0 {
m.notifyForTxOuts(ops, addrs, tx, block)
}
} | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"notifyForTx",
"(",
"ops",
"map",
"[",
"wire",
".",
"OutPoint",
"]",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"addrs",
"map",
"[",
"string",
"]",
"map",
"[",
"chan",
"stru... | // notifyForTx examines the inputs and outputs of the passed transaction,
// notifying websocket clients of outputs spending to a watched address
// and inputs spending a watched outpoint. | [
"notifyForTx",
"examines",
"the",
"inputs",
"and",
"outputs",
"of",
"the",
"passed",
"transaction",
"notifying",
"websocket",
"clients",
"of",
"outputs",
"spending",
"to",
"a",
"watched",
"address",
"and",
"inputs",
"spending",
"a",
"watched",
"outpoint",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1064-L1073 |
163,578 | btcsuite/btcd | rpcwebsocket.go | notifyForTxIns | func (m *wsNotificationManager) notifyForTxIns(ops map[wire.OutPoint]map[chan struct{}]*wsClient,
tx *btcutil.Tx, block *btcutil.Block) {
// Nothing to do if nobody is watching outpoints.
if len(ops) == 0 {
return
}
txHex := ""
wscNotified := make(map[chan struct{}]struct{})
for _, txIn := range tx.MsgTx().T... | go | func (m *wsNotificationManager) notifyForTxIns(ops map[wire.OutPoint]map[chan struct{}]*wsClient,
tx *btcutil.Tx, block *btcutil.Block) {
// Nothing to do if nobody is watching outpoints.
if len(ops) == 0 {
return
}
txHex := ""
wscNotified := make(map[chan struct{}]struct{})
for _, txIn := range tx.MsgTx().T... | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"notifyForTxIns",
"(",
"ops",
"map",
"[",
"wire",
".",
"OutPoint",
"]",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"tx",
"*",
"btcutil",
".",
"Tx",
",",
"block",
"*",
"btcut... | // notifyForTxIns examines the inputs of the passed transaction and sends
// interested websocket clients a redeemingtx notification if any inputs
// spend a watched output. If block is non-nil, any matching spent
// requests are removed. | [
"notifyForTxIns",
"examines",
"the",
"inputs",
"of",
"the",
"passed",
"transaction",
"and",
"sends",
"interested",
"websocket",
"clients",
"a",
"redeemingtx",
"notification",
"if",
"any",
"inputs",
"spend",
"a",
"watched",
"output",
".",
"If",
"block",
"is",
"no... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1079-L1112 |
163,579 | btcsuite/btcd | rpcwebsocket.go | RegisterTxOutAddressRequests | func (m *wsNotificationManager) RegisterTxOutAddressRequests(wsc *wsClient, addrs []string) {
m.queueNotification <- ¬ificationRegisterAddr{
wsc: wsc,
addrs: addrs,
}
} | go | func (m *wsNotificationManager) RegisterTxOutAddressRequests(wsc *wsClient, addrs []string) {
m.queueNotification <- ¬ificationRegisterAddr{
wsc: wsc,
addrs: addrs,
}
} | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"RegisterTxOutAddressRequests",
"(",
"wsc",
"*",
"wsClient",
",",
"addrs",
"[",
"]",
"string",
")",
"{",
"m",
".",
"queueNotification",
"<-",
"&",
"notificationRegisterAddr",
"{",
"wsc",
":",
"wsc",
",",
"... | // RegisterTxOutAddressRequests requests notifications to the passed websocket
// client when a transaction output spends to the passed address. | [
"RegisterTxOutAddressRequests",
"requests",
"notifications",
"to",
"the",
"passed",
"websocket",
"client",
"when",
"a",
"transaction",
"output",
"spends",
"to",
"the",
"passed",
"address",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1116-L1121 |
163,580 | btcsuite/btcd | rpcwebsocket.go | addAddrRequests | func (*wsNotificationManager) addAddrRequests(addrMap map[string]map[chan struct{}]*wsClient,
wsc *wsClient, addrs []string) {
for _, addr := range addrs {
// Track the request in the client as well so it can be quickly be
// removed on disconnect.
wsc.addrRequests[addr] = struct{}{}
// Add the client to th... | go | func (*wsNotificationManager) addAddrRequests(addrMap map[string]map[chan struct{}]*wsClient,
wsc *wsClient, addrs []string) {
for _, addr := range addrs {
// Track the request in the client as well so it can be quickly be
// removed on disconnect.
wsc.addrRequests[addr] = struct{}{}
// Add the client to th... | [
"func",
"(",
"*",
"wsNotificationManager",
")",
"addAddrRequests",
"(",
"addrMap",
"map",
"[",
"string",
"]",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"wsc",
"*",
"wsClient",
",",
"addrs",
"[",
"]",
"string",
")",
"{",
"for",
... | // addAddrRequests adds the websocket client wsc to the address to client set
// addrMap so wsc will be notified for any mempool or block transaction outputs
// spending to any of the addresses in addrs. | [
"addAddrRequests",
"adds",
"the",
"websocket",
"client",
"wsc",
"to",
"the",
"address",
"to",
"client",
"set",
"addrMap",
"so",
"wsc",
"will",
"be",
"notified",
"for",
"any",
"mempool",
"or",
"block",
"transaction",
"outputs",
"spending",
"to",
"any",
"of",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1126-L1143 |
163,581 | btcsuite/btcd | rpcwebsocket.go | UnregisterTxOutAddressRequest | func (m *wsNotificationManager) UnregisterTxOutAddressRequest(wsc *wsClient, addr string) {
m.queueNotification <- ¬ificationUnregisterAddr{
wsc: wsc,
addr: addr,
}
} | go | func (m *wsNotificationManager) UnregisterTxOutAddressRequest(wsc *wsClient, addr string) {
m.queueNotification <- ¬ificationUnregisterAddr{
wsc: wsc,
addr: addr,
}
} | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"UnregisterTxOutAddressRequest",
"(",
"wsc",
"*",
"wsClient",
",",
"addr",
"string",
")",
"{",
"m",
".",
"queueNotification",
"<-",
"&",
"notificationUnregisterAddr",
"{",
"wsc",
":",
"wsc",
",",
"addr",
":"... | // UnregisterTxOutAddressRequest removes a request from the passed websocket
// client to be notified when a transaction spends to the passed address. | [
"UnregisterTxOutAddressRequest",
"removes",
"a",
"request",
"from",
"the",
"passed",
"websocket",
"client",
"to",
"be",
"notified",
"when",
"a",
"transaction",
"spends",
"to",
"the",
"passed",
"address",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1147-L1152 |
163,582 | btcsuite/btcd | rpcwebsocket.go | removeAddrRequest | func (*wsNotificationManager) removeAddrRequest(addrs map[string]map[chan struct{}]*wsClient,
wsc *wsClient, addr string) {
// Remove the request tracking from the client.
delete(wsc.addrRequests, addr)
// Remove the client from the list to notify.
cmap, ok := addrs[addr]
if !ok {
rpcsLog.Warnf("Attempt to re... | go | func (*wsNotificationManager) removeAddrRequest(addrs map[string]map[chan struct{}]*wsClient,
wsc *wsClient, addr string) {
// Remove the request tracking from the client.
delete(wsc.addrRequests, addr)
// Remove the client from the list to notify.
cmap, ok := addrs[addr]
if !ok {
rpcsLog.Warnf("Attempt to re... | [
"func",
"(",
"*",
"wsNotificationManager",
")",
"removeAddrRequest",
"(",
"addrs",
"map",
"[",
"string",
"]",
"map",
"[",
"chan",
"struct",
"{",
"}",
"]",
"*",
"wsClient",
",",
"wsc",
"*",
"wsClient",
",",
"addr",
"string",
")",
"{",
"// Remove the request... | // removeAddrRequest removes the websocket client wsc from the address to
// client set addrs so it will no longer receive notification updates for
// any transaction outputs send to addr. | [
"removeAddrRequest",
"removes",
"the",
"websocket",
"client",
"wsc",
"from",
"the",
"address",
"to",
"client",
"set",
"addrs",
"so",
"it",
"will",
"no",
"longer",
"receive",
"notification",
"updates",
"for",
"any",
"transaction",
"outputs",
"send",
"to",
"addr",... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1157-L1177 |
163,583 | btcsuite/btcd | rpcwebsocket.go | RemoveClient | func (m *wsNotificationManager) RemoveClient(wsc *wsClient) {
select {
case m.queueNotification <- (*notificationUnregisterClient)(wsc):
case <-m.quit:
}
} | go | func (m *wsNotificationManager) RemoveClient(wsc *wsClient) {
select {
case m.queueNotification <- (*notificationUnregisterClient)(wsc):
case <-m.quit:
}
} | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"RemoveClient",
"(",
"wsc",
"*",
"wsClient",
")",
"{",
"select",
"{",
"case",
"m",
".",
"queueNotification",
"<-",
"(",
"*",
"notificationUnregisterClient",
")",
"(",
"wsc",
")",
":",
"case",
"<-",
"m",
... | // RemoveClient removes the passed websocket client and all notifications
// registered for it. | [
"RemoveClient",
"removes",
"the",
"passed",
"websocket",
"client",
"and",
"all",
"notifications",
"registered",
"for",
"it",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1186-L1191 |
163,584 | btcsuite/btcd | rpcwebsocket.go | Start | func (m *wsNotificationManager) Start() {
m.wg.Add(2)
go m.queueHandler()
go m.notificationHandler()
} | go | func (m *wsNotificationManager) Start() {
m.wg.Add(2)
go m.queueHandler()
go m.notificationHandler()
} | [
"func",
"(",
"m",
"*",
"wsNotificationManager",
")",
"Start",
"(",
")",
"{",
"m",
".",
"wg",
".",
"Add",
"(",
"2",
")",
"\n",
"go",
"m",
".",
"queueHandler",
"(",
")",
"\n",
"go",
"m",
".",
"notificationHandler",
"(",
")",
"\n",
"}"
] | // Start starts the goroutines required for the manager to queue and process
// websocket client notifications. | [
"Start",
"starts",
"the",
"goroutines",
"required",
"for",
"the",
"manager",
"to",
"queue",
"and",
"process",
"websocket",
"client",
"notifications",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1195-L1199 |
163,585 | btcsuite/btcd | rpcwebsocket.go | newWsNotificationManager | func newWsNotificationManager(server *rpcServer) *wsNotificationManager {
return &wsNotificationManager{
server: server,
queueNotification: make(chan interface{}),
notificationMsgs: make(chan interface{}),
numClients: make(chan int),
quit: make(chan struct{}),
}
} | go | func newWsNotificationManager(server *rpcServer) *wsNotificationManager {
return &wsNotificationManager{
server: server,
queueNotification: make(chan interface{}),
notificationMsgs: make(chan interface{}),
numClients: make(chan int),
quit: make(chan struct{}),
}
} | [
"func",
"newWsNotificationManager",
"(",
"server",
"*",
"rpcServer",
")",
"*",
"wsNotificationManager",
"{",
"return",
"&",
"wsNotificationManager",
"{",
"server",
":",
"server",
",",
"queueNotification",
":",
"make",
"(",
"chan",
"interface",
"{",
"}",
")",
","... | // newWsNotificationManager returns a new notification manager ready for use.
// See wsNotificationManager for more details. | [
"newWsNotificationManager",
"returns",
"a",
"new",
"notification",
"manager",
"ready",
"for",
"use",
".",
"See",
"wsNotificationManager",
"for",
"more",
"details",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1215-L1223 |
163,586 | btcsuite/btcd | rpcwebsocket.go | serviceRequest | func (c *wsClient) serviceRequest(r *parsedRPCCmd) {
var (
result interface{}
err error
)
// Lookup the websocket extension for the command and if it doesn't
// exist fallback to handling the command as a standard command.
wsHandler, ok := wsHandlers[r.method]
if ok {
result, err = wsHandler(c, r.cmd)
... | go | func (c *wsClient) serviceRequest(r *parsedRPCCmd) {
var (
result interface{}
err error
)
// Lookup the websocket extension for the command and if it doesn't
// exist fallback to handling the command as a standard command.
wsHandler, ok := wsHandlers[r.method]
if ok {
result, err = wsHandler(c, r.cmd)
... | [
"func",
"(",
"c",
"*",
"wsClient",
")",
"serviceRequest",
"(",
"r",
"*",
"parsedRPCCmd",
")",
"{",
"var",
"(",
"result",
"interface",
"{",
"}",
"\n",
"err",
"error",
"\n",
")",
"\n\n",
"// Lookup the websocket extension for the command and if it doesn't",
"// exis... | // serviceRequest services a parsed RPC request by looking up and executing the
// appropriate RPC handler. The response is marshalled and sent to the
// websocket client. | [
"serviceRequest",
"services",
"a",
"parsed",
"RPC",
"request",
"by",
"looking",
"up",
"and",
"executing",
"the",
"appropriate",
"RPC",
"handler",
".",
"The",
"response",
"is",
"marshalled",
"and",
"sent",
"to",
"the",
"websocket",
"client",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1484-L1505 |
163,587 | btcsuite/btcd | rpcwebsocket.go | outHandler | func (c *wsClient) outHandler() {
out:
for {
// Send any messages ready for send until the quit channel is
// closed.
select {
case r := <-c.sendChan:
err := c.conn.WriteMessage(websocket.TextMessage, r.msg)
if err != nil {
c.Disconnect()
break out
}
if r.doneChan != nil {
r.doneChan <-... | go | func (c *wsClient) outHandler() {
out:
for {
// Send any messages ready for send until the quit channel is
// closed.
select {
case r := <-c.sendChan:
err := c.conn.WriteMessage(websocket.TextMessage, r.msg)
if err != nil {
c.Disconnect()
break out
}
if r.doneChan != nil {
r.doneChan <-... | [
"func",
"(",
"c",
"*",
"wsClient",
")",
"outHandler",
"(",
")",
"{",
"out",
":",
"for",
"{",
"// Send any messages ready for send until the quit channel is",
"// closed.",
"select",
"{",
"case",
"r",
":=",
"<-",
"c",
".",
"sendChan",
":",
"err",
":=",
"c",
"... | // outHandler handles all outgoing messages for the websocket connection. It
// must be run as a goroutine. It uses a buffered channel to serialize output
// messages while allowing the sender to continue running asynchronously. It
// must be run as a goroutine. | [
"outHandler",
"handles",
"all",
"outgoing",
"messages",
"for",
"the",
"websocket",
"connection",
".",
"It",
"must",
"be",
"run",
"as",
"a",
"goroutine",
".",
"It",
"uses",
"a",
"buffered",
"channel",
"to",
"serialize",
"output",
"messages",
"while",
"allowing"... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1584-L1620 |
163,588 | btcsuite/btcd | rpcwebsocket.go | SendMessage | func (c *wsClient) SendMessage(marshalledJSON []byte, doneChan chan bool) {
// Don't send the message if disconnected.
if c.Disconnected() {
if doneChan != nil {
doneChan <- false
}
return
}
c.sendChan <- wsResponse{msg: marshalledJSON, doneChan: doneChan}
} | go | func (c *wsClient) SendMessage(marshalledJSON []byte, doneChan chan bool) {
// Don't send the message if disconnected.
if c.Disconnected() {
if doneChan != nil {
doneChan <- false
}
return
}
c.sendChan <- wsResponse{msg: marshalledJSON, doneChan: doneChan}
} | [
"func",
"(",
"c",
"*",
"wsClient",
")",
"SendMessage",
"(",
"marshalledJSON",
"[",
"]",
"byte",
",",
"doneChan",
"chan",
"bool",
")",
"{",
"// Don't send the message if disconnected.",
"if",
"c",
".",
"Disconnected",
"(",
")",
"{",
"if",
"doneChan",
"!=",
"n... | // SendMessage sends the passed json to the websocket client. It is backed
// by a buffered channel, so it will not block until the send channel is full.
// Note however that QueueNotification must be used for sending async
// notifications instead of the this function. This approach allows a limit to
// the number o... | [
"SendMessage",
"sends",
"the",
"passed",
"json",
"to",
"the",
"websocket",
"client",
".",
"It",
"is",
"backed",
"by",
"a",
"buffered",
"channel",
"so",
"it",
"will",
"not",
"block",
"until",
"the",
"send",
"channel",
"is",
"full",
".",
"Note",
"however",
... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1628-L1638 |
163,589 | btcsuite/btcd | rpcwebsocket.go | QueueNotification | func (c *wsClient) QueueNotification(marshalledJSON []byte) error {
// Don't queue the message if disconnected.
if c.Disconnected() {
return ErrClientQuit
}
c.ntfnChan <- marshalledJSON
return nil
} | go | func (c *wsClient) QueueNotification(marshalledJSON []byte) error {
// Don't queue the message if disconnected.
if c.Disconnected() {
return ErrClientQuit
}
c.ntfnChan <- marshalledJSON
return nil
} | [
"func",
"(",
"c",
"*",
"wsClient",
")",
"QueueNotification",
"(",
"marshalledJSON",
"[",
"]",
"byte",
")",
"error",
"{",
"// Don't queue the message if disconnected.",
"if",
"c",
".",
"Disconnected",
"(",
")",
"{",
"return",
"ErrClientQuit",
"\n",
"}",
"\n\n",
... | // QueueNotification queues the passed notification to be sent to the websocket
// client. This function, as the name implies, is only intended for
// notifications since it has additional logic to prevent other subsystems, such
// as the memory pool and block manager, from blocking even when the send
// channel is fu... | [
"QueueNotification",
"queues",
"the",
"passed",
"notification",
"to",
"be",
"sent",
"to",
"the",
"websocket",
"client",
".",
"This",
"function",
"as",
"the",
"name",
"implies",
"is",
"only",
"intended",
"for",
"notifications",
"since",
"it",
"has",
"additional",... | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1653-L1661 |
163,590 | btcsuite/btcd | rpcwebsocket.go | Disconnected | func (c *wsClient) Disconnected() bool {
c.Lock()
isDisconnected := c.disconnected
c.Unlock()
return isDisconnected
} | go | func (c *wsClient) Disconnected() bool {
c.Lock()
isDisconnected := c.disconnected
c.Unlock()
return isDisconnected
} | [
"func",
"(",
"c",
"*",
"wsClient",
")",
"Disconnected",
"(",
")",
"bool",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"isDisconnected",
":=",
"c",
".",
"disconnected",
"\n",
"c",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"isDisconnected",
"\n",
"}"
] | // Disconnected returns whether or not the websocket client is disconnected. | [
"Disconnected",
"returns",
"whether",
"or",
"not",
"the",
"websocket",
"client",
"is",
"disconnected",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1664-L1670 |
163,591 | btcsuite/btcd | rpcwebsocket.go | Disconnect | func (c *wsClient) Disconnect() {
c.Lock()
defer c.Unlock()
// Nothing to do if already disconnected.
if c.disconnected {
return
}
rpcsLog.Tracef("Disconnecting websocket client %s", c.addr)
close(c.quit)
c.conn.Close()
c.disconnected = true
} | go | func (c *wsClient) Disconnect() {
c.Lock()
defer c.Unlock()
// Nothing to do if already disconnected.
if c.disconnected {
return
}
rpcsLog.Tracef("Disconnecting websocket client %s", c.addr)
close(c.quit)
c.conn.Close()
c.disconnected = true
} | [
"func",
"(",
"c",
"*",
"wsClient",
")",
"Disconnect",
"(",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n\n",
"// Nothing to do if already disconnected.",
"if",
"c",
".",
"disconnected",
"{",
"return",
"\n",
"}",
... | // Disconnect disconnects the websocket client. | [
"Disconnect",
"disconnects",
"the",
"websocket",
"client",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1673-L1686 |
163,592 | btcsuite/btcd | rpcwebsocket.go | Start | func (c *wsClient) Start() {
rpcsLog.Tracef("Starting websocket client %s", c.addr)
// Start processing input and output.
c.wg.Add(3)
go c.inHandler()
go c.notificationQueueHandler()
go c.outHandler()
} | go | func (c *wsClient) Start() {
rpcsLog.Tracef("Starting websocket client %s", c.addr)
// Start processing input and output.
c.wg.Add(3)
go c.inHandler()
go c.notificationQueueHandler()
go c.outHandler()
} | [
"func",
"(",
"c",
"*",
"wsClient",
")",
"Start",
"(",
")",
"{",
"rpcsLog",
".",
"Tracef",
"(",
"\"",
"\"",
",",
"c",
".",
"addr",
")",
"\n\n",
"// Start processing input and output.",
"c",
".",
"wg",
".",
"Add",
"(",
"3",
")",
"\n",
"go",
"c",
".",... | // Start begins processing input and output messages. | [
"Start",
"begins",
"processing",
"input",
"and",
"output",
"messages",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1689-L1697 |
163,593 | btcsuite/btcd | rpcwebsocket.go | handleWebsocketHelp | func handleWebsocketHelp(wsc *wsClient, icmd interface{}) (interface{}, error) {
cmd, ok := icmd.(*btcjson.HelpCmd)
if !ok {
return nil, btcjson.ErrRPCInternal
}
// Provide a usage overview of all commands when no specific command
// was specified.
var command string
if cmd.Command != nil {
command = *cmd.C... | go | func handleWebsocketHelp(wsc *wsClient, icmd interface{}) (interface{}, error) {
cmd, ok := icmd.(*btcjson.HelpCmd)
if !ok {
return nil, btcjson.ErrRPCInternal
}
// Provide a usage overview of all commands when no specific command
// was specified.
var command string
if cmd.Command != nil {
command = *cmd.C... | [
"func",
"handleWebsocketHelp",
"(",
"wsc",
"*",
"wsClient",
",",
"icmd",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"cmd",
",",
"ok",
":=",
"icmd",
".",
"(",
"*",
"btcjson",
".",
"HelpCmd",
")",
"\n",
"if",
"!",... | // handleWebsocketHelp implements the help command for websocket connections. | [
"handleWebsocketHelp",
"implements",
"the",
"help",
"command",
"for",
"websocket",
"connections",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1737-L1781 |
163,594 | btcsuite/btcd | rpcwebsocket.go | handleNotifyBlocks | func handleNotifyBlocks(wsc *wsClient, icmd interface{}) (interface{}, error) {
wsc.server.ntfnMgr.RegisterBlockUpdates(wsc)
return nil, nil
} | go | func handleNotifyBlocks(wsc *wsClient, icmd interface{}) (interface{}, error) {
wsc.server.ntfnMgr.RegisterBlockUpdates(wsc)
return nil, nil
} | [
"func",
"handleNotifyBlocks",
"(",
"wsc",
"*",
"wsClient",
",",
"icmd",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"wsc",
".",
"server",
".",
"ntfnMgr",
".",
"RegisterBlockUpdates",
"(",
"wsc",
")",
"\n",
"return",
... | // handleNotifyBlocks implements the notifyblocks command extension for
// websocket connections. | [
"handleNotifyBlocks",
"implements",
"the",
"notifyblocks",
"command",
"extension",
"for",
"websocket",
"connections",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1830-L1833 |
163,595 | btcsuite/btcd | rpcwebsocket.go | handleSession | func handleSession(wsc *wsClient, icmd interface{}) (interface{}, error) {
return &btcjson.SessionResult{SessionID: wsc.sessionID}, nil
} | go | func handleSession(wsc *wsClient, icmd interface{}) (interface{}, error) {
return &btcjson.SessionResult{SessionID: wsc.sessionID}, nil
} | [
"func",
"handleSession",
"(",
"wsc",
"*",
"wsClient",
",",
"icmd",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"return",
"&",
"btcjson",
".",
"SessionResult",
"{",
"SessionID",
":",
"wsc",
".",
"sessionID",
"}",
",",... | // handleSession implements the session command extension for websocket
// connections. | [
"handleSession",
"implements",
"the",
"session",
"command",
"extension",
"for",
"websocket",
"connections",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1837-L1839 |
163,596 | btcsuite/btcd | rpcwebsocket.go | handleStopNotifyBlocks | func handleStopNotifyBlocks(wsc *wsClient, icmd interface{}) (interface{}, error) {
wsc.server.ntfnMgr.UnregisterBlockUpdates(wsc)
return nil, nil
} | go | func handleStopNotifyBlocks(wsc *wsClient, icmd interface{}) (interface{}, error) {
wsc.server.ntfnMgr.UnregisterBlockUpdates(wsc)
return nil, nil
} | [
"func",
"handleStopNotifyBlocks",
"(",
"wsc",
"*",
"wsClient",
",",
"icmd",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"wsc",
".",
"server",
".",
"ntfnMgr",
".",
"UnregisterBlockUpdates",
"(",
"wsc",
")",
"\n",
"retur... | // handleStopNotifyBlocks implements the stopnotifyblocks command extension for
// websocket connections. | [
"handleStopNotifyBlocks",
"implements",
"the",
"stopnotifyblocks",
"command",
"extension",
"for",
"websocket",
"connections",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1843-L1846 |
163,597 | btcsuite/btcd | rpcwebsocket.go | handleNotifySpent | func handleNotifySpent(wsc *wsClient, icmd interface{}) (interface{}, error) {
cmd, ok := icmd.(*btcjson.NotifySpentCmd)
if !ok {
return nil, btcjson.ErrRPCInternal
}
outpoints, err := deserializeOutpoints(cmd.OutPoints)
if err != nil {
return nil, err
}
wsc.server.ntfnMgr.RegisterSpentRequests(wsc, outpoi... | go | func handleNotifySpent(wsc *wsClient, icmd interface{}) (interface{}, error) {
cmd, ok := icmd.(*btcjson.NotifySpentCmd)
if !ok {
return nil, btcjson.ErrRPCInternal
}
outpoints, err := deserializeOutpoints(cmd.OutPoints)
if err != nil {
return nil, err
}
wsc.server.ntfnMgr.RegisterSpentRequests(wsc, outpoi... | [
"func",
"handleNotifySpent",
"(",
"wsc",
"*",
"wsClient",
",",
"icmd",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"cmd",
",",
"ok",
":=",
"icmd",
".",
"(",
"*",
"btcjson",
".",
"NotifySpentCmd",
")",
"\n",
"if",
... | // handleNotifySpent implements the notifyspent command extension for
// websocket connections. | [
"handleNotifySpent",
"implements",
"the",
"notifyspent",
"command",
"extension",
"for",
"websocket",
"connections",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1850-L1863 |
163,598 | btcsuite/btcd | rpcwebsocket.go | handleNotifyNewTransactions | func handleNotifyNewTransactions(wsc *wsClient, icmd interface{}) (interface{}, error) {
cmd, ok := icmd.(*btcjson.NotifyNewTransactionsCmd)
if !ok {
return nil, btcjson.ErrRPCInternal
}
wsc.verboseTxUpdates = cmd.Verbose != nil && *cmd.Verbose
wsc.server.ntfnMgr.RegisterNewMempoolTxsUpdates(wsc)
return nil, n... | go | func handleNotifyNewTransactions(wsc *wsClient, icmd interface{}) (interface{}, error) {
cmd, ok := icmd.(*btcjson.NotifyNewTransactionsCmd)
if !ok {
return nil, btcjson.ErrRPCInternal
}
wsc.verboseTxUpdates = cmd.Verbose != nil && *cmd.Verbose
wsc.server.ntfnMgr.RegisterNewMempoolTxsUpdates(wsc)
return nil, n... | [
"func",
"handleNotifyNewTransactions",
"(",
"wsc",
"*",
"wsClient",
",",
"icmd",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"cmd",
",",
"ok",
":=",
"icmd",
".",
"(",
"*",
"btcjson",
".",
"NotifyNewTransactionsCmd",
")... | // handleNotifyNewTransations implements the notifynewtransactions command
// extension for websocket connections. | [
"handleNotifyNewTransations",
"implements",
"the",
"notifynewtransactions",
"command",
"extension",
"for",
"websocket",
"connections",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1867-L1876 |
163,599 | btcsuite/btcd | rpcwebsocket.go | handleStopNotifyNewTransactions | func handleStopNotifyNewTransactions(wsc *wsClient, icmd interface{}) (interface{}, error) {
wsc.server.ntfnMgr.UnregisterNewMempoolTxsUpdates(wsc)
return nil, nil
} | go | func handleStopNotifyNewTransactions(wsc *wsClient, icmd interface{}) (interface{}, error) {
wsc.server.ntfnMgr.UnregisterNewMempoolTxsUpdates(wsc)
return nil, nil
} | [
"func",
"handleStopNotifyNewTransactions",
"(",
"wsc",
"*",
"wsClient",
",",
"icmd",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"wsc",
".",
"server",
".",
"ntfnMgr",
".",
"UnregisterNewMempoolTxsUpdates",
"(",
"wsc",
")",... | // handleStopNotifyNewTransations implements the stopnotifynewtransactions
// command extension for websocket connections. | [
"handleStopNotifyNewTransations",
"implements",
"the",
"stopnotifynewtransactions",
"command",
"extension",
"for",
"websocket",
"connections",
"."
] | 96897255fd17525dd12426345d279533780bc4e1 | https://github.com/btcsuite/btcd/blob/96897255fd17525dd12426345d279533780bc4e1/rpcwebsocket.go#L1880-L1883 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.