repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
lightninglabs/neutrino
blockntfns/notification.go
String
func (n *Connected) String() string { return fmt.Sprintf("block connected (height=%d, hash=%v)", n.height, n.header.BlockHash()) }
go
func (n *Connected) String() string { return fmt.Sprintf("block connected (height=%d, hash=%v)", n.height, n.header.BlockHash()) }
[ "func", "(", "n", "*", "Connected", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "n", ".", "height", ",", "n", ".", "header", ".", "BlockHash", "(", ")", ")", "\n", "}" ]
// String returns the string representation of a Connected notification.
[ "String", "returns", "the", "string", "representation", "of", "a", "Connected", "notification", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/notification.go#L57-L60
train
lightninglabs/neutrino
blockntfns/notification.go
NewBlockDisconnected
func NewBlockDisconnected(headerDisconnected wire.BlockHeader, heightDisconnected uint32, chainTip wire.BlockHeader) *Disconnected { return &Disconnected{ headerDisconnected: headerDisconnected, heightDisconnected: heightDisconnected, chainTip: chainTip, } }
go
func NewBlockDisconnected(headerDisconnected wire.BlockHeader, heightDisconnected uint32, chainTip wire.BlockHeader) *Disconnected { return &Disconnected{ headerDisconnected: headerDisconnected, heightDisconnected: heightDisconnected, chainTip: chainTip, } }
[ "func", "NewBlockDisconnected", "(", "headerDisconnected", "wire", ".", "BlockHeader", ",", "heightDisconnected", "uint32", ",", "chainTip", "wire", ".", "BlockHeader", ")", "*", "Disconnected", "{", "return", "&", "Disconnected", "{", "headerDisconnected", ":", "he...
// NewBlockDisconnected creates a Disconnected notification for the given block.
[ "NewBlockDisconnected", "creates", "a", "Disconnected", "notification", "for", "the", "given", "block", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/notification.go#L75-L83
train
lightninglabs/neutrino
blockntfns/notification.go
String
func (n *Disconnected) String() string { return fmt.Sprintf("block disconnected (height=%d, hash=%v)", n.heightDisconnected, n.headerDisconnected.BlockHash()) }
go
func (n *Disconnected) String() string { return fmt.Sprintf("block disconnected (height=%d, hash=%v)", n.heightDisconnected, n.headerDisconnected.BlockHash()) }
[ "func", "(", "n", "*", "Disconnected", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "n", ".", "heightDisconnected", ",", "n", ".", "headerDisconnected", ".", "BlockHash", "(", ")", ")", "\n", "}" ]
// String returns the string representation of a Disconnected notification.
[ "String", "returns", "the", "string", "representation", "of", "a", "Disconnected", "notification", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/notification.go#L102-L105
train
lightninglabs/neutrino
query.go
defaultQueryOptions
func defaultQueryOptions() *queryOptions { return &queryOptions{ timeout: QueryTimeout, numRetries: uint8(QueryNumRetries), peerConnectTimeout: QueryPeerConnectTimeout, encoding: QueryEncoding, optimisticBatch: noBatch, } }
go
func defaultQueryOptions() *queryOptions { return &queryOptions{ timeout: QueryTimeout, numRetries: uint8(QueryNumRetries), peerConnectTimeout: QueryPeerConnectTimeout, encoding: QueryEncoding, optimisticBatch: noBatch, } }
[ "func", "defaultQueryOptions", "(", ")", "*", "queryOptions", "{", "return", "&", "queryOptions", "{", "timeout", ":", "QueryTimeout", ",", "numRetries", ":", "uint8", "(", "QueryNumRetries", ")", ",", "peerConnectTimeout", ":", "QueryPeerConnectTimeout", ",", "en...
// defaultQueryOptions returns a queryOptions set to package-level defaults.
[ "defaultQueryOptions", "returns", "a", "queryOptions", "set", "to", "package", "-", "level", "defaults", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L112-L120
train
lightninglabs/neutrino
query.go
applyQueryOptions
func (qo *queryOptions) applyQueryOptions(options ...QueryOption) { for _, option := range options { option(qo) } }
go
func (qo *queryOptions) applyQueryOptions(options ...QueryOption) { for _, option := range options { option(qo) } }
[ "func", "(", "qo", "*", "queryOptions", ")", "applyQueryOptions", "(", "options", "...", "QueryOption", ")", "{", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "qo", ")", "\n", "}", "\n", "}" ]
// applyQueryOptions updates a queryOptions set with functional options.
[ "applyQueryOptions", "updates", "a", "queryOptions", "set", "with", "functional", "options", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L123-L127
train
lightninglabs/neutrino
query.go
Timeout
func Timeout(timeout time.Duration) QueryOption { return func(qo *queryOptions) { qo.timeout = timeout } }
go
func Timeout(timeout time.Duration) QueryOption { return func(qo *queryOptions) { qo.timeout = timeout } }
[ "func", "Timeout", "(", "timeout", "time", ".", "Duration", ")", "QueryOption", "{", "return", "func", "(", "qo", "*", "queryOptions", ")", "{", "qo", ".", "timeout", "=", "timeout", "\n", "}", "\n", "}" ]
// Timeout is a query option that lets the query know how long to wait for each // peer we ask the query to answer it before moving on.
[ "Timeout", "is", "a", "query", "option", "that", "lets", "the", "query", "know", "how", "long", "to", "wait", "for", "each", "peer", "we", "ask", "the", "query", "to", "answer", "it", "before", "moving", "on", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L131-L135
train
lightninglabs/neutrino
query.go
PeerConnectTimeout
func PeerConnectTimeout(timeout time.Duration) QueryOption { return func(qo *queryOptions) { qo.peerConnectTimeout = timeout } }
go
func PeerConnectTimeout(timeout time.Duration) QueryOption { return func(qo *queryOptions) { qo.peerConnectTimeout = timeout } }
[ "func", "PeerConnectTimeout", "(", "timeout", "time", ".", "Duration", ")", "QueryOption", "{", "return", "func", "(", "qo", "*", "queryOptions", ")", "{", "qo", ".", "peerConnectTimeout", "=", "timeout", "\n", "}", "\n", "}" ]
// PeerConnectTimeout is a query option that lets the query know how long to // wait for the underlying chain service to connect to a peer before giving up // on a query in case we don't have any peers.
[ "PeerConnectTimeout", "is", "a", "query", "option", "that", "lets", "the", "query", "know", "how", "long", "to", "wait", "for", "the", "underlying", "chain", "service", "to", "connect", "to", "a", "peer", "before", "giving", "up", "on", "a", "query", "in",...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L148-L152
train
lightninglabs/neutrino
query.go
Encoding
func Encoding(encoding wire.MessageEncoding) QueryOption { return func(qo *queryOptions) { qo.encoding = encoding } }
go
func Encoding(encoding wire.MessageEncoding) QueryOption { return func(qo *queryOptions) { qo.encoding = encoding } }
[ "func", "Encoding", "(", "encoding", "wire", ".", "MessageEncoding", ")", "QueryOption", "{", "return", "func", "(", "qo", "*", "queryOptions", ")", "{", "qo", ".", "encoding", "=", "encoding", "\n", "}", "\n", "}" ]
// Encoding is a query option that allows the caller to set a message encoding // for the query messages.
[ "Encoding", "is", "a", "query", "option", "that", "allows", "the", "caller", "to", "set", "a", "message", "encoding", "for", "the", "query", "messages", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L156-L160
train
lightninglabs/neutrino
query.go
queryAllPeers
func (s *ChainService) queryAllPeers( // queryMsg is the message to broadcast to all peers. queryMsg wire.Message, // checkResponse is called for every message within the timeout period. // The quit channel lets the query know to terminate because the // required response has been found. This is done by closing t...
go
func (s *ChainService) queryAllPeers( // queryMsg is the message to broadcast to all peers. queryMsg wire.Message, // checkResponse is called for every message within the timeout period. // The quit channel lets the query know to terminate because the // required response has been found. This is done by closing t...
[ "func", "(", "s", "*", "ChainService", ")", "queryAllPeers", "(", "// queryMsg is the message to broadcast to all peers.", "queryMsg", "wire", ".", "Message", ",", "// checkResponse is called for every message within the timeout period.", "// The quit channel lets the query know to ter...
// queryAllPeers is a helper function that sends a query to all peers and waits // for a timeout specified by the QueryTimeout package-level variable or the // Timeout functional option. The NumRetries option is set to 1 by default // unless overridden by the caller.
[ "queryAllPeers", "is", "a", "helper", "function", "that", "sends", "a", "query", "to", "all", "peers", "and", "waits", "for", "a", "timeout", "specified", "by", "the", "QueryTimeout", "package", "-", "level", "variable", "or", "the", "Timeout", "functional", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L496-L609
train
lightninglabs/neutrino
query.go
queryChainServicePeers
func queryChainServicePeers( // s is the ChainService to use. s *ChainService, // queryMsg is the message to send to each peer selected by selectPeer. queryMsg wire.Message, // checkResponse is called for every message within the timeout period. // The quit channel lets the query know to terminate because the ...
go
func queryChainServicePeers( // s is the ChainService to use. s *ChainService, // queryMsg is the message to send to each peer selected by selectPeer. queryMsg wire.Message, // checkResponse is called for every message within the timeout period. // The quit channel lets the query know to terminate because the ...
[ "func", "queryChainServicePeers", "(", "// s is the ChainService to use.", "s", "*", "ChainService", ",", "// queryMsg is the message to send to each peer selected by selectPeer.", "queryMsg", "wire", ".", "Message", ",", "// checkResponse is called for every message within the timeout p...
// queryChainServicePeers is a helper function that sends a query to one or // more peers of the given ChainService, and waits for an answer. The timeout // for queries is set by the QueryTimeout package-level variable or the Timeout // functional option.
[ "queryChainServicePeers", "is", "a", "helper", "function", "that", "sends", "a", "query", "to", "one", "or", "more", "peers", "of", "the", "given", "ChainService", "and", "waits", "for", "an", "answer", ".", "The", "timeout", "for", "queries", "is", "set", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L615-L748
train
lightninglabs/neutrino
query.go
getFilterFromCache
func (s *ChainService) getFilterFromCache(blockHash *chainhash.Hash, filterType filterdb.FilterType) (*gcs.Filter, error) { cacheKey := cache.FilterCacheKey{*blockHash, filterType} filterValue, err := s.FilterCache.Get(cacheKey) if err != nil { return nil, err } return filterValue.(*cache.CacheableFilter).Fi...
go
func (s *ChainService) getFilterFromCache(blockHash *chainhash.Hash, filterType filterdb.FilterType) (*gcs.Filter, error) { cacheKey := cache.FilterCacheKey{*blockHash, filterType} filterValue, err := s.FilterCache.Get(cacheKey) if err != nil { return nil, err } return filterValue.(*cache.CacheableFilter).Fi...
[ "func", "(", "s", "*", "ChainService", ")", "getFilterFromCache", "(", "blockHash", "*", "chainhash", ".", "Hash", ",", "filterType", "filterdb", ".", "FilterType", ")", "(", "*", "gcs", ".", "Filter", ",", "error", ")", "{", "cacheKey", ":=", "cache", "...
// getFilterFromCache returns a filter from ChainService's FilterCache if it // exists, returning nil and error if it doesn't.
[ "getFilterFromCache", "returns", "a", "filter", "from", "ChainService", "s", "FilterCache", "if", "it", "exists", "returning", "nil", "and", "error", "if", "it", "doesn", "t", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L752-L763
train
lightninglabs/neutrino
query.go
putFilterToCache
func (s *ChainService) putFilterToCache(blockHash *chainhash.Hash, filterType filterdb.FilterType, filter *gcs.Filter) (bool, error) { cacheKey := cache.FilterCacheKey{*blockHash, filterType} return s.FilterCache.Put(cacheKey, &cache.CacheableFilter{Filter: filter}) }
go
func (s *ChainService) putFilterToCache(blockHash *chainhash.Hash, filterType filterdb.FilterType, filter *gcs.Filter) (bool, error) { cacheKey := cache.FilterCacheKey{*blockHash, filterType} return s.FilterCache.Put(cacheKey, &cache.CacheableFilter{Filter: filter}) }
[ "func", "(", "s", "*", "ChainService", ")", "putFilterToCache", "(", "blockHash", "*", "chainhash", ".", "Hash", ",", "filterType", "filterdb", ".", "FilterType", ",", "filter", "*", "gcs", ".", "Filter", ")", "(", "bool", ",", "error", ")", "{", "cacheK...
// putFilterToCache inserts a given filter in ChainService's FilterCache.
[ "putFilterToCache", "inserts", "a", "given", "filter", "in", "ChainService", "s", "FilterCache", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L766-L771
train
lightninglabs/neutrino
query.go
queryMsg
func (q *cfiltersQuery) queryMsg() wire.Message { return wire.NewMsgGetCFilters( q.filterType, uint32(q.startHeight), q.stopHash, ) }
go
func (q *cfiltersQuery) queryMsg() wire.Message { return wire.NewMsgGetCFilters( q.filterType, uint32(q.startHeight), q.stopHash, ) }
[ "func", "(", "q", "*", "cfiltersQuery", ")", "queryMsg", "(", ")", "wire", ".", "Message", "{", "return", "wire", ".", "NewMsgGetCFilters", "(", "q", ".", "filterType", ",", "uint32", "(", "q", ".", "startHeight", ")", ",", "q", ".", "stopHash", ",", ...
// queryMsg returns the wire message to perform this query.
[ "queryMsg", "returns", "the", "wire", "message", "to", "perform", "this", "query", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L788-L792
train
lightninglabs/neutrino
query.go
handleCFiltersResponse
func (s *ChainService) handleCFiltersResponse(q *cfiltersQuery, resp wire.Message, quit chan<- struct{}) { // We're only interested in "cfilter" messages. response, ok := resp.(*wire.MsgCFilter) if !ok { return } // If the response doesn't match our request, ignore this message. if q.filterType != response.F...
go
func (s *ChainService) handleCFiltersResponse(q *cfiltersQuery, resp wire.Message, quit chan<- struct{}) { // We're only interested in "cfilter" messages. response, ok := resp.(*wire.MsgCFilter) if !ok { return } // If the response doesn't match our request, ignore this message. if q.filterType != response.F...
[ "func", "(", "s", "*", "ChainService", ")", "handleCFiltersResponse", "(", "q", "*", "cfiltersQuery", ",", "resp", "wire", ".", "Message", ",", "quit", "chan", "<-", "struct", "{", "}", ")", "{", "// We're only interested in \"cfilter\" messages.", "response", "...
// handleCFiltersRespons is called every time we receive a response for the // GetCFilters request.
[ "handleCFiltersRespons", "is", "called", "every", "time", "we", "receive", "a", "response", "for", "the", "GetCFilters", "request", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L928-L1024
train
lightninglabs/neutrino
query.go
GetCFilter
func (s *ChainService) GetCFilter(blockHash chainhash.Hash, filterType wire.FilterType, options ...QueryOption) (*gcs.Filter, error) { // The only supported filter atm is the regular filter, so we'll reject // all other filters. if filterType != wire.GCSFilterRegular { return nil, fmt.Errorf("unknown filter type...
go
func (s *ChainService) GetCFilter(blockHash chainhash.Hash, filterType wire.FilterType, options ...QueryOption) (*gcs.Filter, error) { // The only supported filter atm is the regular filter, so we'll reject // all other filters. if filterType != wire.GCSFilterRegular { return nil, fmt.Errorf("unknown filter type...
[ "func", "(", "s", "*", "ChainService", ")", "GetCFilter", "(", "blockHash", "chainhash", ".", "Hash", ",", "filterType", "wire", ".", "FilterType", ",", "options", "...", "QueryOption", ")", "(", "*", "gcs", ".", "Filter", ",", "error", ")", "{", "// The...
// GetCFilter gets a cfilter from the database. Failing that, it requests the // cfilter from the network and writes it to the database. If extended is true, // an extended filter will be queried for. Otherwise, we'll fetch the regular // filter.
[ "GetCFilter", "gets", "a", "cfilter", "from", "the", "database", ".", "Failing", "that", "it", "requests", "the", "cfilter", "from", "the", "network", "and", "writes", "it", "to", "the", "database", ".", "If", "extended", "is", "true", "an", "extended", "f...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L1030-L1134
train
lightninglabs/neutrino
query.go
GetBlock
func (s *ChainService) GetBlock(blockHash chainhash.Hash, options ...QueryOption) (*btcutil.Block, error) { // Fetch the corresponding block header from the database. If this // isn't found, then we don't have the header for this block so we // can't request it. blockHeader, height, err := s.BlockHeaders.FetchHea...
go
func (s *ChainService) GetBlock(blockHash chainhash.Hash, options ...QueryOption) (*btcutil.Block, error) { // Fetch the corresponding block header from the database. If this // isn't found, then we don't have the header for this block so we // can't request it. blockHeader, height, err := s.BlockHeaders.FetchHea...
[ "func", "(", "s", "*", "ChainService", ")", "GetBlock", "(", "blockHash", "chainhash", ".", "Hash", ",", "options", "...", "QueryOption", ")", "(", "*", "btcutil", ".", "Block", ",", "error", ")", "{", "// Fetch the corresponding block header from the database. If...
// GetBlock gets a block by requesting it from the network, one peer at a // time, until one answers. If the block is found in the cache, it will be // returned immediately.
[ "GetBlock", "gets", "a", "block", "by", "requesting", "it", "from", "the", "network", "one", "peer", "at", "a", "time", "until", "one", "answers", ".", "If", "the", "block", "is", "found", "in", "the", "cache", "it", "will", "be", "returned", "immediatel...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/query.go#L1139-L1258
train
lightninglabs/neutrino
notifications.go
Peers
func (s *ChainService) Peers() []*ServerPeer { replyChan := make(chan []*ServerPeer) select { case s.query <- getPeersMsg{reply: replyChan}: return <-replyChan case <-s.quit: return nil } }
go
func (s *ChainService) Peers() []*ServerPeer { replyChan := make(chan []*ServerPeer) select { case s.query <- getPeersMsg{reply: replyChan}: return <-replyChan case <-s.quit: return nil } }
[ "func", "(", "s", "*", "ChainService", ")", "Peers", "(", ")", "[", "]", "*", "ServerPeer", "{", "replyChan", ":=", "make", "(", "chan", "[", "]", "*", "ServerPeer", ")", "\n\n", "select", "{", "case", "s", ".", "query", "<-", "getPeersMsg", "{", "...
// Peers returns an array of all connected peers.
[ "Peers", "returns", "an", "array", "of", "all", "connected", "peers", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/notifications.go#L223-L232
train
lightninglabs/neutrino
notifications.go
DisconnectNodeByAddr
func (s *ChainService) DisconnectNodeByAddr(addr string) error { replyChan := make(chan error) select { case s.query <- disconnectNodeMsg{ cmp: func(sp *ServerPeer) bool { return sp.Addr() == addr }, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
go
func (s *ChainService) DisconnectNodeByAddr(addr string) error { replyChan := make(chan error) select { case s.query <- disconnectNodeMsg{ cmp: func(sp *ServerPeer) bool { return sp.Addr() == addr }, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
[ "func", "(", "s", "*", "ChainService", ")", "DisconnectNodeByAddr", "(", "addr", "string", ")", "error", "{", "replyChan", ":=", "make", "(", "chan", "error", ")", "\n\n", "select", "{", "case", "s", ".", "query", "<-", "disconnectNodeMsg", "{", "cmp", "...
// DisconnectNodeByAddr disconnects a peer by target address. Both outbound and // inbound nodes will be searched for the target node. An error message will // be returned if the peer was not found.
[ "DisconnectNodeByAddr", "disconnects", "a", "peer", "by", "target", "address", ".", "Both", "outbound", "and", "inbound", "nodes", "will", "be", "searched", "for", "the", "target", "node", ".", "An", "error", "message", "will", "be", "returned", "if", "the", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/notifications.go#L237-L249
train
lightninglabs/neutrino
notifications.go
DisconnectNodeByID
func (s *ChainService) DisconnectNodeByID(id int32) error { replyChan := make(chan error) select { case s.query <- disconnectNodeMsg{ cmp: func(sp *ServerPeer) bool { return sp.ID() == id }, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
go
func (s *ChainService) DisconnectNodeByID(id int32) error { replyChan := make(chan error) select { case s.query <- disconnectNodeMsg{ cmp: func(sp *ServerPeer) bool { return sp.ID() == id }, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
[ "func", "(", "s", "*", "ChainService", ")", "DisconnectNodeByID", "(", "id", "int32", ")", "error", "{", "replyChan", ":=", "make", "(", "chan", "error", ")", "\n\n", "select", "{", "case", "s", ".", "query", "<-", "disconnectNodeMsg", "{", "cmp", ":", ...
// DisconnectNodeByID disconnects a peer by target node id. Both outbound and // inbound nodes will be searched for the target node. An error message will be // returned if the peer was not found.
[ "DisconnectNodeByID", "disconnects", "a", "peer", "by", "target", "node", "id", ".", "Both", "outbound", "and", "inbound", "nodes", "will", "be", "searched", "for", "the", "target", "node", ".", "An", "error", "message", "will", "be", "returned", "if", "the"...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/notifications.go#L254-L266
train
lightninglabs/neutrino
notifications.go
ConnectNode
func (s *ChainService) ConnectNode(addr string, permanent bool) error { replyChan := make(chan error) select { case s.query <- connectNodeMsg{ addr: addr, permanent: permanent, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
go
func (s *ChainService) ConnectNode(addr string, permanent bool) error { replyChan := make(chan error) select { case s.query <- connectNodeMsg{ addr: addr, permanent: permanent, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
[ "func", "(", "s", "*", "ChainService", ")", "ConnectNode", "(", "addr", "string", ",", "permanent", "bool", ")", "error", "{", "replyChan", ":=", "make", "(", "chan", "error", ")", "\n\n", "select", "{", "case", "s", ".", "query", "<-", "connectNodeMsg",...
// ConnectNode adds `addr' as a new outbound peer. If permanent is true then the // peer will be persistent and reconnect if the connection is lost. // It is an error to call this with an already existing peer.
[ "ConnectNode", "adds", "addr", "as", "a", "new", "outbound", "peer", ".", "If", "permanent", "is", "true", "then", "the", "peer", "will", "be", "persistent", "and", "reconnect", "if", "the", "connection", "is", "lost", ".", "It", "is", "an", "error", "to...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/notifications.go#L303-L316
train
lightninglabs/neutrino
notifications.go
IsBanned
func (s *ChainService) IsBanned(addr string) bool { replyChan := make(chan bool, 1) select { case s.query <- banQueryMsg{ addr: addr, reply: replyChan, }: return <-replyChan case <-s.quit: return false } }
go
func (s *ChainService) IsBanned(addr string) bool { replyChan := make(chan bool, 1) select { case s.query <- banQueryMsg{ addr: addr, reply: replyChan, }: return <-replyChan case <-s.quit: return false } }
[ "func", "(", "s", "*", "ChainService", ")", "IsBanned", "(", "addr", "string", ")", "bool", "{", "replyChan", ":=", "make", "(", "chan", "bool", ",", "1", ")", "\n\n", "select", "{", "case", "s", ".", "query", "<-", "banQueryMsg", "{", "addr", ":", ...
// IsBanned retursn true if the peer is banned, and false otherwise.
[ "IsBanned", "retursn", "true", "if", "the", "peer", "is", "banned", "and", "false", "otherwise", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/notifications.go#L330-L342
train
lightninglabs/neutrino
rescan.go
NotificationHandlers
func NotificationHandlers(ntfn rpcclient.NotificationHandlers) RescanOption { return func(ro *rescanOptions) { ro.ntfn = ntfn } }
go
func NotificationHandlers(ntfn rpcclient.NotificationHandlers) RescanOption { return func(ro *rescanOptions) { ro.ntfn = ntfn } }
[ "func", "NotificationHandlers", "(", "ntfn", "rpcclient", ".", "NotificationHandlers", ")", "RescanOption", "{", "return", "func", "(", "ro", "*", "rescanOptions", ")", "{", "ro", ".", "ntfn", "=", "ntfn", "\n", "}", "\n", "}" ]
// NotificationHandlers specifies notification handlers for the rescan. These // will always run in the same goroutine as the caller.
[ "NotificationHandlers", "specifies", "notification", "handlers", "for", "the", "rescan", ".", "These", "will", "always", "run", "in", "the", "same", "goroutine", "as", "the", "caller", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L114-L118
train
lightninglabs/neutrino
rescan.go
StartTime
func StartTime(startTime time.Time) RescanOption { return func(ro *rescanOptions) { ro.startTime = startTime } }
go
func StartTime(startTime time.Time) RescanOption { return func(ro *rescanOptions) { ro.startTime = startTime } }
[ "func", "StartTime", "(", "startTime", "time", ".", "Time", ")", "RescanOption", "{", "return", "func", "(", "ro", "*", "rescanOptions", ")", "{", "ro", ".", "startTime", "=", "startTime", "\n", "}", "\n", "}" ]
// StartTime specifies the start time. The time is compared to the timestamp of // each block, and the rescan only begins once the first block crosses that // timestamp. When using this, it is advisable to use a margin of error and // start rescans slightly earlier than required. The rescan uses the latter of // StartB...
[ "StartTime", "specifies", "the", "start", "time", ".", "The", "time", "is", "compared", "to", "the", "timestamp", "of", "each", "block", "and", "the", "rescan", "only", "begins", "once", "the", "first", "block", "crosses", "that", "timestamp", ".", "When", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L137-L141
train
lightninglabs/neutrino
rescan.go
WatchInputs
func WatchInputs(watchInputs ...InputWithScript) RescanOption { return func(ro *rescanOptions) { ro.watchInputs = append(ro.watchInputs, watchInputs...) } }
go
func WatchInputs(watchInputs ...InputWithScript) RescanOption { return func(ro *rescanOptions) { ro.watchInputs = append(ro.watchInputs, watchInputs...) } }
[ "func", "WatchInputs", "(", "watchInputs", "...", "InputWithScript", ")", "RescanOption", "{", "return", "func", "(", "ro", "*", "rescanOptions", ")", "{", "ro", ".", "watchInputs", "=", "append", "(", "ro", ".", "watchInputs", ",", "watchInputs", "...", ")"...
// WatchInputs specifies the outpoints to watch for on-chain spends. We also // require the script as we'll match on the script, but then notify based on // the outpoint. Each call to this function adds to the list of outpoints being // watched rather than replacing the list.
[ "WatchInputs", "specifies", "the", "outpoints", "to", "watch", "for", "on", "-", "chain", "spends", ".", "We", "also", "require", "the", "script", "as", "we", "ll", "match", "on", "the", "script", "but", "then", "notify", "based", "on", "the", "outpoint", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L180-L184
train
lightninglabs/neutrino
rescan.go
notifyBlock
func notifyBlock(chain ChainSource, ro *rescanOptions, curHeader wire.BlockHeader, curStamp waddrmgr.BlockStamp, scanning bool) error { // Find relevant transactions based on watch list. If scanning is // false, we can safely assume this block has no relevant transactions. var relevantTxs []*btcutil.Tx if len(ro...
go
func notifyBlock(chain ChainSource, ro *rescanOptions, curHeader wire.BlockHeader, curStamp waddrmgr.BlockStamp, scanning bool) error { // Find relevant transactions based on watch list. If scanning is // false, we can safely assume this block has no relevant transactions. var relevantTxs []*btcutil.Tx if len(ro...
[ "func", "notifyBlock", "(", "chain", "ChainSource", ",", "ro", "*", "rescanOptions", ",", "curHeader", "wire", ".", "BlockHeader", ",", "curStamp", "waddrmgr", ".", "BlockStamp", ",", "scanning", "bool", ")", "error", "{", "// Find relevant transactions based on wat...
// notifyBlock calls appropriate listeners based on the block filter.
[ "notifyBlock", "calls", "appropriate", "listeners", "based", "on", "the", "block", "filter", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L813-L850
train
lightninglabs/neutrino
rescan.go
extractBlockMatches
func extractBlockMatches(chain ChainSource, ro *rescanOptions, curStamp *waddrmgr.BlockStamp) ([]*btcutil.Tx, error) { // We've matched. Now we actually get the block and cycle through the // transactions to see which ones are relevant. block, err := chain.GetBlock(curStamp.Hash, ro.queryOptions...) if err != nil...
go
func extractBlockMatches(chain ChainSource, ro *rescanOptions, curStamp *waddrmgr.BlockStamp) ([]*btcutil.Tx, error) { // We've matched. Now we actually get the block and cycle through the // transactions to see which ones are relevant. block, err := chain.GetBlock(curStamp.Hash, ro.queryOptions...) if err != nil...
[ "func", "extractBlockMatches", "(", "chain", "ChainSource", ",", "ro", "*", "rescanOptions", ",", "curStamp", "*", "waddrmgr", ".", "BlockStamp", ")", "(", "[", "]", "*", "btcutil", ".", "Tx", ",", "error", ")", "{", "// We've matched. Now we actually get the bl...
// extractBlockMatches fetches the target block from the network, and filters // out any relevant transactions found within the block.
[ "extractBlockMatches", "fetches", "the", "target", "block", "from", "the", "network", "and", "filters", "out", "any", "relevant", "transactions", "found", "within", "the", "block", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L854-L911
train
lightninglabs/neutrino
rescan.go
notifyBlockWithFilter
func notifyBlockWithFilter(chain ChainSource, ro *rescanOptions, curHeader *wire.BlockHeader, curStamp *waddrmgr.BlockStamp, filter *gcs.Filter) error { // Based on what we find within the block or the filter, we'll be // sending out a set of notifications with transactions that are // relevant to the rescan. va...
go
func notifyBlockWithFilter(chain ChainSource, ro *rescanOptions, curHeader *wire.BlockHeader, curStamp *waddrmgr.BlockStamp, filter *gcs.Filter) error { // Based on what we find within the block or the filter, we'll be // sending out a set of notifications with transactions that are // relevant to the rescan. va...
[ "func", "notifyBlockWithFilter", "(", "chain", "ChainSource", ",", "ro", "*", "rescanOptions", ",", "curHeader", "*", "wire", ".", "BlockHeader", ",", "curStamp", "*", "waddrmgr", ".", "BlockStamp", ",", "filter", "*", "gcs", ".", "Filter", ")", "error", "{"...
// notifyBlockWithFilter calls appropriate listeners based on the block filter. // This differs from notifyBlock in that is expects the caller to already have // obtained the target filter.
[ "notifyBlockWithFilter", "calls", "appropriate", "listeners", "based", "on", "the", "block", "filter", ".", "This", "differs", "from", "notifyBlock", "in", "that", "is", "expects", "the", "caller", "to", "already", "have", "obtained", "the", "target", "filter", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L916-L955
train
lightninglabs/neutrino
rescan.go
matchBlockFilter
func matchBlockFilter(ro *rescanOptions, filter *gcs.Filter, blockHash *chainhash.Hash) (bool, error) { // Now that we have the filter as well as the block hash of the block // used to construct the filter, we'll check to see if the block // matches any items in our watch list. key := builder.DeriveKey(blockHash)...
go
func matchBlockFilter(ro *rescanOptions, filter *gcs.Filter, blockHash *chainhash.Hash) (bool, error) { // Now that we have the filter as well as the block hash of the block // used to construct the filter, we'll check to see if the block // matches any items in our watch list. key := builder.DeriveKey(blockHash)...
[ "func", "matchBlockFilter", "(", "ro", "*", "rescanOptions", ",", "filter", "*", "gcs", ".", "Filter", ",", "blockHash", "*", "chainhash", ".", "Hash", ")", "(", "bool", ",", "error", ")", "{", "// Now that we have the filter as well as the block hash of the block",...
// matchBlockFilter returns whether the block filter matches the watched items. // If this returns false, it means the block is certainly not interesting to // us. This method differs from blockFilterMatches in that it expects the // filter to already be obtained, rather than fetching the filter from the // network.
[ "matchBlockFilter", "returns", "whether", "the", "block", "filter", "matches", "the", "watched", "items", ".", "If", "this", "returns", "false", "it", "means", "the", "block", "is", "certainly", "not", "interesting", "to", "us", ".", "This", "method", "differs...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L962-L975
train
lightninglabs/neutrino
rescan.go
blockFilterMatches
func blockFilterMatches(chain ChainSource, ro *rescanOptions, blockHash *chainhash.Hash) (bool, error) { // TODO(roasbeef): need to ENSURE always get filter // Since this method is called when we are not current, and from the // utxoscanner, we expect more calls to follow for the subsequent // filters. To speed ...
go
func blockFilterMatches(chain ChainSource, ro *rescanOptions, blockHash *chainhash.Hash) (bool, error) { // TODO(roasbeef): need to ENSURE always get filter // Since this method is called when we are not current, and from the // utxoscanner, we expect more calls to follow for the subsequent // filters. To speed ...
[ "func", "blockFilterMatches", "(", "chain", "ChainSource", ",", "ro", "*", "rescanOptions", ",", "blockHash", "*", "chainhash", ".", "Hash", ")", "(", "bool", ",", "error", ")", "{", "// TODO(roasbeef): need to ENSURE always get filter", "// Since this method is called ...
// blockFilterMatches returns whether the block filter matches the watched // items. If this returns false, it means the block is certainly not interesting // to us.
[ "blockFilterMatches", "returns", "whether", "the", "block", "filter", "matches", "the", "watched", "items", ".", "If", "this", "returns", "false", "it", "means", "the", "block", "is", "certainly", "not", "interesting", "to", "us", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L980-L1007
train
lightninglabs/neutrino
rescan.go
updateFilter
func (ro *rescanOptions) updateFilter(chain ChainSource, update *updateOptions, curStamp *waddrmgr.BlockStamp, curHeader *wire.BlockHeader) (bool, error) { ro.watchAddrs = append(ro.watchAddrs, update.addrs...) ro.watchInputs = append(ro.watchInputs, update.inputs...) for _, addr := range update.addrs { script,...
go
func (ro *rescanOptions) updateFilter(chain ChainSource, update *updateOptions, curStamp *waddrmgr.BlockStamp, curHeader *wire.BlockHeader) (bool, error) { ro.watchAddrs = append(ro.watchAddrs, update.addrs...) ro.watchInputs = append(ro.watchInputs, update.inputs...) for _, addr := range update.addrs { script,...
[ "func", "(", "ro", "*", "rescanOptions", ")", "updateFilter", "(", "chain", "ChainSource", ",", "update", "*", "updateOptions", ",", "curStamp", "*", "waddrmgr", ".", "BlockStamp", ",", "curHeader", "*", "wire", ".", "BlockHeader", ")", "(", "bool", ",", "...
// updateFilter atomically updates the filter and rewinds to the specified // height if not 0.
[ "updateFilter", "atomically", "updates", "the", "filter", "and", "rewinds", "to", "the", "specified", "height", "if", "not", "0", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L1011-L1075
train
lightninglabs/neutrino
rescan.go
spendsWatchedInput
func (ro *rescanOptions) spendsWatchedInput(tx *btcutil.Tx) bool { for _, in := range tx.MsgTx().TxIn { for _, input := range ro.watchInputs { switch { // If we're watching for a zero outpoint, then we should // match on the output script being spent instead. case input.OutPoint == zeroOutPoint: pkSc...
go
func (ro *rescanOptions) spendsWatchedInput(tx *btcutil.Tx) bool { for _, in := range tx.MsgTx().TxIn { for _, input := range ro.watchInputs { switch { // If we're watching for a zero outpoint, then we should // match on the output script being spent instead. case input.OutPoint == zeroOutPoint: pkSc...
[ "func", "(", "ro", "*", "rescanOptions", ")", "spendsWatchedInput", "(", "tx", "*", "btcutil", ".", "Tx", ")", "bool", "{", "for", "_", ",", "in", ":=", "range", "tx", ".", "MsgTx", "(", ")", ".", "TxIn", "{", "for", "_", ",", "input", ":=", "ran...
// spendsWatchedInput returns whether the transaction matches the filter by // spending a watched input.
[ "spendsWatchedInput", "returns", "whether", "the", "transaction", "matches", "the", "filter", "by", "spending", "a", "watched", "input", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L1079-L1104
train
lightninglabs/neutrino
rescan.go
paysWatchedAddr
func (ro *rescanOptions) paysWatchedAddr(tx *btcutil.Tx) (bool, error) { anyMatchingOutputs := false txOutLoop: for outIdx, out := range tx.MsgTx().TxOut { pkScript := out.PkScript for _, addr := range ro.watchAddrs { // We'll convert the address into its matching pkScript // to in order to check for a ma...
go
func (ro *rescanOptions) paysWatchedAddr(tx *btcutil.Tx) (bool, error) { anyMatchingOutputs := false txOutLoop: for outIdx, out := range tx.MsgTx().TxOut { pkScript := out.PkScript for _, addr := range ro.watchAddrs { // We'll convert the address into its matching pkScript // to in order to check for a ma...
[ "func", "(", "ro", "*", "rescanOptions", ")", "paysWatchedAddr", "(", "tx", "*", "btcutil", ".", "Tx", ")", "(", "bool", ",", "error", ")", "{", "anyMatchingOutputs", ":=", "false", "\n\n", "txOutLoop", ":", "for", "outIdx", ",", "out", ":=", "range", ...
// paysWatchedAddr returns whether the transaction matches the filter by having // an output paying to a watched address. If that is the case, this also // updates the filter to watch the newly created output going forward.
[ "paysWatchedAddr", "returns", "whether", "the", "transaction", "matches", "the", "filter", "by", "having", "an", "output", "paying", "to", "a", "watched", "address", ".", "If", "that", "is", "the", "case", "this", "also", "updates", "the", "filter", "to", "w...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L1109-L1153
train
lightninglabs/neutrino
rescan.go
NewRescan
func NewRescan(chain ChainSource, options ...RescanOption) *Rescan { return &Rescan{ running: make(chan struct{}), options: options, updateChan: make(chan *updateOptions), chain: chain, } }
go
func NewRescan(chain ChainSource, options ...RescanOption) *Rescan { return &Rescan{ running: make(chan struct{}), options: options, updateChan: make(chan *updateOptions), chain: chain, } }
[ "func", "NewRescan", "(", "chain", "ChainSource", ",", "options", "...", "RescanOption", ")", "*", "Rescan", "{", "return", "&", "Rescan", "{", "running", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "options", ":", "options", ",", "updateChan...
// NewRescan returns a rescan object that runs in another goroutine and has an // updatable filter. It returns the long-running rescan object, and a channel // which returns any error on termination of the rescan process.
[ "NewRescan", "returns", "a", "rescan", "object", "that", "runs", "in", "another", "goroutine", "and", "has", "an", "updatable", "filter", ".", "It", "returns", "the", "long", "-", "running", "rescan", "object", "and", "a", "channel", "which", "returns", "any...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L1178-L1185
train
lightninglabs/neutrino
rescan.go
Start
func (r *Rescan) Start() <-chan error { errChan := make(chan error, 1) if !atomic.CompareAndSwapUint32(&r.started, 0, 1) { errChan <- fmt.Errorf("Rescan already started") return errChan } r.wg.Add(1) go func() { defer r.wg.Done() rescanArgs := append(r.options, updateChan(r.updateChan)) err := rescan(...
go
func (r *Rescan) Start() <-chan error { errChan := make(chan error, 1) if !atomic.CompareAndSwapUint32(&r.started, 0, 1) { errChan <- fmt.Errorf("Rescan already started") return errChan } r.wg.Add(1) go func() { defer r.wg.Done() rescanArgs := append(r.options, updateChan(r.updateChan)) err := rescan(...
[ "func", "(", "r", "*", "Rescan", ")", "Start", "(", ")", "<-", "chan", "error", "{", "errChan", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n\n", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "r", ".", "started", ",", "0", ...
// Start kicks off the rescan goroutine, which will begin to scan the chain // according to the specified rescan options.
[ "Start", "kicks", "off", "the", "rescan", "goroutine", "which", "will", "begin", "to", "scan", "the", "chain", "according", "to", "the", "specified", "rescan", "options", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L1196-L1221
train
lightninglabs/neutrino
rescan.go
AddAddrs
func AddAddrs(addrs ...btcutil.Address) UpdateOption { return func(uo *updateOptions) { uo.addrs = append(uo.addrs, addrs...) } }
go
func AddAddrs(addrs ...btcutil.Address) UpdateOption { return func(uo *updateOptions) { uo.addrs = append(uo.addrs, addrs...) } }
[ "func", "AddAddrs", "(", "addrs", "...", "btcutil", ".", "Address", ")", "UpdateOption", "{", "return", "func", "(", "uo", "*", "updateOptions", ")", "{", "uo", ".", "addrs", "=", "append", "(", "uo", ".", "addrs", ",", "addrs", "...", ")", "\n", "}"...
// AddAddrs adds addresses to the filter.
[ "AddAddrs", "adds", "addresses", "to", "the", "filter", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L1240-L1244
train
lightninglabs/neutrino
rescan.go
AddInputs
func AddInputs(inputs ...InputWithScript) UpdateOption { return func(uo *updateOptions) { uo.inputs = append(uo.inputs, inputs...) } }
go
func AddInputs(inputs ...InputWithScript) UpdateOption { return func(uo *updateOptions) { uo.inputs = append(uo.inputs, inputs...) } }
[ "func", "AddInputs", "(", "inputs", "...", "InputWithScript", ")", "UpdateOption", "{", "return", "func", "(", "uo", "*", "updateOptions", ")", "{", "uo", ".", "inputs", "=", "append", "(", "uo", ".", "inputs", ",", "inputs", "...", ")", "\n", "}", "\n...
// AddInputs adds inputs to watch to the filter.
[ "AddInputs", "adds", "inputs", "to", "watch", "to", "the", "filter", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/rescan.go#L1247-L1251
train
lightninglabs/neutrino
pushtx/broadcaster.go
NewBroadcaster
func NewBroadcaster(cfg *Config) *Broadcaster { b := &Broadcaster{ cfg: *cfg, broadcastReqs: make(chan *broadcastReq), transactions: make(map[chainhash.Hash]*wire.MsgTx), quit: make(chan struct{}), } return b }
go
func NewBroadcaster(cfg *Config) *Broadcaster { b := &Broadcaster{ cfg: *cfg, broadcastReqs: make(chan *broadcastReq), transactions: make(map[chainhash.Hash]*wire.MsgTx), quit: make(chan struct{}), } return b }
[ "func", "NewBroadcaster", "(", "cfg", "*", "Config", ")", "*", "Broadcaster", "{", "b", ":=", "&", "Broadcaster", "{", "cfg", ":", "*", "cfg", ",", "broadcastReqs", ":", "make", "(", "chan", "*", "broadcastReq", ")", ",", "transactions", ":", "make", "...
// NewBroadcaster creates a new Broadcaster backed by the given config.
[ "NewBroadcaster", "creates", "a", "new", "Broadcaster", "backed", "by", "the", "given", "config", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/pushtx/broadcaster.go#L74-L83
train
lightninglabs/neutrino
pushtx/broadcaster.go
Start
func (b *Broadcaster) Start() error { var err error b.start.Do(func() { sub, err := b.cfg.SubscribeBlocks() if err != nil { err = fmt.Errorf("unable to subscribe for block "+ "notifications: %v", err) return } b.wg.Add(1) go b.broadcastHandler(sub) }) return err }
go
func (b *Broadcaster) Start() error { var err error b.start.Do(func() { sub, err := b.cfg.SubscribeBlocks() if err != nil { err = fmt.Errorf("unable to subscribe for block "+ "notifications: %v", err) return } b.wg.Add(1) go b.broadcastHandler(sub) }) return err }
[ "func", "(", "b", "*", "Broadcaster", ")", "Start", "(", ")", "error", "{", "var", "err", "error", "\n", "b", ".", "start", ".", "Do", "(", "func", "(", ")", "{", "sub", ",", "err", ":=", "b", ".", "cfg", ".", "SubscribeBlocks", "(", ")", "\n",...
// Start starts all of the necessary steps for the Broadcaster to begin properly // carrying out its duties.
[ "Start", "starts", "all", "of", "the", "necessary", "steps", "for", "the", "Broadcaster", "to", "begin", "properly", "carrying", "out", "its", "duties", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/pushtx/broadcaster.go#L87-L101
train
lightninglabs/neutrino
pushtx/broadcaster.go
Stop
func (b *Broadcaster) Stop() { b.stop.Do(func() { close(b.quit) b.wg.Wait() }) }
go
func (b *Broadcaster) Stop() { b.stop.Do(func() { close(b.quit) b.wg.Wait() }) }
[ "func", "(", "b", "*", "Broadcaster", ")", "Stop", "(", ")", "{", "b", ".", "stop", ".", "Do", "(", "func", "(", ")", "{", "close", "(", "b", ".", "quit", ")", "\n", "b", ".", "wg", ".", "Wait", "(", ")", "\n", "}", ")", "\n", "}" ]
// Stop halts the Broadcaster from rebroadcasting pending transactions.
[ "Stop", "halts", "the", "Broadcaster", "from", "rebroadcasting", "pending", "transactions", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/pushtx/broadcaster.go#L104-L109
train
lightninglabs/neutrino
pushtx/broadcaster.go
handleBroadcastReq
func (b *Broadcaster) handleBroadcastReq(req *broadcastReq) error { err := b.cfg.Broadcast(req.tx) if err != nil && !IsBroadcastError(err, Mempool) { log.Errorf("Broadcast attempt failed: %v", err) return err } b.transactions[req.tx.TxHash()] = req.tx return nil }
go
func (b *Broadcaster) handleBroadcastReq(req *broadcastReq) error { err := b.cfg.Broadcast(req.tx) if err != nil && !IsBroadcastError(err, Mempool) { log.Errorf("Broadcast attempt failed: %v", err) return err } b.transactions[req.tx.TxHash()] = req.tx return nil }
[ "func", "(", "b", "*", "Broadcaster", ")", "handleBroadcastReq", "(", "req", "*", "broadcastReq", ")", "error", "{", "err", ":=", "b", ".", "cfg", ".", "Broadcast", "(", "req", ".", "tx", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "IsBroadcastEr...
// handleBroadcastReq handles a new external request to reliably broadcast a // transaction to the network.
[ "handleBroadcastReq", "handles", "a", "new", "external", "request", "to", "reliably", "broadcast", "a", "transaction", "to", "the", "network", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/pushtx/broadcaster.go#L167-L177
train
lightninglabs/neutrino
pushtx/broadcaster.go
rebroadcast
func (b *Broadcaster) rebroadcast() { if len(b.transactions) == 0 { return } sortedTxs := wtxmgr.DependencySort(b.transactions) for _, tx := range sortedTxs { err := b.cfg.Broadcast(tx) switch { // If the transaction has already confirmed on-chain, we can // stop broadcasting it further. // // TODO(w...
go
func (b *Broadcaster) rebroadcast() { if len(b.transactions) == 0 { return } sortedTxs := wtxmgr.DependencySort(b.transactions) for _, tx := range sortedTxs { err := b.cfg.Broadcast(tx) switch { // If the transaction has already confirmed on-chain, we can // stop broadcasting it further. // // TODO(w...
[ "func", "(", "b", "*", "Broadcaster", ")", "rebroadcast", "(", ")", "{", "if", "len", "(", "b", ".", "transactions", ")", "==", "0", "{", "return", "\n", "}", "\n\n", "sortedTxs", ":=", "wtxmgr", ".", "DependencySort", "(", "b", ".", "transactions", ...
// rebroadcast rebroadcasts all of the currently pending transactions. Care has // been taken to ensure that the transactions are sorted in their dependency // order to prevent peers from deeming our transactions as invalid due to // broadcasting them before their pending dependencies.
[ "rebroadcast", "rebroadcasts", "all", "of", "the", "currently", "pending", "transactions", ".", "Care", "has", "been", "taken", "to", "ensure", "that", "the", "transactions", "are", "sorted", "in", "their", "dependency", "order", "to", "prevent", "peers", "from"...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/pushtx/broadcaster.go#L183-L223
train
lightninglabs/neutrino
pushtx/broadcaster.go
Broadcast
func (b *Broadcaster) Broadcast(tx *wire.MsgTx) error { errChan := make(chan error, 1) select { case b.broadcastReqs <- &broadcastReq{ tx: tx, errChan: errChan, }: case <-b.quit: return ErrBroadcasterStopped } select { case err := <-errChan: return err case <-b.quit: return ErrBroadcasterStopp...
go
func (b *Broadcaster) Broadcast(tx *wire.MsgTx) error { errChan := make(chan error, 1) select { case b.broadcastReqs <- &broadcastReq{ tx: tx, errChan: errChan, }: case <-b.quit: return ErrBroadcasterStopped } select { case err := <-errChan: return err case <-b.quit: return ErrBroadcasterStopp...
[ "func", "(", "b", "*", "Broadcaster", ")", "Broadcast", "(", "tx", "*", "wire", ".", "MsgTx", ")", "error", "{", "errChan", ":=", "make", "(", "chan", "error", ",", "1", ")", "\n\n", "select", "{", "case", "b", ".", "broadcastReqs", "<-", "&", "bro...
// Broadcast submits a request to the Broadcaster to reliably broadcast the // given transaction. An error won't be returned if the transaction already // exists within the mempool. Any transaction broadcast through this method will // be rebroadcast upon every change of the tip of the chain.
[ "Broadcast", "submits", "a", "request", "to", "the", "Broadcaster", "to", "reliably", "broadcast", "the", "given", "transaction", ".", "An", "error", "won", "t", "be", "returned", "if", "the", "transaction", "already", "exists", "within", "the", "mempool", "."...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/pushtx/broadcaster.go#L229-L247
train
lightninglabs/neutrino
blockntfns/manager.go
NewSubscriptionManager
func NewSubscriptionManager(ntfnSource NotificationSource) *SubscriptionManager { return &SubscriptionManager{ subscribers: make(map[uint64]*newSubscription), newSubscriptions: make(chan *newSubscription), cancelSubscriptions: make(chan *cancelSubscription), ntfnSource: ntfnSource, quit: ...
go
func NewSubscriptionManager(ntfnSource NotificationSource) *SubscriptionManager { return &SubscriptionManager{ subscribers: make(map[uint64]*newSubscription), newSubscriptions: make(chan *newSubscription), cancelSubscriptions: make(chan *cancelSubscription), ntfnSource: ntfnSource, quit: ...
[ "func", "NewSubscriptionManager", "(", "ntfnSource", "NotificationSource", ")", "*", "SubscriptionManager", "{", "return", "&", "SubscriptionManager", "{", "subscribers", ":", "make", "(", "map", "[", "uint64", "]", "*", "newSubscription", ")", ",", "newSubscription...
// NewSubscriptionManager creates a subscription manager backed by a // NotificationSource.
[ "NewSubscriptionManager", "creates", "a", "subscription", "manager", "backed", "by", "a", "NotificationSource", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L104-L112
train
lightninglabs/neutrino
blockntfns/manager.go
Start
func (m *SubscriptionManager) Start() { if atomic.AddInt32(&m.started, 1) != 1 { return } log.Debug("Starting block notifications subscription manager") m.wg.Add(1) go m.subscriptionHandler() }
go
func (m *SubscriptionManager) Start() { if atomic.AddInt32(&m.started, 1) != 1 { return } log.Debug("Starting block notifications subscription manager") m.wg.Add(1) go m.subscriptionHandler() }
[ "func", "(", "m", "*", "SubscriptionManager", ")", "Start", "(", ")", "{", "if", "atomic", ".", "AddInt32", "(", "&", "m", ".", "started", ",", "1", ")", "!=", "1", "{", "return", "\n", "}", "\n\n", "log", ".", "Debug", "(", "\"", "\"", ")", "\...
// Start starts all the goroutines required for the SubscriptionManager to carry // out its duties.
[ "Start", "starts", "all", "the", "goroutines", "required", "for", "the", "SubscriptionManager", "to", "carry", "out", "its", "duties", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L116-L125
train
lightninglabs/neutrino
blockntfns/manager.go
Stop
func (m *SubscriptionManager) Stop() { if atomic.AddInt32(&m.stopped, 1) != 1 { return } log.Debug("Stopping block notifications subscription manager") close(m.quit) m.wg.Wait() var wg sync.WaitGroup wg.Add(len(m.subscribers)) for _, subscriber := range m.subscribers { go func() { defer wg.Done() s...
go
func (m *SubscriptionManager) Stop() { if atomic.AddInt32(&m.stopped, 1) != 1 { return } log.Debug("Stopping block notifications subscription manager") close(m.quit) m.wg.Wait() var wg sync.WaitGroup wg.Add(len(m.subscribers)) for _, subscriber := range m.subscribers { go func() { defer wg.Done() s...
[ "func", "(", "m", "*", "SubscriptionManager", ")", "Stop", "(", ")", "{", "if", "atomic", ".", "AddInt32", "(", "&", "m", ".", "stopped", ",", "1", ")", "!=", "1", "{", "return", "\n", "}", "\n\n", "log", ".", "Debug", "(", "\"", "\"", ")", "\n...
// Stop stops all active goroutines required for the SubscriptionManager to // carry out its duties.
[ "Stop", "stops", "all", "active", "goroutines", "required", "for", "the", "SubscriptionManager", "to", "carry", "out", "its", "duties", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L129-L149
train
lightninglabs/neutrino
blockntfns/manager.go
NewSubscription
func (m *SubscriptionManager) NewSubscription(bestHeight uint32) (*Subscription, error) { // We'll start by constructing the internal messages that the // subscription handler will use to register the new client. sub := &newSubscription{ id: atomic.AddUint64(&m.subscriberCounter, 1), ntfnChan: make(c...
go
func (m *SubscriptionManager) NewSubscription(bestHeight uint32) (*Subscription, error) { // We'll start by constructing the internal messages that the // subscription handler will use to register the new client. sub := &newSubscription{ id: atomic.AddUint64(&m.subscriberCounter, 1), ntfnChan: make(c...
[ "func", "(", "m", "*", "SubscriptionManager", ")", "NewSubscription", "(", "bestHeight", "uint32", ")", "(", "*", "Subscription", ",", "error", ")", "{", "// We'll start by constructing the internal messages that the", "// subscription handler will use to register the new clien...
// NewSubscription creates a new block notification subscription for a client. // The bestHeight parameter can be used by the client to indicate its best known // state. A backlog of notifications from said point until the tip of the chain // will be delivered upon the client's successful registration. When providing a...
[ "NewSubscription", "creates", "a", "new", "block", "notification", "subscription", "for", "a", "client", ".", "The", "bestHeight", "parameter", "can", "be", "used", "by", "the", "client", "to", "indicate", "its", "best", "known", "state", ".", "A", "backlog", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L197-L274
train
lightninglabs/neutrino
blockntfns/manager.go
handleNewSubscription
func (m *SubscriptionManager) handleNewSubscription(sub *newSubscription) error { log.Infof("Registering block subscription: id=%d", sub.id) // We'll start by retrieving a backlog of notifications from the // client's best height. blocks, currentHeight, err := m.ntfnSource.NotificationsSinceHeight( sub.bestHeigh...
go
func (m *SubscriptionManager) handleNewSubscription(sub *newSubscription) error { log.Infof("Registering block subscription: id=%d", sub.id) // We'll start by retrieving a backlog of notifications from the // client's best height. blocks, currentHeight, err := m.ntfnSource.NotificationsSinceHeight( sub.bestHeigh...
[ "func", "(", "m", "*", "SubscriptionManager", ")", "handleNewSubscription", "(", "sub", "*", "newSubscription", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "sub", ".", "id", ")", "\n\n", "// We'll start by retrieving a backlog of notifications fr...
// handleNewSubscription handles a request to create a new block subscription.
[ "handleNewSubscription", "handles", "a", "request", "to", "create", "a", "new", "block", "subscription", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L277-L305
train
lightninglabs/neutrino
blockntfns/manager.go
cancelSubscription
func (m *SubscriptionManager) cancelSubscription(sub *newSubscription) { select { case m.cancelSubscriptions <- &cancelSubscription{sub.id}: case <-m.quit: } }
go
func (m *SubscriptionManager) cancelSubscription(sub *newSubscription) { select { case m.cancelSubscriptions <- &cancelSubscription{sub.id}: case <-m.quit: } }
[ "func", "(", "m", "*", "SubscriptionManager", ")", "cancelSubscription", "(", "sub", "*", "newSubscription", ")", "{", "select", "{", "case", "m", ".", "cancelSubscriptions", "<-", "&", "cancelSubscription", "{", "sub", ".", "id", "}", ":", "case", "<-", "...
// cancelSubscription sends a request to the subscription handler to cancel an // existing subscription.
[ "cancelSubscription", "sends", "a", "request", "to", "the", "subscription", "handler", "to", "cancel", "an", "existing", "subscription", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L309-L314
train
lightninglabs/neutrino
blockntfns/manager.go
handleCancelSubscription
func (m *SubscriptionManager) handleCancelSubscription(msg *cancelSubscription) { // First, we'll attempt to look up an existing susbcriber with the given // ID. sub, ok := m.subscribers[msg.id] if !ok { return } log.Infof("Canceling block subscription: id=%d", msg.id) // If there is one, we'll stop their in...
go
func (m *SubscriptionManager) handleCancelSubscription(msg *cancelSubscription) { // First, we'll attempt to look up an existing susbcriber with the given // ID. sub, ok := m.subscribers[msg.id] if !ok { return } log.Infof("Canceling block subscription: id=%d", msg.id) // If there is one, we'll stop their in...
[ "func", "(", "m", "*", "SubscriptionManager", ")", "handleCancelSubscription", "(", "msg", "*", "cancelSubscription", ")", "{", "// First, we'll attempt to look up an existing susbcriber with the given", "// ID.", "sub", ",", "ok", ":=", "m", ".", "subscribers", "[", "m...
// handleCancelSubscription handles a request to cancel an existing // subscription.
[ "handleCancelSubscription", "handles", "a", "request", "to", "cancel", "an", "existing", "subscription", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L318-L332
train
lightninglabs/neutrino
blockntfns/manager.go
notifySubscribers
func (m *SubscriptionManager) notifySubscribers(ntfn BlockNtfn) { log.Tracef("Notifying %v", ntfn) for _, subscriber := range m.subscribers { m.notifySubscriber(subscriber, ntfn) } }
go
func (m *SubscriptionManager) notifySubscribers(ntfn BlockNtfn) { log.Tracef("Notifying %v", ntfn) for _, subscriber := range m.subscribers { m.notifySubscriber(subscriber, ntfn) } }
[ "func", "(", "m", "*", "SubscriptionManager", ")", "notifySubscribers", "(", "ntfn", "BlockNtfn", ")", "{", "log", ".", "Tracef", "(", "\"", "\"", ",", "ntfn", ")", "\n\n", "for", "_", ",", "subscriber", ":=", "range", "m", ".", "subscribers", "{", "m"...
// notifySubscribers notifies all currently active subscribers about the block.
[ "notifySubscribers", "notifies", "all", "currently", "active", "subscribers", "about", "the", "block", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L335-L341
train
lightninglabs/neutrino
blockntfns/manager.go
notifySubscriber
func (m *SubscriptionManager) notifySubscriber(sub *newSubscription, block BlockNtfn) { select { case sub.ntfnQueue.ChanIn() <- block: case <-sub.quit: case <-m.quit: return } }
go
func (m *SubscriptionManager) notifySubscriber(sub *newSubscription, block BlockNtfn) { select { case sub.ntfnQueue.ChanIn() <- block: case <-sub.quit: case <-m.quit: return } }
[ "func", "(", "m", "*", "SubscriptionManager", ")", "notifySubscriber", "(", "sub", "*", "newSubscription", ",", "block", "BlockNtfn", ")", "{", "select", "{", "case", "sub", ".", "ntfnQueue", ".", "ChanIn", "(", ")", "<-", "block", ":", "case", "<-", "su...
// notifySubscriber notifies a single subscriber about the block.
[ "notifySubscriber", "notifies", "a", "single", "subscriber", "about", "the", "block", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockntfns/manager.go#L344-L353
train
lightninglabs/neutrino
utxoscanner.go
deliver
func (r *GetUtxoRequest) deliver(report *SpendReport, err error) { select { case r.resultChan <- &getUtxoResult{report, err}: default: log.Warnf("duplicate getutxo result delivered for "+ "outpoint=%v, spend=%v, err=%v", r.Input.OutPoint, report, err) } }
go
func (r *GetUtxoRequest) deliver(report *SpendReport, err error) { select { case r.resultChan <- &getUtxoResult{report, err}: default: log.Warnf("duplicate getutxo result delivered for "+ "outpoint=%v, spend=%v, err=%v", r.Input.OutPoint, report, err) } }
[ "func", "(", "r", "*", "GetUtxoRequest", ")", "deliver", "(", "report", "*", "SpendReport", ",", "err", "error", ")", "{", "select", "{", "case", "r", ".", "resultChan", "<-", "&", "getUtxoResult", "{", "report", ",", "err", "}", ":", "default", ":", ...
// deliver tries to deliver the report or error to any subscribers. If // resultChan cannot accept a new update, this method will not block.
[ "deliver", "tries", "to", "deliver", "the", "report", "or", "error", "to", "any", "subscribers", ".", "If", "resultChan", "cannot", "accept", "a", "new", "update", "this", "method", "will", "not", "block", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L47-L55
train
lightninglabs/neutrino
utxoscanner.go
Result
func (r *GetUtxoRequest) Result(cancel <-chan struct{}) (*SpendReport, error) { r.mu.Lock() defer r.mu.Unlock() select { case result := <-r.resultChan: // Cache the first result returned, in case we have multiple // readers calling Result. if r.result == nil { r.result = result } return r.result.repo...
go
func (r *GetUtxoRequest) Result(cancel <-chan struct{}) (*SpendReport, error) { r.mu.Lock() defer r.mu.Unlock() select { case result := <-r.resultChan: // Cache the first result returned, in case we have multiple // readers calling Result. if r.result == nil { r.result = result } return r.result.repo...
[ "func", "(", "r", "*", "GetUtxoRequest", ")", "Result", "(", "cancel", "<-", "chan", "struct", "{", "}", ")", "(", "*", "SpendReport", ",", "error", ")", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", ...
// Result is callback returning either a spend report or an error.
[ "Result", "is", "callback", "returning", "either", "a", "spend", "report", "or", "an", "error", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L58-L78
train
lightninglabs/neutrino
utxoscanner.go
NewUtxoScanner
func NewUtxoScanner(cfg *UtxoScannerConfig) *UtxoScanner { scanner := &UtxoScanner{ cfg: cfg, quit: make(chan struct{}), shutdown: make(chan struct{}), } scanner.cv = sync.NewCond(&scanner.mu) return scanner }
go
func NewUtxoScanner(cfg *UtxoScannerConfig) *UtxoScanner { scanner := &UtxoScanner{ cfg: cfg, quit: make(chan struct{}), shutdown: make(chan struct{}), } scanner.cv = sync.NewCond(&scanner.mu) return scanner }
[ "func", "NewUtxoScanner", "(", "cfg", "*", "UtxoScannerConfig", ")", "*", "UtxoScanner", "{", "scanner", ":=", "&", "UtxoScanner", "{", "cfg", ":", "cfg", ",", "quit", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "shutdown", ":", "make", "("...
// NewUtxoScanner creates a new instance of UtxoScanner using the given chain // interface.
[ "NewUtxoScanner", "creates", "a", "new", "instance", "of", "UtxoScanner", "using", "the", "given", "chain", "interface", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L119-L128
train
lightninglabs/neutrino
utxoscanner.go
Start
func (s *UtxoScanner) Start() error { if !atomic.CompareAndSwapUint32(&s.started, 0, 1) { return nil } s.wg.Add(1) go s.batchManager() return nil }
go
func (s *UtxoScanner) Start() error { if !atomic.CompareAndSwapUint32(&s.started, 0, 1) { return nil } s.wg.Add(1) go s.batchManager() return nil }
[ "func", "(", "s", "*", "UtxoScanner", ")", "Start", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "s", ".", "started", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "s", ".", "wg", ".", ...
// Start begins running scan batches.
[ "Start", "begins", "running", "scan", "batches", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L131-L140
train
lightninglabs/neutrino
utxoscanner.go
Stop
func (s *UtxoScanner) Stop() error { if !atomic.CompareAndSwapUint32(&s.stopped, 0, 1) { return nil } close(s.quit) batchShutdown: for { select { case <-s.shutdown: break batchShutdown case <-time.After(50 * time.Millisecond): s.cv.Signal() } } // Cancel all pending get utxo requests that were ...
go
func (s *UtxoScanner) Stop() error { if !atomic.CompareAndSwapUint32(&s.stopped, 0, 1) { return nil } close(s.quit) batchShutdown: for { select { case <-s.shutdown: break batchShutdown case <-time.After(50 * time.Millisecond): s.cv.Signal() } } // Cancel all pending get utxo requests that were ...
[ "func", "(", "s", "*", "UtxoScanner", ")", "Stop", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "s", ".", "stopped", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "close", "(", "s", ".", ...
// Stop any in-progress scan.
[ "Stop", "any", "in", "-", "progress", "scan", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L143-L168
train
lightninglabs/neutrino
utxoscanner.go
Enqueue
func (s *UtxoScanner) Enqueue(input *InputWithScript, birthHeight uint32) (*GetUtxoRequest, error) { log.Debugf("Enqueuing request for %s with birth height %d", input.OutPoint.String(), birthHeight) req := &GetUtxoRequest{ Input: input, BirthHeight: birthHeight, resultChan: make(chan *getUtxoResult,...
go
func (s *UtxoScanner) Enqueue(input *InputWithScript, birthHeight uint32) (*GetUtxoRequest, error) { log.Debugf("Enqueuing request for %s with birth height %d", input.OutPoint.String(), birthHeight) req := &GetUtxoRequest{ Input: input, BirthHeight: birthHeight, resultChan: make(chan *getUtxoResult,...
[ "func", "(", "s", "*", "UtxoScanner", ")", "Enqueue", "(", "input", "*", "InputWithScript", ",", "birthHeight", "uint32", ")", "(", "*", "GetUtxoRequest", ",", "error", ")", "{", "log", ".", "Debugf", "(", "\"", "\"", ",", "input", ".", "OutPoint", "."...
// Enqueue takes a GetUtxoRequest and adds it to the next applicable batch.
[ "Enqueue", "takes", "a", "GetUtxoRequest", "and", "adds", "it", "to", "the", "next", "applicable", "batch", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L171-L200
train
lightninglabs/neutrino
utxoscanner.go
dequeueAtHeight
func (s *UtxoScanner) dequeueAtHeight(height uint32) []*GetUtxoRequest { s.cv.L.Lock() defer s.cv.L.Unlock() // Take any requests that are too old to go in this batch and keep them for // the next batch. for !s.pq.IsEmpty() && s.pq.Peek().BirthHeight < height { item := heap.Pop(&s.pq).(*GetUtxoRequest) s.next...
go
func (s *UtxoScanner) dequeueAtHeight(height uint32) []*GetUtxoRequest { s.cv.L.Lock() defer s.cv.L.Unlock() // Take any requests that are too old to go in this batch and keep them for // the next batch. for !s.pq.IsEmpty() && s.pq.Peek().BirthHeight < height { item := heap.Pop(&s.pq).(*GetUtxoRequest) s.next...
[ "func", "(", "s", "*", "UtxoScanner", ")", "dequeueAtHeight", "(", "height", "uint32", ")", "[", "]", "*", "GetUtxoRequest", "{", "s", ".", "cv", ".", "L", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "cv", ".", "L", ".", "Unlock", "(", ")", ...
// dequeueAtHeight returns all GetUtxoRequests that have starting height of the // given height.
[ "dequeueAtHeight", "returns", "all", "GetUtxoRequests", "that", "have", "starting", "height", "of", "the", "given", "height", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L252-L270
train
lightninglabs/neutrino
utxoscanner.go
scanFromHeight
func (s *UtxoScanner) scanFromHeight(initHeight uint32) error { // Before beginning the scan, grab the best block stamp we know of, // which will serve as an initial estimate for the end height of the // scan. bestStamp, err := s.cfg.BestSnapshot() if err != nil { return err } var ( // startHeight and endHe...
go
func (s *UtxoScanner) scanFromHeight(initHeight uint32) error { // Before beginning the scan, grab the best block stamp we know of, // which will serve as an initial estimate for the end height of the // scan. bestStamp, err := s.cfg.BestSnapshot() if err != nil { return err } var ( // startHeight and endHe...
[ "func", "(", "s", "*", "UtxoScanner", ")", "scanFromHeight", "(", "initHeight", "uint32", ")", "error", "{", "// Before beginning the scan, grab the best block stamp we know of,", "// which will serve as an initial estimate for the end height of the", "// scan.", "bestStamp", ",", ...
// scanFromHeight runs a single batch, pulling in any requests that get added // above the batch's last processed height. If there was an error, then return // the outstanding requests.
[ "scanFromHeight", "runs", "a", "single", "batch", "pulling", "in", "any", "requests", "that", "get", "added", "above", "the", "batch", "s", "last", "processed", "height", ".", "If", "there", "was", "an", "error", "then", "return", "the", "outstanding", "requ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L275-L388
train
lightninglabs/neutrino
utxoscanner.go
Push
func (pq *GetUtxoRequestPQ) Push(x interface{}) { item := x.(*GetUtxoRequest) *pq = append(*pq, item) }
go
func (pq *GetUtxoRequestPQ) Push(x interface{}) { item := x.(*GetUtxoRequest) *pq = append(*pq, item) }
[ "func", "(", "pq", "*", "GetUtxoRequestPQ", ")", "Push", "(", "x", "interface", "{", "}", ")", "{", "item", ":=", "x", ".", "(", "*", "GetUtxoRequest", ")", "\n", "*", "pq", "=", "append", "(", "*", "pq", ",", "item", ")", "\n", "}" ]
// Push is called by the heap.Interface implementation to add an element to the // end of the backing store. The heap library will then maintain the heap // invariant.
[ "Push", "is", "called", "by", "the", "heap", ".", "Interface", "implementation", "to", "add", "an", "element", "to", "the", "end", "of", "the", "backing", "store", ".", "The", "heap", "library", "will", "then", "maintain", "the", "heap", "invariant", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L410-L413
train
lightninglabs/neutrino
utxoscanner.go
Pop
func (pq *GetUtxoRequestPQ) Pop() interface{} { old := *pq n := len(old) item := old[n-1] *pq = old[0 : n-1] return item }
go
func (pq *GetUtxoRequestPQ) Pop() interface{} { old := *pq n := len(old) item := old[n-1] *pq = old[0 : n-1] return item }
[ "func", "(", "pq", "*", "GetUtxoRequestPQ", ")", "Pop", "(", ")", "interface", "{", "}", "{", "old", ":=", "*", "pq", "\n", "n", ":=", "len", "(", "old", ")", "\n", "item", ":=", "old", "[", "n", "-", "1", "]", "\n", "*", "pq", "=", "old", ...
// Pop is called by the heap.Interface implementation to remove an element from // the end of the backing store. The heap library will then maintain the heap // invariant.
[ "Pop", "is", "called", "by", "the", "heap", ".", "Interface", "implementation", "to", "remove", "an", "element", "from", "the", "end", "of", "the", "backing", "store", ".", "The", "heap", "library", "will", "then", "maintain", "the", "heap", "invariant", "...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/utxoscanner.go#L423-L429
train
lightninglabs/neutrino
blockmanager.go
newBlockManager
func newBlockManager(s *ChainService, firstPeerSignal <-chan struct{}) (*blockManager, error) { targetTimespan := int64(s.chainParams.TargetTimespan / time.Second) targetTimePerBlock := int64(s.chainParams.TargetTimePerBlock / time.Second) adjustmentFactor := s.chainParams.RetargetAdjustmentFactor bm := blockMan...
go
func newBlockManager(s *ChainService, firstPeerSignal <-chan struct{}) (*blockManager, error) { targetTimespan := int64(s.chainParams.TargetTimespan / time.Second) targetTimePerBlock := int64(s.chainParams.TargetTimePerBlock / time.Second) adjustmentFactor := s.chainParams.RetargetAdjustmentFactor bm := blockMan...
[ "func", "newBlockManager", "(", "s", "*", "ChainService", ",", "firstPeerSignal", "<-", "chan", "struct", "{", "}", ")", "(", "*", "blockManager", ",", "error", ")", "{", "targetTimespan", ":=", "int64", "(", "s", ".", "chainParams", ".", "TargetTimespan", ...
// newBlockManager returns a new bitcoin block manager. Use Start to begin // processing asynchronous block and inv updates.
[ "newBlockManager", "returns", "a", "new", "bitcoin", "block", "manager", ".", "Use", "Start", "to", "begin", "processing", "asynchronous", "block", "and", "inv", "updates", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L191-L264
train
lightninglabs/neutrino
blockmanager.go
Stop
func (b *blockManager) Stop() error { if atomic.AddInt32(&b.shutdown, 1) != 1 { log.Warnf("Block manager is already in the process of " + "shutting down") return nil } // We'll send out update signals before the quit to ensure that any // goroutines waiting on them will properly exit. done := make(chan str...
go
func (b *blockManager) Stop() error { if atomic.AddInt32(&b.shutdown, 1) != 1 { log.Warnf("Block manager is already in the process of " + "shutting down") return nil } // We'll send out update signals before the quit to ensure that any // goroutines waiting on them will properly exit. done := make(chan str...
[ "func", "(", "b", "*", "blockManager", ")", "Stop", "(", ")", "error", "{", "if", "atomic", ".", "AddInt32", "(", "&", "b", ".", "shutdown", ",", "1", ")", "!=", "1", "{", "log", ".", "Warnf", "(", "\"", "\"", "+", "\"", "\"", ")", "\n", "ret...
// Stop gracefully shuts down the block manager by stopping all asynchronous // handlers and waiting for them to finish.
[ "Stop", "gracefully", "shuts", "down", "the", "block", "manager", "by", "stopping", "all", "asynchronous", "handlers", "and", "waiting", "for", "them", "to", "finish", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L296-L328
train
lightninglabs/neutrino
blockmanager.go
NewPeer
func (b *blockManager) NewPeer(sp *ServerPeer) { // Ignore if we are shutting down. if atomic.LoadInt32(&b.shutdown) != 0 { return } select { case b.peerChan <- &newPeerMsg{peer: sp}: case <-b.quit: return } }
go
func (b *blockManager) NewPeer(sp *ServerPeer) { // Ignore if we are shutting down. if atomic.LoadInt32(&b.shutdown) != 0 { return } select { case b.peerChan <- &newPeerMsg{peer: sp}: case <-b.quit: return } }
[ "func", "(", "b", "*", "blockManager", ")", "NewPeer", "(", "sp", "*", "ServerPeer", ")", "{", "// Ignore if we are shutting down.", "if", "atomic", ".", "LoadInt32", "(", "&", "b", ".", "shutdown", ")", "!=", "0", "{", "return", "\n", "}", "\n\n", "sele...
// NewPeer informs the block manager of a newly active peer.
[ "NewPeer", "informs", "the", "block", "manager", "of", "a", "newly", "active", "peer", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L331-L342
train
lightninglabs/neutrino
blockmanager.go
writeCFHeadersMsg
func (b *blockManager) writeCFHeadersMsg(msg *wire.MsgCFHeaders, store *headerfs.FilterHeaderStore) (*chainhash.Hash, error) { b.newFilterHeadersMtx.Lock() defer b.newFilterHeadersMtx.Unlock() // Check that the PrevFilterHeader is the same as the last stored so we // can prevent misalignment. tip, tipHeight, er...
go
func (b *blockManager) writeCFHeadersMsg(msg *wire.MsgCFHeaders, store *headerfs.FilterHeaderStore) (*chainhash.Hash, error) { b.newFilterHeadersMtx.Lock() defer b.newFilterHeadersMtx.Unlock() // Check that the PrevFilterHeader is the same as the last stored so we // can prevent misalignment. tip, tipHeight, er...
[ "func", "(", "b", "*", "blockManager", ")", "writeCFHeadersMsg", "(", "msg", "*", "wire", ".", "MsgCFHeaders", ",", "store", "*", "headerfs", ".", "FilterHeaderStore", ")", "(", "*", "chainhash", ".", "Hash", ",", "error", ")", "{", "b", ".", "newFilterH...
// writeCFHeadersMsg writes a cfheaders message to the specified store. It // assumes that everything is being written in order. The hints are required to // store the correct block heights for the filters. We also return final // constructed cfheader in this range as this lets callers populate the prev // filter heade...
[ "writeCFHeadersMsg", "writes", "a", "cfheaders", "message", "to", "the", "specified", "store", ".", "It", "assumes", "that", "everything", "is", "being", "written", "in", "order", ".", "The", "hints", "are", "required", "to", "store", "the", "correct", "block"...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1079-L1169
train
lightninglabs/neutrino
blockmanager.go
minCheckpointHeight
func minCheckpointHeight(checkpoints map[string][]*chainhash.Hash) uint32 { // If the map is empty, return 0 immediately. if len(checkpoints) == 0 { return 0 } // Otherwise return the length of the shortest one. minHeight := uint32(math.MaxUint32) for _, cps := range checkpoints { height := uint32(len(cps) *...
go
func minCheckpointHeight(checkpoints map[string][]*chainhash.Hash) uint32 { // If the map is empty, return 0 immediately. if len(checkpoints) == 0 { return 0 } // Otherwise return the length of the shortest one. minHeight := uint32(math.MaxUint32) for _, cps := range checkpoints { height := uint32(len(cps) *...
[ "func", "minCheckpointHeight", "(", "checkpoints", "map", "[", "string", "]", "[", "]", "*", "chainhash", ".", "Hash", ")", "uint32", "{", "// If the map is empty, return 0 immediately.", "if", "len", "(", "checkpoints", ")", "==", "0", "{", "return", "0", "\n...
// minCheckpointHeight returns the height of the last filter checkpoint for the // shortest checkpoint list among the given lists.
[ "minCheckpointHeight", "returns", "the", "height", "of", "the", "last", "filter", "checkpoint", "for", "the", "shortest", "checkpoint", "list", "among", "the", "given", "lists", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1173-L1188
train
lightninglabs/neutrino
blockmanager.go
verifyCheckpoint
func verifyCheckpoint(prevCheckpoint, nextCheckpoint *chainhash.Hash, cfheaders *wire.MsgCFHeaders) bool { if *prevCheckpoint != cfheaders.PrevFilterHeader { return false } lastHeader := cfheaders.PrevFilterHeader for _, hash := range cfheaders.FilterHashes { lastHeader = chainhash.DoubleHashH( append(has...
go
func verifyCheckpoint(prevCheckpoint, nextCheckpoint *chainhash.Hash, cfheaders *wire.MsgCFHeaders) bool { if *prevCheckpoint != cfheaders.PrevFilterHeader { return false } lastHeader := cfheaders.PrevFilterHeader for _, hash := range cfheaders.FilterHashes { lastHeader = chainhash.DoubleHashH( append(has...
[ "func", "verifyCheckpoint", "(", "prevCheckpoint", ",", "nextCheckpoint", "*", "chainhash", ".", "Hash", ",", "cfheaders", "*", "wire", ".", "MsgCFHeaders", ")", "bool", "{", "if", "*", "prevCheckpoint", "!=", "cfheaders", ".", "PrevFilterHeader", "{", "return",...
// verifyHeaderCheckpoint verifies that a CFHeaders message matches the passed // checkpoints. It assumes everything else has been checked, including filter // type and stop hash matches, and returns true if matching and false if not.
[ "verifyHeaderCheckpoint", "verifies", "that", "a", "CFHeaders", "message", "matches", "the", "passed", "checkpoints", ".", "It", "assumes", "everything", "else", "has", "been", "checked", "including", "filter", "type", "and", "stop", "hash", "matches", "and", "ret...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1193-L1208
train
lightninglabs/neutrino
blockmanager.go
checkForCFHeaderMismatch
func checkForCFHeaderMismatch(headers map[string]*wire.MsgCFHeaders, idx int) bool { // First, see if we have a mismatch. hash := zeroHash for _, msg := range headers { if len(msg.FilterHashes) <= idx { continue } if hash == zeroHash { hash = *msg.FilterHashes[idx] continue } if hash != *msg.F...
go
func checkForCFHeaderMismatch(headers map[string]*wire.MsgCFHeaders, idx int) bool { // First, see if we have a mismatch. hash := zeroHash for _, msg := range headers { if len(msg.FilterHashes) <= idx { continue } if hash == zeroHash { hash = *msg.FilterHashes[idx] continue } if hash != *msg.F...
[ "func", "checkForCFHeaderMismatch", "(", "headers", "map", "[", "string", "]", "*", "wire", ".", "MsgCFHeaders", ",", "idx", "int", ")", "bool", "{", "// First, see if we have a mismatch.", "hash", ":=", "zeroHash", "\n", "for", "_", ",", "msg", ":=", "range",...
// checkForCFHeaderMismatch checks all peers' responses at a specific position // and detects a mismatch. It returns true if a mismatch has occurred.
[ "checkForCFHeaderMismatch", "checks", "all", "peers", "responses", "at", "a", "specific", "position", "and", "detects", "a", "mismatch", ".", "It", "returns", "true", "if", "a", "mismatch", "has", "occurred", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1356-L1378
train
lightninglabs/neutrino
blockmanager.go
resolveCFHeaderMismatch
func resolveCFHeaderMismatch(block *wire.MsgBlock, fType wire.FilterType, filtersFromPeers map[string]*gcs.Filter) ([]string, error) { badPeers := make(map[string]struct{}) blockHash := block.BlockHash() filterKey := builder.DeriveKey(&blockHash) log.Infof("Attempting to pinpoint mismatch in cfheaders for block...
go
func resolveCFHeaderMismatch(block *wire.MsgBlock, fType wire.FilterType, filtersFromPeers map[string]*gcs.Filter) ([]string, error) { badPeers := make(map[string]struct{}) blockHash := block.BlockHash() filterKey := builder.DeriveKey(&blockHash) log.Infof("Attempting to pinpoint mismatch in cfheaders for block...
[ "func", "resolveCFHeaderMismatch", "(", "block", "*", "wire", ".", "MsgBlock", ",", "fType", "wire", ".", "FilterType", ",", "filtersFromPeers", "map", "[", "string", "]", "*", "gcs", ".", "Filter", ")", "(", "[", "]", "string", ",", "error", ")", "{", ...
// resolveCFHeaderMismatch will attempt to cross-reference each filter received // by each peer based on what we can reconstruct and verify from the filter in // question. We'll return all the peers that returned what we believe to in // invalid filter.
[ "resolveCFHeaderMismatch", "will", "attempt", "to", "cross", "-", "reference", "each", "filter", "received", "by", "each", "peer", "based", "on", "what", "we", "can", "reconstruct", "and", "verify", "from", "the", "filter", "in", "question", ".", "We", "ll", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1384-L1473
train
lightninglabs/neutrino
blockmanager.go
getCFHeadersForAllPeers
func (b *blockManager) getCFHeadersForAllPeers(height uint32, fType wire.FilterType) (map[string]*wire.MsgCFHeaders, int) { // Create the map we're returning. headers := make(map[string]*wire.MsgCFHeaders) // Get the header we expect at either the tip of the block header store // or at the end of the maximum-siz...
go
func (b *blockManager) getCFHeadersForAllPeers(height uint32, fType wire.FilterType) (map[string]*wire.MsgCFHeaders, int) { // Create the map we're returning. headers := make(map[string]*wire.MsgCFHeaders) // Get the header we expect at either the tip of the block header store // or at the end of the maximum-siz...
[ "func", "(", "b", "*", "blockManager", ")", "getCFHeadersForAllPeers", "(", "height", "uint32", ",", "fType", "wire", ".", "FilterType", ")", "(", "map", "[", "string", "]", "*", "wire", ".", "MsgCFHeaders", ",", "int", ")", "{", "// Create the map we're ret...
// getCFHeadersForAllPeers runs a query for cfheaders at a specific height and // returns a map of responses from all peers. The second return value is the // number for cfheaders in each response.
[ "getCFHeadersForAllPeers", "runs", "a", "query", "for", "cfheaders", "at", "a", "specific", "height", "and", "returns", "a", "map", "of", "responses", "from", "all", "peers", ".", "The", "second", "return", "value", "is", "the", "number", "for", "cfheaders", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1478-L1528
train
lightninglabs/neutrino
blockmanager.go
fetchFilterFromAllPeers
func (b *blockManager) fetchFilterFromAllPeers( height uint32, blockHash chainhash.Hash, filterType wire.FilterType) map[string]*gcs.Filter { // We'll use this map to collate all responses we receive from each // peer. filterResponses := make(map[string]*gcs.Filter) // We'll now request the target filter from e...
go
func (b *blockManager) fetchFilterFromAllPeers( height uint32, blockHash chainhash.Hash, filterType wire.FilterType) map[string]*gcs.Filter { // We'll use this map to collate all responses we receive from each // peer. filterResponses := make(map[string]*gcs.Filter) // We'll now request the target filter from e...
[ "func", "(", "b", "*", "blockManager", ")", "fetchFilterFromAllPeers", "(", "height", "uint32", ",", "blockHash", "chainhash", ".", "Hash", ",", "filterType", "wire", ".", "FilterType", ")", "map", "[", "string", "]", "*", "gcs", ".", "Filter", "{", "// We...
// fetchFilterFromAllPeers attempts to fetch a filter for the target filter // type and blocks from all peers connected to the block manager. This method // returns a map which allows the caller to match a peer to the filter it // responded with.
[ "fetchFilterFromAllPeers", "attempts", "to", "fetch", "a", "filter", "for", "the", "target", "filter", "type", "and", "blocks", "from", "all", "peers", "connected", "to", "the", "block", "manager", ".", "This", "method", "returns", "a", "map", "which", "allows...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1534-L1584
train
lightninglabs/neutrino
blockmanager.go
getCheckpts
func (b *blockManager) getCheckpts(lastHash *chainhash.Hash, fType wire.FilterType) map[string][]*chainhash.Hash { checkpoints := make(map[string][]*chainhash.Hash) getCheckptMsg := wire.NewMsgGetCFCheckpt(fType, lastHash) b.server.queryAllPeers( getCheckptMsg, func(sp *ServerPeer, resp wire.Message, quit chan...
go
func (b *blockManager) getCheckpts(lastHash *chainhash.Hash, fType wire.FilterType) map[string][]*chainhash.Hash { checkpoints := make(map[string][]*chainhash.Hash) getCheckptMsg := wire.NewMsgGetCFCheckpt(fType, lastHash) b.server.queryAllPeers( getCheckptMsg, func(sp *ServerPeer, resp wire.Message, quit chan...
[ "func", "(", "b", "*", "blockManager", ")", "getCheckpts", "(", "lastHash", "*", "chainhash", ".", "Hash", ",", "fType", "wire", ".", "FilterType", ")", "map", "[", "string", "]", "[", "]", "*", "chainhash", ".", "Hash", "{", "checkpoints", ":=", "make...
// getCheckpts runs a query for cfcheckpts against all peers and returns a map // of responses.
[ "getCheckpts", "runs", "a", "query", "for", "cfcheckpts", "against", "all", "peers", "and", "returns", "a", "map", "of", "responses", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1588-L1608
train
lightninglabs/neutrino
blockmanager.go
checkCFCheckptSanity
func checkCFCheckptSanity(cp map[string][]*chainhash.Hash, headerStore *headerfs.FilterHeaderStore) (int, error) { // Get the known best header to compare against checkpoints. _, storeTip, err := headerStore.ChainTip() if err != nil { return 0, err } // Determine the maximum length of each peer's checkpoint l...
go
func checkCFCheckptSanity(cp map[string][]*chainhash.Hash, headerStore *headerfs.FilterHeaderStore) (int, error) { // Get the known best header to compare against checkpoints. _, storeTip, err := headerStore.ChainTip() if err != nil { return 0, err } // Determine the maximum length of each peer's checkpoint l...
[ "func", "checkCFCheckptSanity", "(", "cp", "map", "[", "string", "]", "[", "]", "*", "chainhash", ".", "Hash", ",", "headerStore", "*", "headerfs", ".", "FilterHeaderStore", ")", "(", "int", ",", "error", ")", "{", "// Get the known best header to compare agains...
// checkCFCheckptSanity checks whether all peers which have responded agree. // If so, it returns -1; otherwise, it returns the earliest index at which at // least one of the peers differs. The checkpoints are also checked against the // existing store up to the tip of the store. If all of the peers match but // the st...
[ "checkCFCheckptSanity", "checks", "whether", "all", "peers", "which", "have", "responded", "agree", ".", "If", "so", "it", "returns", "-", "1", ";", "otherwise", "it", "returns", "the", "earliest", "index", "at", "which", "at", "least", "one", "of", "the", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1615-L1671
train
lightninglabs/neutrino
blockmanager.go
SyncPeer
func (b *blockManager) SyncPeer() *ServerPeer { b.syncPeerMutex.Lock() defer b.syncPeerMutex.Unlock() return b.syncPeer }
go
func (b *blockManager) SyncPeer() *ServerPeer { b.syncPeerMutex.Lock() defer b.syncPeerMutex.Unlock() return b.syncPeer }
[ "func", "(", "b", "*", "blockManager", ")", "SyncPeer", "(", ")", "*", "ServerPeer", "{", "b", ".", "syncPeerMutex", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "syncPeerMutex", ".", "Unlock", "(", ")", "\n\n", "return", "b", ".", "syncPeer", "\n...
// SyncPeer returns the current sync peer.
[ "SyncPeer", "returns", "the", "current", "sync", "peer", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1714-L1719
train
lightninglabs/neutrino
blockmanager.go
findNextHeaderCheckpoint
func (b *blockManager) findNextHeaderCheckpoint(height int32) *chaincfg.Checkpoint { // There is no next checkpoint if there are none for this current // network. checkpoints := b.server.chainParams.Checkpoints if len(checkpoints) == 0 { return nil } // There is no next checkpoint if the height is already afte...
go
func (b *blockManager) findNextHeaderCheckpoint(height int32) *chaincfg.Checkpoint { // There is no next checkpoint if there are none for this current // network. checkpoints := b.server.chainParams.Checkpoints if len(checkpoints) == 0 { return nil } // There is no next checkpoint if the height is already afte...
[ "func", "(", "b", "*", "blockManager", ")", "findNextHeaderCheckpoint", "(", "height", "int32", ")", "*", "chaincfg", ".", "Checkpoint", "{", "// There is no next checkpoint if there are none for this current", "// network.", "checkpoints", ":=", "b", ".", "server", "."...
// findNextHeaderCheckpoint returns the next checkpoint after the passed height. // It returns nil when there is not one either because the height is already // later than the final checkpoint or there are none for the current network.
[ "findNextHeaderCheckpoint", "returns", "the", "next", "checkpoint", "after", "the", "passed", "height", ".", "It", "returns", "nil", "when", "there", "is", "not", "one", "either", "because", "the", "height", "is", "already", "later", "than", "the", "final", "c...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1731-L1755
train
lightninglabs/neutrino
blockmanager.go
findPreviousHeaderCheckpoint
func (b *blockManager) findPreviousHeaderCheckpoint(height int32) *chaincfg.Checkpoint { // Start with the genesis block - earliest checkpoint to which our code // will want to reset prevCheckpoint := &chaincfg.Checkpoint{ Height: 0, Hash: b.server.chainParams.GenesisHash, } // Find the latest checkpoint lo...
go
func (b *blockManager) findPreviousHeaderCheckpoint(height int32) *chaincfg.Checkpoint { // Start with the genesis block - earliest checkpoint to which our code // will want to reset prevCheckpoint := &chaincfg.Checkpoint{ Height: 0, Hash: b.server.chainParams.GenesisHash, } // Find the latest checkpoint lo...
[ "func", "(", "b", "*", "blockManager", ")", "findPreviousHeaderCheckpoint", "(", "height", "int32", ")", "*", "chaincfg", ".", "Checkpoint", "{", "// Start with the genesis block - earliest checkpoint to which our code", "// will want to reset", "prevCheckpoint", ":=", "&", ...
// findPreviousHeaderCheckpoint returns the last checkpoint before the passed // height. It returns a checkpoint matching the genesis block when the height // is earlier than the first checkpoint or there are no checkpoints for the // current network. This is used for resetting state when a malicious peer // sends us h...
[ "findPreviousHeaderCheckpoint", "returns", "the", "last", "checkpoint", "before", "the", "passed", "height", ".", "It", "returns", "a", "checkpoint", "matching", "the", "genesis", "block", "when", "the", "height", "is", "earlier", "than", "the", "first", "checkpoi...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1762-L1781
train
lightninglabs/neutrino
blockmanager.go
IsFullySynced
func (b *blockManager) IsFullySynced() bool { _, blockHeaderHeight, err := b.server.BlockHeaders.ChainTip() if err != nil { return false } _, filterHeaderHeight, err := b.server.RegFilterHeaders.ChainTip() if err != nil { return false } // If the block headers and filter headers are not at the same height,...
go
func (b *blockManager) IsFullySynced() bool { _, blockHeaderHeight, err := b.server.BlockHeaders.ChainTip() if err != nil { return false } _, filterHeaderHeight, err := b.server.RegFilterHeaders.ChainTip() if err != nil { return false } // If the block headers and filter headers are not at the same height,...
[ "func", "(", "b", "*", "blockManager", ")", "IsFullySynced", "(", ")", "bool", "{", "_", ",", "blockHeaderHeight", ",", "err", ":=", "b", ".", "server", ".", "BlockHeaders", ".", "ChainTip", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "f...
// IsFullySynced returns whether or not the block manager believed it is fully // synced to the connected peers, meaning both block headers and filter headers // are current.
[ "IsFullySynced", "returns", "whether", "or", "not", "the", "block", "manager", "believed", "it", "is", "fully", "synced", "to", "the", "connected", "peers", "meaning", "both", "block", "headers", "and", "filter", "headers", "are", "current", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1875-L1895
train
lightninglabs/neutrino
blockmanager.go
BlockHeadersSynced
func (b *blockManager) BlockHeadersSynced() bool { b.syncPeerMutex.RLock() defer b.syncPeerMutex.RUnlock() // Figure out the latest block we know. header, height, err := b.server.BlockHeaders.ChainTip() if err != nil { return false } // There is no last checkpoint if checkpoints are disabled or there are //...
go
func (b *blockManager) BlockHeadersSynced() bool { b.syncPeerMutex.RLock() defer b.syncPeerMutex.RUnlock() // Figure out the latest block we know. header, height, err := b.server.BlockHeaders.ChainTip() if err != nil { return false } // There is no last checkpoint if checkpoints are disabled or there are //...
[ "func", "(", "b", "*", "blockManager", ")", "BlockHeadersSynced", "(", ")", "bool", "{", "b", ".", "syncPeerMutex", ".", "RLock", "(", ")", "\n", "defer", "b", ".", "syncPeerMutex", ".", "RUnlock", "(", ")", "\n\n", "// Figure out the latest block we know.", ...
// BlockHeadersSynced returns whether or not the block manager believes its // block headers are synced with the connected peers.
[ "BlockHeadersSynced", "returns", "whether", "or", "not", "the", "block", "manager", "believes", "its", "block", "headers", "are", "synced", "with", "the", "connected", "peers", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1899-L1943
train
lightninglabs/neutrino
blockmanager.go
SynchronizeFilterHeaders
func (b *blockManager) SynchronizeFilterHeaders(f func(uint32) error) error { b.newFilterHeadersMtx.RLock() defer b.newFilterHeadersMtx.RUnlock() return f(b.filterHeaderTip) }
go
func (b *blockManager) SynchronizeFilterHeaders(f func(uint32) error) error { b.newFilterHeadersMtx.RLock() defer b.newFilterHeadersMtx.RUnlock() return f(b.filterHeaderTip) }
[ "func", "(", "b", "*", "blockManager", ")", "SynchronizeFilterHeaders", "(", "f", "func", "(", "uint32", ")", "error", ")", "error", "{", "b", ".", "newFilterHeadersMtx", ".", "RLock", "(", ")", "\n", "defer", "b", ".", "newFilterHeadersMtx", ".", "RUnlock...
// SynchronizeFilterHeaders allows the caller to execute a function closure // that depends on synchronization with the current set of filter headers. This // allows the caller to execute an action that depends on the current filter // header state, thereby ensuring that the state would shift from underneath // them. E...
[ "SynchronizeFilterHeaders", "allows", "the", "caller", "to", "execute", "a", "function", "closure", "that", "depends", "on", "synchronization", "with", "the", "current", "set", "of", "filter", "headers", ".", "This", "allows", "the", "caller", "to", "execute", "...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L1951-L1956
train
lightninglabs/neutrino
blockmanager.go
checkHeaderSanity
func (b *blockManager) checkHeaderSanity(blockHeader *wire.BlockHeader, maxTimestamp time.Time, reorgAttempt bool) error { diff, err := b.calcNextRequiredDifficulty( blockHeader.Timestamp, reorgAttempt) if err != nil { return err } stubBlock := btcutil.NewBlock(&wire.MsgBlock{ Header: *blockHeader, }) err ...
go
func (b *blockManager) checkHeaderSanity(blockHeader *wire.BlockHeader, maxTimestamp time.Time, reorgAttempt bool) error { diff, err := b.calcNextRequiredDifficulty( blockHeader.Timestamp, reorgAttempt) if err != nil { return err } stubBlock := btcutil.NewBlock(&wire.MsgBlock{ Header: *blockHeader, }) err ...
[ "func", "(", "b", "*", "blockManager", ")", "checkHeaderSanity", "(", "blockHeader", "*", "wire", ".", "BlockHeader", ",", "maxTimestamp", "time", ".", "Time", ",", "reorgAttempt", "bool", ")", "error", "{", "diff", ",", "err", ":=", "b", ".", "calcNextReq...
// checkHeaderSanity checks the PoW, and timestamp of a block header.
[ "checkHeaderSanity", "checks", "the", "PoW", "and", "timestamp", "of", "a", "block", "header", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L2416-L2437
train
lightninglabs/neutrino
blockmanager.go
calcNextRequiredDifficulty
func (b *blockManager) calcNextRequiredDifficulty(newBlockTime time.Time, reorgAttempt bool) (uint32, error) { hList := b.headerList if reorgAttempt { hList = b.reorgList } lastNode := hList.Back() // Genesis block. if lastNode == nil { return b.server.chainParams.PowLimitBits, nil } // Return the prev...
go
func (b *blockManager) calcNextRequiredDifficulty(newBlockTime time.Time, reorgAttempt bool) (uint32, error) { hList := b.headerList if reorgAttempt { hList = b.reorgList } lastNode := hList.Back() // Genesis block. if lastNode == nil { return b.server.chainParams.PowLimitBits, nil } // Return the prev...
[ "func", "(", "b", "*", "blockManager", ")", "calcNextRequiredDifficulty", "(", "newBlockTime", "time", ".", "Time", ",", "reorgAttempt", "bool", ")", "(", "uint32", ",", "error", ")", "{", "hList", ":=", "b", ".", "headerList", "\n", "if", "reorgAttempt", ...
// calcNextRequiredDifficulty calculates the required difficulty for the block // after the passed previous block node based on the difficulty retarget rules.
[ "calcNextRequiredDifficulty", "calculates", "the", "required", "difficulty", "for", "the", "block", "after", "the", "passed", "previous", "block", "node", "based", "on", "the", "difficulty", "retarget", "rules", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L2441-L2540
train
lightninglabs/neutrino
blockmanager.go
onBlockConnected
func (b *blockManager) onBlockConnected(header wire.BlockHeader, height uint32) { select { case b.blockNtfnChan <- blockntfns.NewBlockConnected(header, height): case <-b.quit: } }
go
func (b *blockManager) onBlockConnected(header wire.BlockHeader, height uint32) { select { case b.blockNtfnChan <- blockntfns.NewBlockConnected(header, height): case <-b.quit: } }
[ "func", "(", "b", "*", "blockManager", ")", "onBlockConnected", "(", "header", "wire", ".", "BlockHeader", ",", "height", "uint32", ")", "{", "select", "{", "case", "b", ".", "blockNtfnChan", "<-", "blockntfns", ".", "NewBlockConnected", "(", "header", ",", ...
// onBlockConnected queues a block notification that extends the current chain.
[ "onBlockConnected", "queues", "a", "block", "notification", "that", "extends", "the", "current", "chain", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L2591-L2596
train
lightninglabs/neutrino
blockmanager.go
onBlockDisconnected
func (b *blockManager) onBlockDisconnected(headerDisconnected wire.BlockHeader, heightDisconnected uint32, newChainTip wire.BlockHeader) { select { case b.blockNtfnChan <- blockntfns.NewBlockDisconnected( headerDisconnected, heightDisconnected, newChainTip, ): case <-b.quit: } }
go
func (b *blockManager) onBlockDisconnected(headerDisconnected wire.BlockHeader, heightDisconnected uint32, newChainTip wire.BlockHeader) { select { case b.blockNtfnChan <- blockntfns.NewBlockDisconnected( headerDisconnected, heightDisconnected, newChainTip, ): case <-b.quit: } }
[ "func", "(", "b", "*", "blockManager", ")", "onBlockDisconnected", "(", "headerDisconnected", "wire", ".", "BlockHeader", ",", "heightDisconnected", "uint32", ",", "newChainTip", "wire", ".", "BlockHeader", ")", "{", "select", "{", "case", "b", ".", "blockNtfnCh...
// onBlockDisconnected queues a block notification that reorgs the current // chain.
[ "onBlockDisconnected", "queues", "a", "block", "notification", "that", "reorgs", "the", "current", "chain", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L2600-L2609
train
lightninglabs/neutrino
blockmanager.go
NotificationsSinceHeight
func (b *blockManager) NotificationsSinceHeight( height uint32) ([]blockntfns.BlockNtfn, uint32, error) { b.newFilterHeadersMtx.RLock() defer b.newFilterHeadersMtx.RUnlock() bestHeight := b.filterHeaderTip // If a height of 0 is provided by the caller, then a backlog of // notifications is not needed. if heig...
go
func (b *blockManager) NotificationsSinceHeight( height uint32) ([]blockntfns.BlockNtfn, uint32, error) { b.newFilterHeadersMtx.RLock() defer b.newFilterHeadersMtx.RUnlock() bestHeight := b.filterHeaderTip // If a height of 0 is provided by the caller, then a backlog of // notifications is not needed. if heig...
[ "func", "(", "b", "*", "blockManager", ")", "NotificationsSinceHeight", "(", "height", "uint32", ")", "(", "[", "]", "blockntfns", ".", "BlockNtfn", ",", "uint32", ",", "error", ")", "{", "b", ".", "newFilterHeadersMtx", ".", "RLock", "(", ")", "\n", "de...
// NotificationsSinceHeight returns a backlog of block notifications starting // from the given height to the tip of the chain. When providing a height of 0, // a backlog will not be delivered.
[ "NotificationsSinceHeight", "returns", "a", "backlog", "of", "block", "notifications", "starting", "from", "the", "given", "height", "to", "the", "tip", "of", "the", "chain", ".", "When", "providing", "a", "height", "of", "0", "a", "backlog", "will", "not", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/blockmanager.go#L2620-L2661
train
lightninglabs/neutrino
cache/cacheable_filter.go
Size
func (c *CacheableFilter) Size() (uint64, error) { f, err := c.Filter.NBytes() if err != nil { return 0, err } return uint64(len(f)), nil }
go
func (c *CacheableFilter) Size() (uint64, error) { f, err := c.Filter.NBytes() if err != nil { return 0, err } return uint64(len(f)), nil }
[ "func", "(", "c", "*", "CacheableFilter", ")", "Size", "(", ")", "(", "uint64", ",", "error", ")", "{", "f", ",", "err", ":=", "c", ".", "Filter", ".", "NBytes", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", ...
// Size returns size of this filter in bytes.
[ "Size", "returns", "size", "of", "this", "filter", "in", "bytes", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/cache/cacheable_filter.go#L22-L28
train
lightninglabs/neutrino
cache/lru/lru.go
NewCache
func NewCache(capacity uint64) *Cache { return &Cache{ capacity: capacity, ll: list.New(), cache: make(elementMap), } }
go
func NewCache(capacity uint64) *Cache { return &Cache{ capacity: capacity, ll: list.New(), cache: make(elementMap), } }
[ "func", "NewCache", "(", "capacity", "uint64", ")", "*", "Cache", "{", "return", "&", "Cache", "{", "capacity", ":", "capacity", ",", "ll", ":", "list", ".", "New", "(", ")", ",", "cache", ":", "make", "(", "elementMap", ")", ",", "}", "\n", "}" ]
// NewCache return a cache with specified capacity, the cache's size can't // exceed that given capacity.
[ "NewCache", "return", "a", "cache", "with", "specified", "capacity", "the", "cache", "s", "size", "can", "t", "exceed", "that", "given", "capacity", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/cache/lru/lru.go#L45-L51
train
lightninglabs/neutrino
cache/lru/lru.go
evict
func (c *Cache) evict(needed uint64) (bool, error) { if needed > c.capacity { return false, fmt.Errorf("can't evict %v elements in size, "+ "since capacity is %v", needed, c.capacity) } evicted := false for c.capacity-c.size < needed { // We still need to evict some more elements. if c.ll.Len() == 0 { ...
go
func (c *Cache) evict(needed uint64) (bool, error) { if needed > c.capacity { return false, fmt.Errorf("can't evict %v elements in size, "+ "since capacity is %v", needed, c.capacity) } evicted := false for c.capacity-c.size < needed { // We still need to evict some more elements. if c.ll.Len() == 0 { ...
[ "func", "(", "c", "*", "Cache", ")", "evict", "(", "needed", "uint64", ")", "(", "bool", ",", "error", ")", "{", "if", "needed", ">", "c", ".", "capacity", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "\"", "\"", ","...
// evict will evict as many elements as necessary to make enough space for a new // element with size needed to be inserted.
[ "evict", "will", "evict", "as", "many", "elements", "as", "necessary", "to", "make", "enough", "space", "for", "a", "new", "element", "with", "size", "needed", "to", "be", "inserted", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/cache/lru/lru.go#L55-L94
train
lightninglabs/neutrino
cache/lru/lru.go
Get
func (c *Cache) Get(key interface{}) (cache.Value, error) { c.mtx.Lock() defer c.mtx.Unlock() el, ok := c.cache[key] if !ok { // Element not found in the cache. return nil, cache.ErrElementNotFound } // When the cache needs to evict a element to make space for another // one, it starts eviction from the ba...
go
func (c *Cache) Get(key interface{}) (cache.Value, error) { c.mtx.Lock() defer c.mtx.Unlock() el, ok := c.cache[key] if !ok { // Element not found in the cache. return nil, cache.ErrElementNotFound } // When the cache needs to evict a element to make space for another // one, it starts eviction from the ba...
[ "func", "(", "c", "*", "Cache", ")", "Get", "(", "key", "interface", "{", "}", ")", "(", "cache", ".", "Value", ",", "error", ")", "{", "c", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", ...
// Get will return value for a given key, making the element the most recently // accessed item in the process. Will return nil if the key isn't found.
[ "Get", "will", "return", "value", "for", "a", "given", "key", "making", "the", "element", "the", "most", "recently", "accessed", "item", "in", "the", "process", ".", "Will", "return", "nil", "if", "the", "key", "isn", "t", "found", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/cache/lru/lru.go#L144-L159
train
lightninglabs/neutrino
cache/lru/lru.go
Len
func (c *Cache) Len() int { c.mtx.RLock() defer c.mtx.RUnlock() return c.ll.Len() }
go
func (c *Cache) Len() int { c.mtx.RLock() defer c.mtx.RUnlock() return c.ll.Len() }
[ "func", "(", "c", "*", "Cache", ")", "Len", "(", ")", "int", "{", "c", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "return", "c", ".", "ll", ".", "Len", "(", ")", "\n", "}" ]
// Len returns number of elements in the cache.
[ "Len", "returns", "number", "of", "elements", "in", "the", "cache", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/cache/lru/lru.go#L162-L167
train
lightninglabs/neutrino
headerlist/bounded_header_list.go
NewBoundedMemoryChain
func NewBoundedMemoryChain(maxNodes uint32) *BoundedMemoryChain { return &BoundedMemoryChain{ headPtr: -1, tailPtr: -1, maxSize: int32(maxNodes), chain: make([]Node, maxNodes), } }
go
func NewBoundedMemoryChain(maxNodes uint32) *BoundedMemoryChain { return &BoundedMemoryChain{ headPtr: -1, tailPtr: -1, maxSize: int32(maxNodes), chain: make([]Node, maxNodes), } }
[ "func", "NewBoundedMemoryChain", "(", "maxNodes", "uint32", ")", "*", "BoundedMemoryChain", "{", "return", "&", "BoundedMemoryChain", "{", "headPtr", ":", "-", "1", ",", "tailPtr", ":", "-", "1", ",", "maxSize", ":", "int32", "(", "maxNodes", ")", ",", "ch...
// NewBoundedMemoryChain returns a new instance of the BoundedMemoryChain with // a target max number of nodes.
[ "NewBoundedMemoryChain", "returns", "a", "new", "instance", "of", "the", "BoundedMemoryChain", "with", "a", "target", "max", "number", "of", "nodes", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/headerlist/bounded_header_list.go#L35-L42
train
lightninglabs/neutrino
pushtx/error.go
IsBroadcastError
func IsBroadcastError(err error, codes ...BroadcastErrorCode) bool { broadcastErr, ok := err.(*BroadcastError) if !ok { return false } for _, code := range codes { if broadcastErr.Code == code { return true } } return false }
go
func IsBroadcastError(err error, codes ...BroadcastErrorCode) bool { broadcastErr, ok := err.(*BroadcastError) if !ok { return false } for _, code := range codes { if broadcastErr.Code == code { return true } } return false }
[ "func", "IsBroadcastError", "(", "err", "error", ",", "codes", "...", "BroadcastErrorCode", ")", "bool", "{", "broadcastErr", ",", "ok", ":=", "err", ".", "(", "*", "BroadcastError", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n\n", ...
// IsBroadcastError is a helper function that can be used to determine whether // an error is a BroadcastError that matches any of the specified codes.
[ "IsBroadcastError", "is", "a", "helper", "function", "that", "can", "be", "used", "to", "determine", "whether", "an", "error", "is", "a", "BroadcastError", "that", "matches", "any", "of", "the", "specified", "codes", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/pushtx/error.go#L72-L85
train
lightninglabs/neutrino
pushtx/error.go
ParseBroadcastError
func ParseBroadcastError(msg *wire.MsgReject, peerAddr string) *BroadcastError { // We'll determine the appropriate broadcast error code by looking at // the reject's message code and reason. The only reject codes returned // from peers (bitcoind and btcd) when attempting to accept a // transaction into their mempo...
go
func ParseBroadcastError(msg *wire.MsgReject, peerAddr string) *BroadcastError { // We'll determine the appropriate broadcast error code by looking at // the reject's message code and reason. The only reject codes returned // from peers (bitcoind and btcd) when attempting to accept a // transaction into their mempo...
[ "func", "ParseBroadcastError", "(", "msg", "*", "wire", ".", "MsgReject", ",", "peerAddr", "string", ")", "*", "BroadcastError", "{", "// We'll determine the appropriate broadcast error code by looking at", "// the reject's message code and reason. The only reject codes returned", ...
// ParseBroadcastError maps a peer's reject message for a transaction to a // BroadcastError.
[ "ParseBroadcastError", "maps", "a", "peer", "s", "reject", "message", "for", "a", "transaction", "to", "a", "BroadcastError", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/pushtx/error.go#L89-L152
train
lightninglabs/neutrino
filterdb/db.go
New
func New(db walletdb.DB, params chaincfg.Params) (*FilterStore, error) { err := walletdb.Update(db, func(tx walletdb.ReadWriteTx) error { // As part of our initial setup, we'll try to create the top // level filter bucket. If this already exists, then we can // exit early. filters, err := tx.CreateTopLevelBuck...
go
func New(db walletdb.DB, params chaincfg.Params) (*FilterStore, error) { err := walletdb.Update(db, func(tx walletdb.ReadWriteTx) error { // As part of our initial setup, we'll try to create the top // level filter bucket. If this already exists, then we can // exit early. filters, err := tx.CreateTopLevelBuck...
[ "func", "New", "(", "db", "walletdb", ".", "DB", ",", "params", "chaincfg", ".", "Params", ")", "(", "*", "FilterStore", ",", "error", ")", "{", "err", ":=", "walletdb", ".", "Update", "(", "db", ",", "func", "(", "tx", "walletdb", ".", "ReadWriteTx"...
// New creates a new instance of the FilterStore given an already open // database, and the target chain parameters.
[ "New", "creates", "a", "new", "instance", "of", "the", "FilterStore", "given", "an", "already", "open", "database", "and", "the", "target", "chain", "parameters", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/filterdb/db.go#L70-L108
train
lightninglabs/neutrino
filterdb/db.go
putFilter
func putFilter(bucket walletdb.ReadWriteBucket, hash *chainhash.Hash, filter *gcs.Filter) error { if filter == nil { return bucket.Put(hash[:], nil) } bytes, err := filter.NBytes() if err != nil { return err } return bucket.Put(hash[:], bytes) }
go
func putFilter(bucket walletdb.ReadWriteBucket, hash *chainhash.Hash, filter *gcs.Filter) error { if filter == nil { return bucket.Put(hash[:], nil) } bytes, err := filter.NBytes() if err != nil { return err } return bucket.Put(hash[:], bytes) }
[ "func", "putFilter", "(", "bucket", "walletdb", ".", "ReadWriteBucket", ",", "hash", "*", "chainhash", ".", "Hash", ",", "filter", "*", "gcs", ".", "Filter", ")", "error", "{", "if", "filter", "==", "nil", "{", "return", "bucket", ".", "Put", "(", "has...
// putFilter stores a filter in the database according to the corresponding // block hash. The passed bucket is expected to be the proper bucket for the // passed filter type.
[ "putFilter", "stores", "a", "filter", "in", "the", "database", "according", "to", "the", "corresponding", "block", "hash", ".", "The", "passed", "bucket", "is", "expected", "to", "be", "the", "proper", "bucket", "for", "the", "passed", "filter", "type", "." ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/filterdb/db.go#L113-L126
train
lightninglabs/neutrino
headerfs/store.go
newHeaderStore
func newHeaderStore(db walletdb.DB, filePath string, hType HeaderType) (*headerStore, error) { var flatFileName string switch hType { case Block: flatFileName = "block_headers.bin" case RegularFilter: flatFileName = "reg_filter_headers.bin" default: return nil, fmt.Errorf("unrecognized filter type: %v", hT...
go
func newHeaderStore(db walletdb.DB, filePath string, hType HeaderType) (*headerStore, error) { var flatFileName string switch hType { case Block: flatFileName = "block_headers.bin" case RegularFilter: flatFileName = "reg_filter_headers.bin" default: return nil, fmt.Errorf("unrecognized filter type: %v", hT...
[ "func", "newHeaderStore", "(", "db", "walletdb", ".", "DB", ",", "filePath", "string", ",", "hType", "HeaderType", ")", "(", "*", "headerStore", ",", "error", ")", "{", "var", "flatFileName", "string", "\n", "switch", "hType", "{", "case", "Block", ":", ...
// newHeaderStore creates a new headerStore given an already open database, a // target file path for the flat-file and a particular header type. The target // file will be created as necessary.
[ "newHeaderStore", "creates", "a", "new", "headerStore", "given", "an", "already", "open", "database", "a", "target", "file", "path", "for", "the", "flat", "-", "file", "and", "a", "particular", "header", "type", ".", "The", "target", "file", "will", "be", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/headerfs/store.go#L94-L129
train
lightninglabs/neutrino
headerfs/store.go
NewBlockHeaderStore
func NewBlockHeaderStore(filePath string, db walletdb.DB, netParams *chaincfg.Params) (BlockHeaderStore, error) { hStore, err := newHeaderStore(db, filePath, Block) if err != nil { return nil, err } // With the header store created, we'll fetch the file size to see if // we need to initialize it with the firs...
go
func NewBlockHeaderStore(filePath string, db walletdb.DB, netParams *chaincfg.Params) (BlockHeaderStore, error) { hStore, err := newHeaderStore(db, filePath, Block) if err != nil { return nil, err } // With the header store created, we'll fetch the file size to see if // we need to initialize it with the firs...
[ "func", "NewBlockHeaderStore", "(", "filePath", "string", ",", "db", "walletdb", ".", "DB", ",", "netParams", "*", "chaincfg", ".", "Params", ")", "(", "BlockHeaderStore", ",", "error", ")", "{", "hStore", ",", "err", ":=", "newHeaderStore", "(", "db", ","...
// NewBlockHeaderStore creates a new instance of the blockHeaderStore based on // a target file path, an open database instance, and finally a set of // parameters for the target chain. These parameters are required as if this is // the initial start up of the blockHeaderStore, then the initial genesis // header will n...
[ "NewBlockHeaderStore", "creates", "a", "new", "instance", "of", "the", "blockHeaderStore", "based", "on", "a", "target", "file", "path", "an", "open", "database", "instance", "and", "finally", "a", "set", "of", "parameters", "for", "the", "target", "chain", "....
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/headerfs/store.go#L148-L221
train
lightninglabs/neutrino
headerfs/store.go
toIndexEntry
func (b *BlockHeader) toIndexEntry() headerEntry { return headerEntry{ hash: b.BlockHash(), height: b.Height, } }
go
func (b *BlockHeader) toIndexEntry() headerEntry { return headerEntry{ hash: b.BlockHash(), height: b.Height, } }
[ "func", "(", "b", "*", "BlockHeader", ")", "toIndexEntry", "(", ")", "headerEntry", "{", "return", "headerEntry", "{", "hash", ":", "b", ".", "BlockHash", "(", ")", ",", "height", ":", "b", ".", "Height", ",", "}", "\n", "}" ]
// toIndexEntry converts the BlockHeader into a matching headerEntry. This // method is used when a header is to be written to disk.
[ "toIndexEntry", "converts", "the", "BlockHeader", "into", "a", "matching", "headerEntry", ".", "This", "method", "is", "used", "when", "a", "header", "is", "to", "be", "written", "to", "disk", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/headerfs/store.go#L356-L361
train
lightninglabs/neutrino
headerfs/store.go
BlockLocatorFromHash
func (h *blockHeaderStore) BlockLocatorFromHash(hash *chainhash.Hash) ( blockchain.BlockLocator, error) { // Lock store for read. h.mtx.RLock() defer h.mtx.RUnlock() return h.blockLocatorFromHash(hash) }
go
func (h *blockHeaderStore) BlockLocatorFromHash(hash *chainhash.Hash) ( blockchain.BlockLocator, error) { // Lock store for read. h.mtx.RLock() defer h.mtx.RUnlock() return h.blockLocatorFromHash(hash) }
[ "func", "(", "h", "*", "blockHeaderStore", ")", "BlockLocatorFromHash", "(", "hash", "*", "chainhash", ".", "Hash", ")", "(", "blockchain", ".", "BlockLocator", ",", "error", ")", "{", "// Lock store for read.", "h", ".", "mtx", ".", "RLock", "(", ")", "\n...
// BlockLocatorFromHash computes a block locator given a particular hash. The // standard Bitcoin algorithm to compute block locators are employed.
[ "BlockLocatorFromHash", "computes", "a", "block", "locator", "given", "a", "particular", "hash", ".", "The", "standard", "Bitcoin", "algorithm", "to", "compute", "block", "locators", "are", "employed", "." ]
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/headerfs/store.go#L472-L480
train
lightninglabs/neutrino
headerfs/store.go
CheckConnectivity
func (h *blockHeaderStore) CheckConnectivity() error { // Lock store for read. h.mtx.RLock() defer h.mtx.RUnlock() return walletdb.View(h.db, func(tx walletdb.ReadTx) error { // First, we'll fetch the root bucket, in order to use that to // fetch the bucket that houses the header index. rootBucket := tx.Read...
go
func (h *blockHeaderStore) CheckConnectivity() error { // Lock store for read. h.mtx.RLock() defer h.mtx.RUnlock() return walletdb.View(h.db, func(tx walletdb.ReadTx) error { // First, we'll fetch the root bucket, in order to use that to // fetch the bucket that houses the header index. rootBucket := tx.Read...
[ "func", "(", "h", "*", "blockHeaderStore", ")", "CheckConnectivity", "(", ")", "error", "{", "// Lock store for read.", "h", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "h", ".", "mtx", ".", "RUnlock", "(", ")", "\n\n", "return", "walletdb", ".", ...
// CheckConnectivity cycles through all of the block headers on disk, from last // to first, and makes sure they all connect to each other. Additionally, at // each block header, we also ensure that the index entry for that height and // hash also match up properly.
[ "CheckConnectivity", "cycles", "through", "all", "of", "the", "block", "headers", "on", "disk", "from", "last", "to", "first", "and", "makes", "sure", "they", "all", "connect", "to", "each", "other", ".", "Additionally", "at", "each", "block", "header", "we"...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/headerfs/store.go#L486-L561
train
lightninglabs/neutrino
headerfs/store.go
NewFilterHeaderStore
func NewFilterHeaderStore(filePath string, db walletdb.DB, filterType HeaderType, netParams *chaincfg.Params) (*FilterHeaderStore, error) { fStore, err := newHeaderStore(db, filePath, filterType) if err != nil { return nil, err } // With the header store created, we'll fetch the fiie size to see if // we need...
go
func NewFilterHeaderStore(filePath string, db walletdb.DB, filterType HeaderType, netParams *chaincfg.Params) (*FilterHeaderStore, error) { fStore, err := newHeaderStore(db, filePath, filterType) if err != nil { return nil, err } // With the header store created, we'll fetch the fiie size to see if // we need...
[ "func", "NewFilterHeaderStore", "(", "filePath", "string", ",", "db", "walletdb", ".", "DB", ",", "filterType", "HeaderType", ",", "netParams", "*", "chaincfg", ".", "Params", ")", "(", "*", "FilterHeaderStore", ",", "error", ")", "{", "fStore", ",", "err", ...
// NewFilterHeaderStore returns a new instance of the FilterHeaderStore based // on a target file path, filter type, and target net parameters. These // parameters are required as if this is the initial start up of the // FilterHeaderStore, then the initial genesis filter header will need to be // inserted.
[ "NewFilterHeaderStore", "returns", "a", "new", "instance", "of", "the", "FilterHeaderStore", "based", "on", "a", "target", "file", "path", "filter", "type", "and", "target", "net", "parameters", ".", "These", "parameters", "are", "required", "as", "if", "this", ...
a655679fe131a5d1b4417872cc834fc3862ac70e
https://github.com/lightninglabs/neutrino/blob/a655679fe131a5d1b4417872cc834fc3862ac70e/headerfs/store.go#L598-L694
train