id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
131,400
tendermint/tendermint
p2p/trust/config.go
customConfig
func customConfig(tmc TrustMetricConfig) TrustMetricConfig { config := DefaultConfig() // Check the config for set values, and setup appropriately if tmc.ProportionalWeight > 0 { config.ProportionalWeight = tmc.ProportionalWeight } if tmc.IntegralWeight > 0 { config.IntegralWeight = tmc.IntegralWeight } i...
go
func customConfig(tmc TrustMetricConfig) TrustMetricConfig { config := DefaultConfig() // Check the config for set values, and setup appropriately if tmc.ProportionalWeight > 0 { config.ProportionalWeight = tmc.ProportionalWeight } if tmc.IntegralWeight > 0 { config.IntegralWeight = tmc.IntegralWeight } i...
[ "func", "customConfig", "(", "tmc", "TrustMetricConfig", ")", "TrustMetricConfig", "{", "config", ":=", "DefaultConfig", "(", ")", "\n\n", "// Check the config for set values, and setup appropriately", "if", "tmc", ".", "ProportionalWeight", ">", "0", "{", "config", "."...
// Ensures that all configuration elements have valid values
[ "Ensures", "that", "all", "configuration", "elements", "have", "valid", "values" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/config.go#L34-L55
131,401
tendermint/tendermint
p2p/pex/addrbook.go
NewAddrBook
func NewAddrBook(filePath string, routabilityStrict bool) *addrBook { am := &addrBook{ rand: cmn.NewRand(), ourAddrs: make(map[string]struct{}), privateIDs: make(map[p2p.ID]struct{}), addrLookup: make(map[p2p.ID]*knownAddress), filePath: filePath, routabilityStr...
go
func NewAddrBook(filePath string, routabilityStrict bool) *addrBook { am := &addrBook{ rand: cmn.NewRand(), ourAddrs: make(map[string]struct{}), privateIDs: make(map[p2p.ID]struct{}), addrLookup: make(map[p2p.ID]*knownAddress), filePath: filePath, routabilityStr...
[ "func", "NewAddrBook", "(", "filePath", "string", ",", "routabilityStrict", "bool", ")", "*", "addrBook", "{", "am", ":=", "&", "addrBook", "{", "rand", ":", "cmn", ".", "NewRand", "(", ")", ",", "ourAddrs", ":", "make", "(", "map", "[", "string", "]",...
// NewAddrBook creates a new address book. // Use Start to begin processing asynchronous address updates.
[ "NewAddrBook", "creates", "a", "new", "address", "book", ".", "Use", "Start", "to", "begin", "processing", "asynchronous", "address", "updates", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L103-L115
131,402
tendermint/tendermint
p2p/pex/addrbook.go
OnStart
func (a *addrBook) OnStart() error { if err := a.BaseService.OnStart(); err != nil { return err } a.loadFromFile(a.filePath) // wg.Add to ensure that any invocation of .Wait() // later on will wait for saveRoutine to terminate. a.wg.Add(1) go a.saveRoutine() return nil }
go
func (a *addrBook) OnStart() error { if err := a.BaseService.OnStart(); err != nil { return err } a.loadFromFile(a.filePath) // wg.Add to ensure that any invocation of .Wait() // later on will wait for saveRoutine to terminate. a.wg.Add(1) go a.saveRoutine() return nil }
[ "func", "(", "a", "*", "addrBook", ")", "OnStart", "(", ")", "error", "{", "if", "err", ":=", "a", ".", "BaseService", ".", "OnStart", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "a", ".", "loadFromFile", "(", "a", ...
// OnStart implements Service.
[ "OnStart", "implements", "Service", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L134-L146
131,403
tendermint/tendermint
p2p/pex/addrbook.go
OurAddress
func (a *addrBook) OurAddress(addr *p2p.NetAddress) bool { a.mtx.Lock() defer a.mtx.Unlock() _, ok := a.ourAddrs[addr.String()] return ok }
go
func (a *addrBook) OurAddress(addr *p2p.NetAddress) bool { a.mtx.Lock() defer a.mtx.Unlock() _, ok := a.ourAddrs[addr.String()] return ok }
[ "func", "(", "a", "*", "addrBook", ")", "OurAddress", "(", "addr", "*", "p2p", ".", "NetAddress", ")", "bool", "{", "a", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "_", ",", "ok", ":=", ...
// OurAddress returns true if it is our address.
[ "OurAddress", "returns", "true", "if", "it", "is", "our", "address", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L173-L179
131,404
tendermint/tendermint
p2p/pex/addrbook.go
RemoveAddress
func (a *addrBook) RemoveAddress(addr *p2p.NetAddress) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.addrLookup[addr.ID] if ka == nil { return } a.Logger.Info("Remove address from book", "addr", addr) a.removeFromAllBuckets(ka) }
go
func (a *addrBook) RemoveAddress(addr *p2p.NetAddress) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.addrLookup[addr.ID] if ka == nil { return } a.Logger.Info("Remove address from book", "addr", addr) a.removeFromAllBuckets(ka) }
[ "func", "(", "a", "*", "addrBook", ")", "RemoveAddress", "(", "addr", "*", "p2p", ".", "NetAddress", ")", "{", "a", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "ka", ":=", "a", ".", "addrL...
// RemoveAddress implements AddrBook - removes the address from the book.
[ "RemoveAddress", "implements", "AddrBook", "-", "removes", "the", "address", "from", "the", "book", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L202-L212
131,405
tendermint/tendermint
p2p/pex/addrbook.go
IsGood
func (a *addrBook) IsGood(addr *p2p.NetAddress) bool { a.mtx.Lock() defer a.mtx.Unlock() return a.addrLookup[addr.ID].isOld() }
go
func (a *addrBook) IsGood(addr *p2p.NetAddress) bool { a.mtx.Lock() defer a.mtx.Unlock() return a.addrLookup[addr.ID].isOld() }
[ "func", "(", "a", "*", "addrBook", ")", "IsGood", "(", "addr", "*", "p2p", ".", "NetAddress", ")", "bool", "{", "a", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "return", "a", ".", "addrLo...
// IsGood returns true if peer was ever marked as good and haven't // done anything wrong since then.
[ "IsGood", "returns", "true", "if", "peer", "was", "ever", "marked", "as", "good", "and", "haven", "t", "done", "anything", "wrong", "since", "then", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L216-L221
131,406
tendermint/tendermint
p2p/pex/addrbook.go
HasAddress
func (a *addrBook) HasAddress(addr *p2p.NetAddress) bool { a.mtx.Lock() defer a.mtx.Unlock() ka := a.addrLookup[addr.ID] return ka != nil }
go
func (a *addrBook) HasAddress(addr *p2p.NetAddress) bool { a.mtx.Lock() defer a.mtx.Unlock() ka := a.addrLookup[addr.ID] return ka != nil }
[ "func", "(", "a", "*", "addrBook", ")", "HasAddress", "(", "addr", "*", "p2p", ".", "NetAddress", ")", "bool", "{", "a", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "ka", ":=", "a", ".", ...
// HasAddress returns true if the address is in the book.
[ "HasAddress", "returns", "true", "if", "the", "address", "is", "in", "the", "book", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L224-L230
131,407
tendermint/tendermint
p2p/pex/addrbook.go
MarkGood
func (a *addrBook) MarkGood(id p2p.ID) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.addrLookup[id] if ka == nil { return } ka.markGood() if ka.isNew() { a.moveToOld(ka) } }
go
func (a *addrBook) MarkGood(id p2p.ID) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.addrLookup[id] if ka == nil { return } ka.markGood() if ka.isNew() { a.moveToOld(ka) } }
[ "func", "(", "a", "*", "addrBook", ")", "MarkGood", "(", "id", "p2p", ".", "ID", ")", "{", "a", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "ka", ":=", "a", ".", "addrLookup", "[", "id",...
// MarkGood implements AddrBook - it marks the peer as good and // moves it into an "old" bucket.
[ "MarkGood", "implements", "AddrBook", "-", "it", "marks", "the", "peer", "as", "good", "and", "moves", "it", "into", "an", "old", "bucket", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L299-L311
131,408
tendermint/tendermint
p2p/pex/addrbook.go
MarkAttempt
func (a *addrBook) MarkAttempt(addr *p2p.NetAddress) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.addrLookup[addr.ID] if ka == nil { return } ka.markAttempt() }
go
func (a *addrBook) MarkAttempt(addr *p2p.NetAddress) { a.mtx.Lock() defer a.mtx.Unlock() ka := a.addrLookup[addr.ID] if ka == nil { return } ka.markAttempt() }
[ "func", "(", "a", "*", "addrBook", ")", "MarkAttempt", "(", "addr", "*", "p2p", ".", "NetAddress", ")", "{", "a", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "ka", ":=", "a", ".", "addrLoo...
// MarkAttempt implements AddrBook - it marks that an attempt was made to connect to the address.
[ "MarkAttempt", "implements", "AddrBook", "-", "it", "marks", "that", "an", "attempt", "was", "made", "to", "connect", "to", "the", "address", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L314-L323
131,409
tendermint/tendermint
p2p/pex/addrbook.go
addToOldBucket
func (a *addrBook) addToOldBucket(ka *knownAddress, bucketIdx int) bool { // Sanity check if ka.isNew() { a.Logger.Error(fmt.Sprintf("Cannot add new address to old bucket: %v", ka)) return false } if len(ka.Buckets) != 0 { a.Logger.Error(fmt.Sprintf("Cannot add already old address to another old bucket: %v", ...
go
func (a *addrBook) addToOldBucket(ka *knownAddress, bucketIdx int) bool { // Sanity check if ka.isNew() { a.Logger.Error(fmt.Sprintf("Cannot add new address to old bucket: %v", ka)) return false } if len(ka.Buckets) != 0 { a.Logger.Error(fmt.Sprintf("Cannot add already old address to another old bucket: %v", ...
[ "func", "(", "a", "*", "addrBook", ")", "addToOldBucket", "(", "ka", "*", "knownAddress", ",", "bucketIdx", "int", ")", "bool", "{", "// Sanity check", "if", "ka", ".", "isNew", "(", ")", "{", "a", ".", "Logger", ".", "Error", "(", "fmt", ".", "Sprin...
// Adds ka to old bucket. Returns false if it couldn't do it cuz buckets full.
[ "Adds", "ka", "to", "old", "bucket", ".", "Returns", "false", "if", "it", "couldn", "t", "do", "it", "cuz", "buckets", "full", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L502-L536
131,410
tendermint/tendermint
p2p/pex/addrbook.go
addAddress
func (a *addrBook) addAddress(addr, src *p2p.NetAddress) error { if addr == nil || src == nil { return ErrAddrBookNilAddr{addr, src} } if !addr.HasID() { return ErrAddrBookInvalidAddrNoID{addr} } if _, ok := a.privateIDs[addr.ID]; ok { return ErrAddrBookPrivate{addr} } if _, ok := a.privateIDs[src.ID]; ...
go
func (a *addrBook) addAddress(addr, src *p2p.NetAddress) error { if addr == nil || src == nil { return ErrAddrBookNilAddr{addr, src} } if !addr.HasID() { return ErrAddrBookInvalidAddrNoID{addr} } if _, ok := a.privateIDs[addr.ID]; ok { return ErrAddrBookPrivate{addr} } if _, ok := a.privateIDs[src.ID]; ...
[ "func", "(", "a", "*", "addrBook", ")", "addAddress", "(", "addr", ",", "src", "*", "p2p", ".", "NetAddress", ")", "error", "{", "if", "addr", "==", "nil", "||", "src", "==", "nil", "{", "return", "ErrAddrBookNilAddr", "{", "addr", ",", "src", "}", ...
// adds the address to a "new" bucket. if its already in one, // it only adds it probabilistically
[ "adds", "the", "address", "to", "a", "new", "bucket", ".", "if", "its", "already", "in", "one", "it", "only", "adds", "it", "probabilistically" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L584-L636
131,411
tendermint/tendermint
p2p/pex/addrbook.go
expireNew
func (a *addrBook) expireNew(bucketIdx int) { for addrStr, ka := range a.bucketsNew[bucketIdx] { // If an entry is bad, throw it away if ka.isBad() { a.Logger.Info(fmt.Sprintf("expiring bad address %v", addrStr)) a.removeFromBucket(ka, bucketTypeNew, bucketIdx) return } } // If we haven't thrown out ...
go
func (a *addrBook) expireNew(bucketIdx int) { for addrStr, ka := range a.bucketsNew[bucketIdx] { // If an entry is bad, throw it away if ka.isBad() { a.Logger.Info(fmt.Sprintf("expiring bad address %v", addrStr)) a.removeFromBucket(ka, bucketTypeNew, bucketIdx) return } } // If we haven't thrown out ...
[ "func", "(", "a", "*", "addrBook", ")", "expireNew", "(", "bucketIdx", "int", ")", "{", "for", "addrStr", ",", "ka", ":=", "range", "a", ".", "bucketsNew", "[", "bucketIdx", "]", "{", "// If an entry is bad, throw it away", "if", "ka", ".", "isBad", "(", ...
// Make space in the new buckets by expiring the really bad entries. // If no bad entries are available we remove the oldest.
[ "Make", "space", "in", "the", "new", "buckets", "by", "expiring", "the", "really", "bad", "entries", ".", "If", "no", "bad", "entries", "are", "available", "we", "remove", "the", "oldest", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/pex/addrbook.go#L678-L691
131,412
tendermint/tendermint
rpc/lib/server/http_server.go
DefaultConfig
func DefaultConfig() *Config { return &Config{ MaxOpenConnections: 0, // unlimited ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, } }
go
func DefaultConfig() *Config { return &Config{ MaxOpenConnections: 0, // unlimited ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, } }
[ "func", "DefaultConfig", "(", ")", "*", "Config", "{", "return", "&", "Config", "{", "MaxOpenConnections", ":", "0", ",", "// unlimited", "ReadTimeout", ":", "10", "*", "time", ".", "Second", ",", "WriteTimeout", ":", "10", "*", "time", ".", "Second", ",...
// DefaultConfig returns a default configuration.
[ "DefaultConfig", "returns", "a", "default", "configuration", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/lib/server/http_server.go#L32-L38
131,413
tendermint/tendermint
rpc/grpc/client_server.go
StartGRPCClient
func StartGRPCClient(protoAddr string) BroadcastAPIClient { conn, err := grpc.Dial(protoAddr, grpc.WithInsecure(), grpc.WithDialer(dialerFunc)) if err != nil { panic(err) } return NewBroadcastAPIClient(conn) }
go
func StartGRPCClient(protoAddr string) BroadcastAPIClient { conn, err := grpc.Dial(protoAddr, grpc.WithInsecure(), grpc.WithDialer(dialerFunc)) if err != nil { panic(err) } return NewBroadcastAPIClient(conn) }
[ "func", "StartGRPCClient", "(", "protoAddr", "string", ")", "BroadcastAPIClient", "{", "conn", ",", "err", ":=", "grpc", ".", "Dial", "(", "protoAddr", ",", "grpc", ".", "WithInsecure", "(", ")", ",", "grpc", ".", "WithDialer", "(", "dialerFunc", ")", ")",...
// StartGRPCClient dials the gRPC server using protoAddr and returns a new // BroadcastAPIClient.
[ "StartGRPCClient", "dials", "the", "gRPC", "server", "using", "protoAddr", "and", "returns", "a", "new", "BroadcastAPIClient", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/grpc/client_server.go#L28-L34
131,414
tendermint/tendermint
state/txindex/indexer_service.go
NewIndexerService
func NewIndexerService(idr TxIndexer, eventBus *types.EventBus) *IndexerService { is := &IndexerService{idr: idr, eventBus: eventBus} is.BaseService = *cmn.NewBaseService(nil, "IndexerService", is) return is }
go
func NewIndexerService(idr TxIndexer, eventBus *types.EventBus) *IndexerService { is := &IndexerService{idr: idr, eventBus: eventBus} is.BaseService = *cmn.NewBaseService(nil, "IndexerService", is) return is }
[ "func", "NewIndexerService", "(", "idr", "TxIndexer", ",", "eventBus", "*", "types", ".", "EventBus", ")", "*", "IndexerService", "{", "is", ":=", "&", "IndexerService", "{", "idr", ":", "idr", ",", "eventBus", ":", "eventBus", "}", "\n", "is", ".", "Bas...
// NewIndexerService returns a new service instance.
[ "NewIndexerService", "returns", "a", "new", "service", "instance", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/txindex/indexer_service.go#L25-L29
131,415
tendermint/tendermint
state/txindex/indexer_service.go
OnStart
func (is *IndexerService) OnStart() error { // Use SubscribeUnbuffered here to ensure both subscriptions does not get // cancelled due to not pulling messages fast enough. Cause this might // sometimes happen when there are no other subscribers. blockHeadersSub, err := is.eventBus.SubscribeUnbuffered(context.Backg...
go
func (is *IndexerService) OnStart() error { // Use SubscribeUnbuffered here to ensure both subscriptions does not get // cancelled due to not pulling messages fast enough. Cause this might // sometimes happen when there are no other subscribers. blockHeadersSub, err := is.eventBus.SubscribeUnbuffered(context.Backg...
[ "func", "(", "is", "*", "IndexerService", ")", "OnStart", "(", ")", "error", "{", "// Use SubscribeUnbuffered here to ensure both subscriptions does not get", "// cancelled due to not pulling messages fast enough. Cause this might", "// sometimes happen when there are no other subscribers....
// OnStart implements cmn.Service by subscribing for all transactions // and indexing them by tags.
[ "OnStart", "implements", "cmn", ".", "Service", "by", "subscribing", "for", "all", "transactions", "and", "indexing", "them", "by", "tags", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/txindex/indexer_service.go#L33-L71
131,416
tendermint/tendermint
state/txindex/indexer_service.go
OnStop
func (is *IndexerService) OnStop() { if is.eventBus.IsRunning() { _ = is.eventBus.UnsubscribeAll(context.Background(), subscriber) } }
go
func (is *IndexerService) OnStop() { if is.eventBus.IsRunning() { _ = is.eventBus.UnsubscribeAll(context.Background(), subscriber) } }
[ "func", "(", "is", "*", "IndexerService", ")", "OnStop", "(", ")", "{", "if", "is", ".", "eventBus", ".", "IsRunning", "(", ")", "{", "_", "=", "is", ".", "eventBus", ".", "UnsubscribeAll", "(", "context", ".", "Background", "(", ")", ",", "subscribe...
// OnStop implements cmn.Service by unsubscribing from all transactions.
[ "OnStop", "implements", "cmn", ".", "Service", "by", "unsubscribing", "from", "all", "transactions", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/txindex/indexer_service.go#L74-L78
131,417
tendermint/tendermint
blockchain/store.go
NewBlockStore
func NewBlockStore(db dbm.DB) *BlockStore { bsjson := LoadBlockStoreStateJSON(db) return &BlockStore{ height: bsjson.Height, db: db, } }
go
func NewBlockStore(db dbm.DB) *BlockStore { bsjson := LoadBlockStoreStateJSON(db) return &BlockStore{ height: bsjson.Height, db: db, } }
[ "func", "NewBlockStore", "(", "db", "dbm", ".", "DB", ")", "*", "BlockStore", "{", "bsjson", ":=", "LoadBlockStoreStateJSON", "(", "db", ")", "\n", "return", "&", "BlockStore", "{", "height", ":", "bsjson", ".", "Height", ",", "db", ":", "db", ",", "}"...
// NewBlockStore returns a new BlockStore with the given DB, // initialized to the last height that was committed to the DB.
[ "NewBlockStore", "returns", "a", "new", "BlockStore", "with", "the", "given", "DB", "initialized", "to", "the", "last", "height", "that", "was", "committed", "to", "the", "DB", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/store.go#L37-L43
131,418
tendermint/tendermint
blockchain/store.go
Height
func (bs *BlockStore) Height() int64 { bs.mtx.RLock() defer bs.mtx.RUnlock() return bs.height }
go
func (bs *BlockStore) Height() int64 { bs.mtx.RLock() defer bs.mtx.RUnlock() return bs.height }
[ "func", "(", "bs", "*", "BlockStore", ")", "Height", "(", ")", "int64", "{", "bs", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "bs", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "bs", ".", "height", "\n", "}" ]
// Height returns the last known contiguous block height.
[ "Height", "returns", "the", "last", "known", "contiguous", "block", "height", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/store.go#L46-L50
131,419
tendermint/tendermint
blockchain/store.go
LoadBlock
func (bs *BlockStore) LoadBlock(height int64) *types.Block { var blockMeta = bs.LoadBlockMeta(height) if blockMeta == nil { return nil } var block = new(types.Block) buf := []byte{} for i := 0; i < blockMeta.BlockID.PartsHeader.Total; i++ { part := bs.LoadBlockPart(height, i) buf = append(buf, part.Bytes.....
go
func (bs *BlockStore) LoadBlock(height int64) *types.Block { var blockMeta = bs.LoadBlockMeta(height) if blockMeta == nil { return nil } var block = new(types.Block) buf := []byte{} for i := 0; i < blockMeta.BlockID.PartsHeader.Total; i++ { part := bs.LoadBlockPart(height, i) buf = append(buf, part.Bytes.....
[ "func", "(", "bs", "*", "BlockStore", ")", "LoadBlock", "(", "height", "int64", ")", "*", "types", ".", "Block", "{", "var", "blockMeta", "=", "bs", ".", "LoadBlockMeta", "(", "height", ")", "\n", "if", "blockMeta", "==", "nil", "{", "return", "nil", ...
// LoadBlock returns the block with the given height. // If no block is found for that height, it returns nil.
[ "LoadBlock", "returns", "the", "block", "with", "the", "given", "height", ".", "If", "no", "block", "is", "found", "for", "that", "height", "it", "returns", "nil", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/store.go#L54-L73
131,420
tendermint/tendermint
blockchain/store.go
LoadBlockPart
func (bs *BlockStore) LoadBlockPart(height int64, index int) *types.Part { var part = new(types.Part) bz := bs.db.Get(calcBlockPartKey(height, index)) if len(bz) == 0 { return nil } err := cdc.UnmarshalBinaryBare(bz, part) if err != nil { panic(cmn.ErrorWrap(err, "Error reading block part")) } return part }
go
func (bs *BlockStore) LoadBlockPart(height int64, index int) *types.Part { var part = new(types.Part) bz := bs.db.Get(calcBlockPartKey(height, index)) if len(bz) == 0 { return nil } err := cdc.UnmarshalBinaryBare(bz, part) if err != nil { panic(cmn.ErrorWrap(err, "Error reading block part")) } return part }
[ "func", "(", "bs", "*", "BlockStore", ")", "LoadBlockPart", "(", "height", "int64", ",", "index", "int", ")", "*", "types", ".", "Part", "{", "var", "part", "=", "new", "(", "types", ".", "Part", ")", "\n", "bz", ":=", "bs", ".", "db", ".", "Get"...
// LoadBlockPart returns the Part at the given index // from the block at the given height. // If no part is found for the given height and index, it returns nil.
[ "LoadBlockPart", "returns", "the", "Part", "at", "the", "given", "index", "from", "the", "block", "at", "the", "given", "height", ".", "If", "no", "part", "is", "found", "for", "the", "given", "height", "and", "index", "it", "returns", "nil", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/store.go#L78-L89
131,421
tendermint/tendermint
blockchain/store.go
LoadBlockMeta
func (bs *BlockStore) LoadBlockMeta(height int64) *types.BlockMeta { var blockMeta = new(types.BlockMeta) bz := bs.db.Get(calcBlockMetaKey(height)) if len(bz) == 0 { return nil } err := cdc.UnmarshalBinaryBare(bz, blockMeta) if err != nil { panic(cmn.ErrorWrap(err, "Error reading block meta")) } return bloc...
go
func (bs *BlockStore) LoadBlockMeta(height int64) *types.BlockMeta { var blockMeta = new(types.BlockMeta) bz := bs.db.Get(calcBlockMetaKey(height)) if len(bz) == 0 { return nil } err := cdc.UnmarshalBinaryBare(bz, blockMeta) if err != nil { panic(cmn.ErrorWrap(err, "Error reading block meta")) } return bloc...
[ "func", "(", "bs", "*", "BlockStore", ")", "LoadBlockMeta", "(", "height", "int64", ")", "*", "types", ".", "BlockMeta", "{", "var", "blockMeta", "=", "new", "(", "types", ".", "BlockMeta", ")", "\n", "bz", ":=", "bs", ".", "db", ".", "Get", "(", "...
// LoadBlockMeta returns the BlockMeta for the given height. // If no block is found for the given height, it returns nil.
[ "LoadBlockMeta", "returns", "the", "BlockMeta", "for", "the", "given", "height", ".", "If", "no", "block", "is", "found", "for", "the", "given", "height", "it", "returns", "nil", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/store.go#L93-L104
131,422
tendermint/tendermint
blockchain/store.go
Save
func (bsj BlockStoreStateJSON) Save(db dbm.DB) { bytes, err := cdc.MarshalJSON(bsj) if err != nil { cmn.PanicSanity(fmt.Sprintf("Could not marshal state bytes: %v", err)) } db.SetSync(blockStoreKey, bytes) }
go
func (bsj BlockStoreStateJSON) Save(db dbm.DB) { bytes, err := cdc.MarshalJSON(bsj) if err != nil { cmn.PanicSanity(fmt.Sprintf("Could not marshal state bytes: %v", err)) } db.SetSync(blockStoreKey, bytes) }
[ "func", "(", "bsj", "BlockStoreStateJSON", ")", "Save", "(", "db", "dbm", ".", "DB", ")", "{", "bytes", ",", "err", ":=", "cdc", ".", "MarshalJSON", "(", "bsj", ")", "\n", "if", "err", "!=", "nil", "{", "cmn", ".", "PanicSanity", "(", "fmt", ".", ...
// Save persists the blockStore state to the database as JSON.
[ "Save", "persists", "the", "blockStore", "state", "to", "the", "database", "as", "JSON", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/store.go#L224-L230
131,423
tendermint/tendermint
blockchain/store.go
LoadBlockStoreStateJSON
func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON { bytes := db.Get(blockStoreKey) if len(bytes) == 0 { return BlockStoreStateJSON{ Height: 0, } } bsj := BlockStoreStateJSON{} err := cdc.UnmarshalJSON(bytes, &bsj) if err != nil { panic(fmt.Sprintf("Could not unmarshal bytes: %X", bytes)) } re...
go
func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON { bytes := db.Get(blockStoreKey) if len(bytes) == 0 { return BlockStoreStateJSON{ Height: 0, } } bsj := BlockStoreStateJSON{} err := cdc.UnmarshalJSON(bytes, &bsj) if err != nil { panic(fmt.Sprintf("Could not unmarshal bytes: %X", bytes)) } re...
[ "func", "LoadBlockStoreStateJSON", "(", "db", "dbm", ".", "DB", ")", "BlockStoreStateJSON", "{", "bytes", ":=", "db", ".", "Get", "(", "blockStoreKey", ")", "\n", "if", "len", "(", "bytes", ")", "==", "0", "{", "return", "BlockStoreStateJSON", "{", "Height...
// LoadBlockStoreStateJSON returns the BlockStoreStateJSON as loaded from disk. // If no BlockStoreStateJSON was previously persisted, it returns the zero value.
[ "LoadBlockStoreStateJSON", "returns", "the", "BlockStoreStateJSON", "as", "loaded", "from", "disk", ".", "If", "no", "BlockStoreStateJSON", "was", "previously", "persisted", "it", "returns", "the", "zero", "value", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/blockchain/store.go#L234-L247
131,424
tendermint/tendermint
p2p/peer_set.go
NewPeerSet
func NewPeerSet() *PeerSet { return &PeerSet{ lookup: make(map[ID]*peerSetItem), list: make([]Peer, 0, 256), } }
go
func NewPeerSet() *PeerSet { return &PeerSet{ lookup: make(map[ID]*peerSetItem), list: make([]Peer, 0, 256), } }
[ "func", "NewPeerSet", "(", ")", "*", "PeerSet", "{", "return", "&", "PeerSet", "{", "lookup", ":", "make", "(", "map", "[", "ID", "]", "*", "peerSetItem", ")", ",", "list", ":", "make", "(", "[", "]", "Peer", ",", "0", ",", "256", ")", ",", "}"...
// NewPeerSet creates a new peerSet with a list of initial capacity of 256 items.
[ "NewPeerSet", "creates", "a", "new", "peerSet", "with", "a", "list", "of", "initial", "capacity", "of", "256", "items", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer_set.go#L33-L38
131,425
tendermint/tendermint
p2p/peer_set.go
Add
func (ps *PeerSet) Add(peer Peer) error { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.lookup[peer.ID()] != nil { return ErrSwitchDuplicatePeerID{peer.ID()} } index := len(ps.list) // Appending is safe even with other goroutines // iterating over the ps.list slice. ps.list = append(ps.list, peer) ps.lookup[pe...
go
func (ps *PeerSet) Add(peer Peer) error { ps.mtx.Lock() defer ps.mtx.Unlock() if ps.lookup[peer.ID()] != nil { return ErrSwitchDuplicatePeerID{peer.ID()} } index := len(ps.list) // Appending is safe even with other goroutines // iterating over the ps.list slice. ps.list = append(ps.list, peer) ps.lookup[pe...
[ "func", "(", "ps", "*", "PeerSet", ")", "Add", "(", "peer", "Peer", ")", "error", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "ps", ".", "lookup", "[", "peer", ".", "ID...
// Add adds the peer to the PeerSet. // It returns an error carrying the reason, if the peer is already present.
[ "Add", "adds", "the", "peer", "to", "the", "PeerSet", ".", "It", "returns", "an", "error", "carrying", "the", "reason", "if", "the", "peer", "is", "already", "present", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer_set.go#L42-L56
131,426
tendermint/tendermint
p2p/peer_set.go
Has
func (ps *PeerSet) Has(peerKey ID) bool { ps.mtx.Lock() _, ok := ps.lookup[peerKey] ps.mtx.Unlock() return ok }
go
func (ps *PeerSet) Has(peerKey ID) bool { ps.mtx.Lock() _, ok := ps.lookup[peerKey] ps.mtx.Unlock() return ok }
[ "func", "(", "ps", "*", "PeerSet", ")", "Has", "(", "peerKey", "ID", ")", "bool", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "_", ",", "ok", ":=", "ps", ".", "lookup", "[", "peerKey", "]", "\n", "ps", ".", "mtx", ".", "Unlock", "(", ...
// Has returns true if the set contains the peer referred to by this // peerKey, otherwise false.
[ "Has", "returns", "true", "if", "the", "set", "contains", "the", "peer", "referred", "to", "by", "this", "peerKey", "otherwise", "false", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer_set.go#L60-L65
131,427
tendermint/tendermint
p2p/peer_set.go
HasIP
func (ps *PeerSet) HasIP(peerIP net.IP) bool { ps.mtx.Lock() defer ps.mtx.Unlock() return ps.hasIP(peerIP) }
go
func (ps *PeerSet) HasIP(peerIP net.IP) bool { ps.mtx.Lock() defer ps.mtx.Unlock() return ps.hasIP(peerIP) }
[ "func", "(", "ps", "*", "PeerSet", ")", "HasIP", "(", "peerIP", "net", ".", "IP", ")", "bool", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "return", "ps", ".", "hasIP", "(", ...
// HasIP returns true if the set contains the peer referred to by this IP // address, otherwise false.
[ "HasIP", "returns", "true", "if", "the", "set", "contains", "the", "peer", "referred", "to", "by", "this", "IP", "address", "otherwise", "false", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer_set.go#L69-L74
131,428
tendermint/tendermint
p2p/peer_set.go
hasIP
func (ps *PeerSet) hasIP(peerIP net.IP) bool { for _, item := range ps.lookup { if item.peer.RemoteIP().Equal(peerIP) { return true } } return false }
go
func (ps *PeerSet) hasIP(peerIP net.IP) bool { for _, item := range ps.lookup { if item.peer.RemoteIP().Equal(peerIP) { return true } } return false }
[ "func", "(", "ps", "*", "PeerSet", ")", "hasIP", "(", "peerIP", "net", ".", "IP", ")", "bool", "{", "for", "_", ",", "item", ":=", "range", "ps", ".", "lookup", "{", "if", "item", ".", "peer", ".", "RemoteIP", "(", ")", ".", "Equal", "(", "peer...
// hasIP does not acquire a lock so it can be used in public methods which // already lock.
[ "hasIP", "does", "not", "acquire", "a", "lock", "so", "it", "can", "be", "used", "in", "public", "methods", "which", "already", "lock", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer_set.go#L78-L86
131,429
tendermint/tendermint
p2p/peer_set.go
Get
func (ps *PeerSet) Get(peerKey ID) Peer { ps.mtx.Lock() defer ps.mtx.Unlock() item, ok := ps.lookup[peerKey] if ok { return item.peer } return nil }
go
func (ps *PeerSet) Get(peerKey ID) Peer { ps.mtx.Lock() defer ps.mtx.Unlock() item, ok := ps.lookup[peerKey] if ok { return item.peer } return nil }
[ "func", "(", "ps", "*", "PeerSet", ")", "Get", "(", "peerKey", "ID", ")", "Peer", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n", "item", ",", "ok", ":=", "ps", ".", "lookup", "[",...
// Get looks up a peer by the provided peerKey. Returns nil if peer is not // found.
[ "Get", "looks", "up", "a", "peer", "by", "the", "provided", "peerKey", ".", "Returns", "nil", "if", "peer", "is", "not", "found", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer_set.go#L90-L98
131,430
tendermint/tendermint
p2p/peer_set.go
Remove
func (ps *PeerSet) Remove(peer Peer) bool { ps.mtx.Lock() defer ps.mtx.Unlock() item := ps.lookup[peer.ID()] if item == nil { return false } index := item.index // Create a new copy of the list but with one less item. // (we must copy because we'll be mutating the list). newList := make([]Peer, len(ps.list...
go
func (ps *PeerSet) Remove(peer Peer) bool { ps.mtx.Lock() defer ps.mtx.Unlock() item := ps.lookup[peer.ID()] if item == nil { return false } index := item.index // Create a new copy of the list but with one less item. // (we must copy because we'll be mutating the list). newList := make([]Peer, len(ps.list...
[ "func", "(", "ps", "*", "PeerSet", ")", "Remove", "(", "peer", "Peer", ")", "bool", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "item", ":=", "ps", ".", "lookup", "[", "peer", ...
// Remove discards peer by its Key, if the peer was previously memoized. // Returns true if the peer was removed, and false if it was not found. // in the set.
[ "Remove", "discards", "peer", "by", "its", "Key", "if", "the", "peer", "was", "previously", "memoized", ".", "Returns", "true", "if", "the", "peer", "was", "removed", "and", "false", "if", "it", "was", "not", "found", ".", "in", "the", "set", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer_set.go#L103-L133
131,431
tendermint/tendermint
p2p/peer_set.go
Size
func (ps *PeerSet) Size() int { ps.mtx.Lock() defer ps.mtx.Unlock() return len(ps.list) }
go
func (ps *PeerSet) Size() int { ps.mtx.Lock() defer ps.mtx.Unlock() return len(ps.list) }
[ "func", "(", "ps", "*", "PeerSet", ")", "Size", "(", ")", "int", "{", "ps", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "ps", ".", "mtx", ".", "Unlock", "(", ")", "\n", "return", "len", "(", "ps", ".", "list", ")", "\n", "}" ]
// Size returns the number of unique items in the peerSet.
[ "Size", "returns", "the", "number", "of", "unique", "items", "in", "the", "peerSet", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/peer_set.go#L136-L140
131,432
tendermint/tendermint
consensus/state.go
NewConsensusState
func NewConsensusState( config *cfg.ConsensusConfig, state sm.State, blockExec *sm.BlockExecutor, blockStore sm.BlockStore, txNotifier txNotifier, evpool evidencePool, options ...StateOption, ) *ConsensusState { cs := &ConsensusState{ config: config, blockExec: blockExec, blockStore: ...
go
func NewConsensusState( config *cfg.ConsensusConfig, state sm.State, blockExec *sm.BlockExecutor, blockStore sm.BlockStore, txNotifier txNotifier, evpool evidencePool, options ...StateOption, ) *ConsensusState { cs := &ConsensusState{ config: config, blockExec: blockExec, blockStore: ...
[ "func", "NewConsensusState", "(", "config", "*", "cfg", ".", "ConsensusConfig", ",", "state", "sm", ".", "State", ",", "blockExec", "*", "sm", ".", "BlockExecutor", ",", "blockStore", "sm", ".", "BlockStore", ",", "txNotifier", "txNotifier", ",", "evpool", "...
// NewConsensusState returns a new ConsensusState.
[ "NewConsensusState", "returns", "a", "new", "ConsensusState", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L142-L182
131,433
tendermint/tendermint
consensus/state.go
GetState
func (cs *ConsensusState) GetState() sm.State { cs.mtx.RLock() defer cs.mtx.RUnlock() return cs.state.Copy() }
go
func (cs *ConsensusState) GetState() sm.State { cs.mtx.RLock() defer cs.mtx.RUnlock() return cs.state.Copy() }
[ "func", "(", "cs", "*", "ConsensusState", ")", "GetState", "(", ")", "sm", ".", "State", "{", "cs", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cs", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "cs", ".", "state", ".", "Copy", ...
// GetState returns a copy of the chain state.
[ "GetState", "returns", "a", "copy", "of", "the", "chain", "state", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L211-L215
131,434
tendermint/tendermint
consensus/state.go
GetLastHeight
func (cs *ConsensusState) GetLastHeight() int64 { cs.mtx.RLock() defer cs.mtx.RUnlock() return cs.RoundState.Height - 1 }
go
func (cs *ConsensusState) GetLastHeight() int64 { cs.mtx.RLock() defer cs.mtx.RUnlock() return cs.RoundState.Height - 1 }
[ "func", "(", "cs", "*", "ConsensusState", ")", "GetLastHeight", "(", ")", "int64", "{", "cs", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cs", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "cs", ".", "RoundState", ".", "Height", "-"...
// GetLastHeight returns the last height committed. // If there were no blocks, returns 0.
[ "GetLastHeight", "returns", "the", "last", "height", "committed", ".", "If", "there", "were", "no", "blocks", "returns", "0", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L219-L223
131,435
tendermint/tendermint
consensus/state.go
GetRoundState
func (cs *ConsensusState) GetRoundState() *cstypes.RoundState { cs.mtx.RLock() rs := cs.RoundState // copy cs.mtx.RUnlock() return &rs }
go
func (cs *ConsensusState) GetRoundState() *cstypes.RoundState { cs.mtx.RLock() rs := cs.RoundState // copy cs.mtx.RUnlock() return &rs }
[ "func", "(", "cs", "*", "ConsensusState", ")", "GetRoundState", "(", ")", "*", "cstypes", ".", "RoundState", "{", "cs", ".", "mtx", ".", "RLock", "(", ")", "\n", "rs", ":=", "cs", ".", "RoundState", "// copy", "\n", "cs", ".", "mtx", ".", "RUnlock", ...
// GetRoundState returns a shallow copy of the internal consensus state.
[ "GetRoundState", "returns", "a", "shallow", "copy", "of", "the", "internal", "consensus", "state", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L226-L231
131,436
tendermint/tendermint
consensus/state.go
GetRoundStateJSON
func (cs *ConsensusState) GetRoundStateJSON() ([]byte, error) { cs.mtx.RLock() defer cs.mtx.RUnlock() return cdc.MarshalJSON(cs.RoundState) }
go
func (cs *ConsensusState) GetRoundStateJSON() ([]byte, error) { cs.mtx.RLock() defer cs.mtx.RUnlock() return cdc.MarshalJSON(cs.RoundState) }
[ "func", "(", "cs", "*", "ConsensusState", ")", "GetRoundStateJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "cs", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cs", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", "cdc...
// GetRoundStateJSON returns a json of RoundState, marshalled using go-amino.
[ "GetRoundStateJSON", "returns", "a", "json", "of", "RoundState", "marshalled", "using", "go", "-", "amino", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L234-L238
131,437
tendermint/tendermint
consensus/state.go
GetRoundStateSimpleJSON
func (cs *ConsensusState) GetRoundStateSimpleJSON() ([]byte, error) { cs.mtx.RLock() defer cs.mtx.RUnlock() return cdc.MarshalJSON(cs.RoundState.RoundStateSimple()) }
go
func (cs *ConsensusState) GetRoundStateSimpleJSON() ([]byte, error) { cs.mtx.RLock() defer cs.mtx.RUnlock() return cdc.MarshalJSON(cs.RoundState.RoundStateSimple()) }
[ "func", "(", "cs", "*", "ConsensusState", ")", "GetRoundStateSimpleJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "cs", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cs", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "return", ...
// GetRoundStateSimpleJSON returns a json of RoundStateSimple, marshalled using go-amino.
[ "GetRoundStateSimpleJSON", "returns", "a", "json", "of", "RoundStateSimple", "marshalled", "using", "go", "-", "amino", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L241-L245
131,438
tendermint/tendermint
consensus/state.go
GetValidators
func (cs *ConsensusState) GetValidators() (int64, []*types.Validator) { cs.mtx.RLock() defer cs.mtx.RUnlock() return cs.state.LastBlockHeight, cs.state.Validators.Copy().Validators }
go
func (cs *ConsensusState) GetValidators() (int64, []*types.Validator) { cs.mtx.RLock() defer cs.mtx.RUnlock() return cs.state.LastBlockHeight, cs.state.Validators.Copy().Validators }
[ "func", "(", "cs", "*", "ConsensusState", ")", "GetValidators", "(", ")", "(", "int64", ",", "[", "]", "*", "types", ".", "Validator", ")", "{", "cs", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cs", ".", "mtx", ".", "RUnlock", "(", ")", ...
// GetValidators returns a copy of the current validators.
[ "GetValidators", "returns", "a", "copy", "of", "the", "current", "validators", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L248-L252
131,439
tendermint/tendermint
consensus/state.go
SetPrivValidator
func (cs *ConsensusState) SetPrivValidator(priv types.PrivValidator) { cs.mtx.Lock() cs.privValidator = priv cs.mtx.Unlock() }
go
func (cs *ConsensusState) SetPrivValidator(priv types.PrivValidator) { cs.mtx.Lock() cs.privValidator = priv cs.mtx.Unlock() }
[ "func", "(", "cs", "*", "ConsensusState", ")", "SetPrivValidator", "(", "priv", "types", ".", "PrivValidator", ")", "{", "cs", ".", "mtx", ".", "Lock", "(", ")", "\n", "cs", ".", "privValidator", "=", "priv", "\n", "cs", ".", "mtx", ".", "Unlock", "(...
// SetPrivValidator sets the private validator account for signing votes.
[ "SetPrivValidator", "sets", "the", "private", "validator", "account", "for", "signing", "votes", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L255-L259
131,440
tendermint/tendermint
consensus/state.go
SetTimeoutTicker
func (cs *ConsensusState) SetTimeoutTicker(timeoutTicker TimeoutTicker) { cs.mtx.Lock() cs.timeoutTicker = timeoutTicker cs.mtx.Unlock() }
go
func (cs *ConsensusState) SetTimeoutTicker(timeoutTicker TimeoutTicker) { cs.mtx.Lock() cs.timeoutTicker = timeoutTicker cs.mtx.Unlock() }
[ "func", "(", "cs", "*", "ConsensusState", ")", "SetTimeoutTicker", "(", "timeoutTicker", "TimeoutTicker", ")", "{", "cs", ".", "mtx", ".", "Lock", "(", ")", "\n", "cs", ".", "timeoutTicker", "=", "timeoutTicker", "\n", "cs", ".", "mtx", ".", "Unlock", "(...
// SetTimeoutTicker sets the local timer. It may be useful to overwrite for testing.
[ "SetTimeoutTicker", "sets", "the", "local", "timer", ".", "It", "may", "be", "useful", "to", "overwrite", "for", "testing", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L262-L266
131,441
tendermint/tendermint
consensus/state.go
LoadCommit
func (cs *ConsensusState) LoadCommit(height int64) *types.Commit { cs.mtx.RLock() defer cs.mtx.RUnlock() if height == cs.blockStore.Height() { return cs.blockStore.LoadSeenCommit(height) } return cs.blockStore.LoadBlockCommit(height) }
go
func (cs *ConsensusState) LoadCommit(height int64) *types.Commit { cs.mtx.RLock() defer cs.mtx.RUnlock() if height == cs.blockStore.Height() { return cs.blockStore.LoadSeenCommit(height) } return cs.blockStore.LoadBlockCommit(height) }
[ "func", "(", "cs", "*", "ConsensusState", ")", "LoadCommit", "(", "height", "int64", ")", "*", "types", ".", "Commit", "{", "cs", ".", "mtx", ".", "RLock", "(", ")", "\n", "defer", "cs", ".", "mtx", ".", "RUnlock", "(", ")", "\n", "if", "height", ...
// LoadCommit loads the commit for a given height.
[ "LoadCommit", "loads", "the", "commit", "for", "a", "given", "height", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L269-L276
131,442
tendermint/tendermint
consensus/state.go
OnStart
func (cs *ConsensusState) OnStart() error { if err := cs.evsw.Start(); err != nil { return err } // we may set the WAL in testing before calling Start, // so only OpenWAL if its still the nilWAL if _, ok := cs.wal.(nilWAL); ok { walFile := cs.config.WalFile() wal, err := cs.OpenWAL(walFile) if err != nil ...
go
func (cs *ConsensusState) OnStart() error { if err := cs.evsw.Start(); err != nil { return err } // we may set the WAL in testing before calling Start, // so only OpenWAL if its still the nilWAL if _, ok := cs.wal.(nilWAL); ok { walFile := cs.config.WalFile() wal, err := cs.OpenWAL(walFile) if err != nil ...
[ "func", "(", "cs", "*", "ConsensusState", ")", "OnStart", "(", ")", "error", "{", "if", "err", ":=", "cs", ".", "evsw", ".", "Start", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// we may set the WAL in testing before cal...
// OnStart implements cmn.Service. // It loads the latest state via the WAL, and starts the timeout and receive routines.
[ "OnStart", "implements", "cmn", ".", "Service", ".", "It", "loads", "the", "latest", "state", "via", "the", "WAL", "and", "starts", "the", "timeout", "and", "receive", "routines", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L280-L341
131,443
tendermint/tendermint
consensus/state.go
OpenWAL
func (cs *ConsensusState) OpenWAL(walFile string) (WAL, error) { wal, err := NewWAL(walFile) if err != nil { cs.Logger.Error("Failed to open WAL for consensus state", "wal", walFile, "err", err) return nil, err } wal.SetLogger(cs.Logger.With("wal", walFile)) if err := wal.Start(); err != nil { return nil, er...
go
func (cs *ConsensusState) OpenWAL(walFile string) (WAL, error) { wal, err := NewWAL(walFile) if err != nil { cs.Logger.Error("Failed to open WAL for consensus state", "wal", walFile, "err", err) return nil, err } wal.SetLogger(cs.Logger.With("wal", walFile)) if err := wal.Start(); err != nil { return nil, er...
[ "func", "(", "cs", "*", "ConsensusState", ")", "OpenWAL", "(", "walFile", "string", ")", "(", "WAL", ",", "error", ")", "{", "wal", ",", "err", ":=", "NewWAL", "(", "walFile", ")", "\n", "if", "err", "!=", "nil", "{", "cs", ".", "Logger", ".", "E...
// OpenWAL opens a file to log all consensus messages and timeouts for deterministic accountability
[ "OpenWAL", "opens", "a", "file", "to", "log", "all", "consensus", "messages", "and", "timeouts", "for", "deterministic", "accountability" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L369-L380
131,444
tendermint/tendermint
consensus/state.go
SetProposal
func (cs *ConsensusState) SetProposal(proposal *types.Proposal, peerID p2p.ID) error { if peerID == "" { cs.internalMsgQueue <- msgInfo{&ProposalMessage{proposal}, ""} } else { cs.peerMsgQueue <- msgInfo{&ProposalMessage{proposal}, peerID} } // TODO: wait for event?! return nil }
go
func (cs *ConsensusState) SetProposal(proposal *types.Proposal, peerID p2p.ID) error { if peerID == "" { cs.internalMsgQueue <- msgInfo{&ProposalMessage{proposal}, ""} } else { cs.peerMsgQueue <- msgInfo{&ProposalMessage{proposal}, peerID} } // TODO: wait for event?! return nil }
[ "func", "(", "cs", "*", "ConsensusState", ")", "SetProposal", "(", "proposal", "*", "types", ".", "Proposal", ",", "peerID", "p2p", ".", "ID", ")", "error", "{", "if", "peerID", "==", "\"", "\"", "{", "cs", ".", "internalMsgQueue", "<-", "msgInfo", "{"...
// SetProposal inputs a proposal.
[ "SetProposal", "inputs", "a", "proposal", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L402-L412
131,445
tendermint/tendermint
consensus/state.go
AddProposalBlockPart
func (cs *ConsensusState) AddProposalBlockPart(height int64, round int, part *types.Part, peerID p2p.ID) error { if peerID == "" { cs.internalMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, ""} } else { cs.peerMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, peerID} } // TODO: wait for ...
go
func (cs *ConsensusState) AddProposalBlockPart(height int64, round int, part *types.Part, peerID p2p.ID) error { if peerID == "" { cs.internalMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, ""} } else { cs.peerMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, peerID} } // TODO: wait for ...
[ "func", "(", "cs", "*", "ConsensusState", ")", "AddProposalBlockPart", "(", "height", "int64", ",", "round", "int", ",", "part", "*", "types", ".", "Part", ",", "peerID", "p2p", ".", "ID", ")", "error", "{", "if", "peerID", "==", "\"", "\"", "{", "cs...
// AddProposalBlockPart inputs a part of the proposal block.
[ "AddProposalBlockPart", "inputs", "a", "part", "of", "the", "proposal", "block", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L415-L425
131,446
tendermint/tendermint
consensus/state.go
SetProposalAndBlock
func (cs *ConsensusState) SetProposalAndBlock(proposal *types.Proposal, block *types.Block, parts *types.PartSet, peerID p2p.ID) error { if err := cs.SetProposal(proposal, peerID); err != nil { return err } for i := 0; i < parts.Total(); i++ { part := parts.GetPart(i) if err := cs.AddProposalBlockPart(proposal...
go
func (cs *ConsensusState) SetProposalAndBlock(proposal *types.Proposal, block *types.Block, parts *types.PartSet, peerID p2p.ID) error { if err := cs.SetProposal(proposal, peerID); err != nil { return err } for i := 0; i < parts.Total(); i++ { part := parts.GetPart(i) if err := cs.AddProposalBlockPart(proposal...
[ "func", "(", "cs", "*", "ConsensusState", ")", "SetProposalAndBlock", "(", "proposal", "*", "types", ".", "Proposal", ",", "block", "*", "types", ".", "Block", ",", "parts", "*", "types", ".", "PartSet", ",", "peerID", "p2p", ".", "ID", ")", "error", "...
// SetProposalAndBlock inputs the proposal and all block parts.
[ "SetProposalAndBlock", "inputs", "the", "proposal", "and", "all", "block", "parts", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L428-L439
131,447
tendermint/tendermint
consensus/state.go
sendInternalMessage
func (cs *ConsensusState) sendInternalMessage(mi msgInfo) { select { case cs.internalMsgQueue <- mi: default: // NOTE: using the go-routine means our votes can // be processed out of order. // TODO: use CList here for strict determinism and // attempt push to internalMsgQueue in receiveRoutine cs.Logger.In...
go
func (cs *ConsensusState) sendInternalMessage(mi msgInfo) { select { case cs.internalMsgQueue <- mi: default: // NOTE: using the go-routine means our votes can // be processed out of order. // TODO: use CList here for strict determinism and // attempt push to internalMsgQueue in receiveRoutine cs.Logger.In...
[ "func", "(", "cs", "*", "ConsensusState", ")", "sendInternalMessage", "(", "mi", "msgInfo", ")", "{", "select", "{", "case", "cs", ".", "internalMsgQueue", "<-", "mi", ":", "default", ":", "// NOTE: using the go-routine means our votes can", "// be processed out of or...
// send a msg into the receiveRoutine regarding our own proposal, block part, or vote
[ "send", "a", "msg", "into", "the", "receiveRoutine", "regarding", "our", "own", "proposal", "block", "part", "or", "vote" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L467-L478
131,448
tendermint/tendermint
consensus/state.go
updateToState
func (cs *ConsensusState) updateToState(state sm.State) { if cs.CommitRound > -1 && 0 < cs.Height && cs.Height != state.LastBlockHeight { cmn.PanicSanity(fmt.Sprintf("updateToState() expected state height of %v but found %v", cs.Height, state.LastBlockHeight)) } if !cs.state.IsEmpty() && cs.state.LastBlockHeigh...
go
func (cs *ConsensusState) updateToState(state sm.State) { if cs.CommitRound > -1 && 0 < cs.Height && cs.Height != state.LastBlockHeight { cmn.PanicSanity(fmt.Sprintf("updateToState() expected state height of %v but found %v", cs.Height, state.LastBlockHeight)) } if !cs.state.IsEmpty() && cs.state.LastBlockHeigh...
[ "func", "(", "cs", "*", "ConsensusState", ")", "updateToState", "(", "state", "sm", ".", "State", ")", "{", "if", "cs", ".", "CommitRound", ">", "-", "1", "&&", "0", "<", "cs", ".", "Height", "&&", "cs", ".", "Height", "!=", "state", ".", "LastBloc...
// Updates ConsensusState and increments height to match that of state. // The round becomes 0 and cs.Step becomes cstypes.RoundStepNewHeight.
[ "Updates", "ConsensusState", "and", "increments", "height", "to", "match", "that", "of", "state", ".", "The", "round", "becomes", "0", "and", "cs", ".", "Step", "becomes", "cstypes", ".", "RoundStepNewHeight", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L505-L575
131,449
tendermint/tendermint
consensus/state.go
finalizeCommit
func (cs *ConsensusState) finalizeCommit(height int64) { if cs.Height != height || cs.Step != cstypes.RoundStepCommit { cs.Logger.Debug(fmt.Sprintf("finalizeCommit(%v): Invalid args. Current step: %v/%v/%v", height, cs.Height, cs.Round, cs.Step)) return } blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoTh...
go
func (cs *ConsensusState) finalizeCommit(height int64) { if cs.Height != height || cs.Step != cstypes.RoundStepCommit { cs.Logger.Debug(fmt.Sprintf("finalizeCommit(%v): Invalid args. Current step: %v/%v/%v", height, cs.Height, cs.Round, cs.Step)) return } blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoTh...
[ "func", "(", "cs", "*", "ConsensusState", ")", "finalizeCommit", "(", "height", "int64", ")", "{", "if", "cs", ".", "Height", "!=", "height", "||", "cs", ".", "Step", "!=", "cstypes", ".", "RoundStepCommit", "{", "cs", ".", "Logger", ".", "Debug", "(",...
// Increment height and goto cstypes.RoundStepNewHeight
[ "Increment", "height", "and", "goto", "cstypes", ".", "RoundStepNewHeight" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L1270-L1363
131,450
tendermint/tendermint
consensus/state.go
tryAddVote
func (cs *ConsensusState) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, error) { added, err := cs.addVote(vote, peerID) if err != nil { // If the vote height is off, we'll just ignore it, // But if it's a conflicting sig, add it to the cs.evpool. // If it's otherwise invalid, punish peer. if err == ErrVo...
go
func (cs *ConsensusState) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, error) { added, err := cs.addVote(vote, peerID) if err != nil { // If the vote height is off, we'll just ignore it, // But if it's a conflicting sig, add it to the cs.evpool. // If it's otherwise invalid, punish peer. if err == ErrVo...
[ "func", "(", "cs", "*", "ConsensusState", ")", "tryAddVote", "(", "vote", "*", "types", ".", "Vote", ",", "peerID", "p2p", ".", "ID", ")", "(", "bool", ",", "error", ")", "{", "added", ",", "err", ":=", "cs", ".", "addVote", "(", "vote", ",", "pe...
// Attempt to add the vote. if its a duplicate signature, dupeout the validator
[ "Attempt", "to", "add", "the", "vote", ".", "if", "its", "a", "duplicate", "signature", "dupeout", "the", "validator" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L1513-L1537
131,451
tendermint/tendermint
consensus/state.go
signAddVote
func (cs *ConsensusState) signAddVote(type_ types.SignedMsgType, hash []byte, header types.PartSetHeader) *types.Vote { // if we don't have a key or we're not in the validator set, do nothing if cs.privValidator == nil || !cs.Validators.HasAddress(cs.privValidator.GetPubKey().Address()) { return nil } vote, err :...
go
func (cs *ConsensusState) signAddVote(type_ types.SignedMsgType, hash []byte, header types.PartSetHeader) *types.Vote { // if we don't have a key or we're not in the validator set, do nothing if cs.privValidator == nil || !cs.Validators.HasAddress(cs.privValidator.GetPubKey().Address()) { return nil } vote, err :...
[ "func", "(", "cs", "*", "ConsensusState", ")", "signAddVote", "(", "type_", "types", ".", "SignedMsgType", ",", "hash", "[", "]", "byte", ",", "header", "types", ".", "PartSetHeader", ")", "*", "types", ".", "Vote", "{", "// if we don't have a key or we're not...
// sign the vote and publish on internalMsgQueue
[ "sign", "the", "vote", "and", "publish", "on", "internalMsgQueue" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/state.go#L1727-L1742
131,452
tendermint/tendermint
rpc/client/httpclient.go
OnStart
func (w *WSEvents) OnStart() error { w.ws = rpcclient.NewWSClient(w.remote, w.endpoint, rpcclient.OnReconnect(func() { // resubscribe immediately w.redoSubscriptionsAfter(0 * time.Second) })) w.ws.SetCodec(w.cdc) err := w.ws.Start() if err != nil { return err } go w.eventListener() return nil }
go
func (w *WSEvents) OnStart() error { w.ws = rpcclient.NewWSClient(w.remote, w.endpoint, rpcclient.OnReconnect(func() { // resubscribe immediately w.redoSubscriptionsAfter(0 * time.Second) })) w.ws.SetCodec(w.cdc) err := w.ws.Start() if err != nil { return err } go w.eventListener() return nil }
[ "func", "(", "w", "*", "WSEvents", ")", "OnStart", "(", ")", "error", "{", "w", ".", "ws", "=", "rpcclient", ".", "NewWSClient", "(", "w", ".", "remote", ",", "w", ".", "endpoint", ",", "rpcclient", ".", "OnReconnect", "(", "func", "(", ")", "{", ...
// OnStart implements cmn.Service by starting WSClient and event loop.
[ "OnStart", "implements", "cmn", ".", "Service", "by", "starting", "WSClient", "and", "event", "loop", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/httpclient.go#L281-L295
131,453
tendermint/tendermint
rpc/client/httpclient.go
Subscribe
func (w *WSEvents) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error) { if err := w.ws.Subscribe(ctx, query); err != nil { return nil, err } outCap := 1 if len(outCapacity) > 0 { outCap = outCapacity[0] } outc := make(chan ctypes.ResultE...
go
func (w *WSEvents) Subscribe(ctx context.Context, subscriber, query string, outCapacity ...int) (out <-chan ctypes.ResultEvent, err error) { if err := w.ws.Subscribe(ctx, query); err != nil { return nil, err } outCap := 1 if len(outCapacity) > 0 { outCap = outCapacity[0] } outc := make(chan ctypes.ResultE...
[ "func", "(", "w", "*", "WSEvents", ")", "Subscribe", "(", "ctx", "context", ".", "Context", ",", "subscriber", ",", "query", "string", ",", "outCapacity", "...", "int", ")", "(", "out", "<-", "chan", "ctypes", ".", "ResultEvent", ",", "err", "error", "...
// Subscribe implements EventsClient by using WSClient to subscribe given // subscriber to query. By default, returns a channel with cap=1. Error is // returned if it fails to subscribe. // Channel is never closed to prevent clients from seeing an erroneus event.
[ "Subscribe", "implements", "EventsClient", "by", "using", "WSClient", "to", "subscribe", "given", "subscriber", "to", "query", ".", "By", "default", "returns", "a", "channel", "with", "cap", "=", "1", ".", "Error", "is", "returned", "if", "it", "fails", "to"...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/httpclient.go#L306-L326
131,454
tendermint/tendermint
rpc/client/httpclient.go
Unsubscribe
func (w *WSEvents) Unsubscribe(ctx context.Context, subscriber, query string) error { if err := w.ws.Unsubscribe(ctx, query); err != nil { return err } w.mtx.Lock() _, ok := w.subscriptions[query] if ok { delete(w.subscriptions, query) } w.mtx.Unlock() return nil }
go
func (w *WSEvents) Unsubscribe(ctx context.Context, subscriber, query string) error { if err := w.ws.Unsubscribe(ctx, query); err != nil { return err } w.mtx.Lock() _, ok := w.subscriptions[query] if ok { delete(w.subscriptions, query) } w.mtx.Unlock() return nil }
[ "func", "(", "w", "*", "WSEvents", ")", "Unsubscribe", "(", "ctx", "context", ".", "Context", ",", "subscriber", ",", "query", "string", ")", "error", "{", "if", "err", ":=", "w", ".", "ws", ".", "Unsubscribe", "(", "ctx", ",", "query", ")", ";", "...
// Unsubscribe implements EventsClient by using WSClient to unsubscribe given // subscriber from query.
[ "Unsubscribe", "implements", "EventsClient", "by", "using", "WSClient", "to", "unsubscribe", "given", "subscriber", "from", "query", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/httpclient.go#L330-L343
131,455
tendermint/tendermint
rpc/client/httpclient.go
UnsubscribeAll
func (w *WSEvents) UnsubscribeAll(ctx context.Context, subscriber string) error { if err := w.ws.UnsubscribeAll(ctx); err != nil { return err } w.mtx.Lock() w.subscriptions = make(map[string]chan ctypes.ResultEvent) w.mtx.Unlock() return nil }
go
func (w *WSEvents) UnsubscribeAll(ctx context.Context, subscriber string) error { if err := w.ws.UnsubscribeAll(ctx); err != nil { return err } w.mtx.Lock() w.subscriptions = make(map[string]chan ctypes.ResultEvent) w.mtx.Unlock() return nil }
[ "func", "(", "w", "*", "WSEvents", ")", "UnsubscribeAll", "(", "ctx", "context", ".", "Context", ",", "subscriber", "string", ")", "error", "{", "if", "err", ":=", "w", ".", "ws", ".", "UnsubscribeAll", "(", "ctx", ")", ";", "err", "!=", "nil", "{", ...
// UnsubscribeAll implements EventsClient by using WSClient to unsubscribe // given subscriber from all the queries.
[ "UnsubscribeAll", "implements", "EventsClient", "by", "using", "WSClient", "to", "unsubscribe", "given", "subscriber", "from", "all", "the", "queries", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/httpclient.go#L347-L357
131,456
tendermint/tendermint
rpc/client/httpclient.go
redoSubscriptionsAfter
func (w *WSEvents) redoSubscriptionsAfter(d time.Duration) { time.Sleep(d) for q := range w.subscriptions { err := w.ws.Subscribe(context.Background(), q) if err != nil { w.Logger.Error("Failed to resubscribe", "err", err) } } }
go
func (w *WSEvents) redoSubscriptionsAfter(d time.Duration) { time.Sleep(d) for q := range w.subscriptions { err := w.ws.Subscribe(context.Background(), q) if err != nil { w.Logger.Error("Failed to resubscribe", "err", err) } } }
[ "func", "(", "w", "*", "WSEvents", ")", "redoSubscriptionsAfter", "(", "d", "time", ".", "Duration", ")", "{", "time", ".", "Sleep", "(", "d", ")", "\n\n", "for", "q", ":=", "range", "w", ".", "subscriptions", "{", "err", ":=", "w", ".", "ws", ".",...
// After being reconnected, it is necessary to redo subscription to server // otherwise no data will be automatically received.
[ "After", "being", "reconnected", "it", "is", "necessary", "to", "redo", "subscription", "to", "server", "otherwise", "no", "data", "will", "be", "automatically", "received", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/httpclient.go#L361-L370
131,457
tendermint/tendermint
consensus/types/peer_round_state.go
StringIndented
func (prs PeerRoundState) StringIndented(indent string) string { return fmt.Sprintf(`PeerRoundState{ %s %v/%v/%v @%v %s Proposal %v -> %v %s POL %v (round %v) %s Prevotes %v %s Precommits %v %s LastCommit %v (round %v) %s Catchup %v (round %v) %s}`, indent, prs.Height, prs.Round, prs.Step, prs.Start...
go
func (prs PeerRoundState) StringIndented(indent string) string { return fmt.Sprintf(`PeerRoundState{ %s %v/%v/%v @%v %s Proposal %v -> %v %s POL %v (round %v) %s Prevotes %v %s Precommits %v %s LastCommit %v (round %v) %s Catchup %v (round %v) %s}`, indent, prs.Height, prs.Round, prs.Step, prs.Start...
[ "func", "(", "prs", "PeerRoundState", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "`PeerRoundState{\n%s %v/%v/%v @%v\n%s Proposal %v -> %v\n%s POL %v (round %v)\n%s Prevotes %v\n%s Precommits %v\n%s LastComm...
// StringIndented returns a string representation of the PeerRoundState
[ "StringIndented", "returns", "a", "string", "representation", "of", "the", "PeerRoundState" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/peer_round_state.go#L39-L57
131,458
tendermint/tendermint
libs/db/remotedb/remotedb.go
Next
func (rItr *reverseIterator) Next() { var err error rItr.cur, err = rItr.dric.Recv() if err != nil { panic(fmt.Sprintf("RemoteDB.ReverseIterator.Next error: %v", err)) } }
go
func (rItr *reverseIterator) Next() { var err error rItr.cur, err = rItr.dric.Recv() if err != nil { panic(fmt.Sprintf("RemoteDB.ReverseIterator.Next error: %v", err)) } }
[ "func", "(", "rItr", "*", "reverseIterator", ")", "Next", "(", ")", "{", "var", "err", "error", "\n", "rItr", ".", "cur", ",", "err", "=", "rItr", ".", "dric", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", "."...
// Next advances the current reverseIterator
[ "Next", "advances", "the", "current", "reverseIterator" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/remotedb/remotedb.go#L152-L158
131,459
tendermint/tendermint
libs/db/remotedb/remotedb.go
Next
func (itr *iterator) Next() { var err error itr.cur, err = itr.dic.Recv() if err != nil { panic(fmt.Sprintf("RemoteDB.Iterator.Next error: %v", err)) } }
go
func (itr *iterator) Next() { var err error itr.cur, err = itr.dic.Recv() if err != nil { panic(fmt.Sprintf("RemoteDB.Iterator.Next error: %v", err)) } }
[ "func", "(", "itr", "*", "iterator", ")", "Next", "(", ")", "{", "var", "err", "error", "\n", "itr", ".", "cur", ",", "err", "=", "itr", ".", "dic", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprint...
// Next advances the current iterator
[ "Next", "advances", "the", "current", "iterator" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/remotedb/remotedb.go#L200-L206
131,460
tendermint/tendermint
state/state.go
Copy
func (state State) Copy() State { return State{ Version: state.Version, ChainID: state.ChainID, LastBlockHeight: state.LastBlockHeight, LastBlockTotalTx: state.LastBlockTotalTx, LastBlockID: state.LastBlockID, LastBlockTime: state.LastBlockTime, NextValidators: state.NextValidator...
go
func (state State) Copy() State { return State{ Version: state.Version, ChainID: state.ChainID, LastBlockHeight: state.LastBlockHeight, LastBlockTotalTx: state.LastBlockTotalTx, LastBlockID: state.LastBlockID, LastBlockTime: state.LastBlockTime, NextValidators: state.NextValidator...
[ "func", "(", "state", "State", ")", "Copy", "(", ")", "State", "{", "return", "State", "{", "Version", ":", "state", ".", "Version", ",", "ChainID", ":", "state", ".", "ChainID", ",", "LastBlockHeight", ":", "state", ".", "LastBlockHeight", ",", "LastBlo...
// Copy makes a copy of the State for mutating.
[ "Copy", "makes", "a", "copy", "of", "the", "State", "for", "mutating", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/state.go#L87-L109
131,461
tendermint/tendermint
state/state.go
Equals
func (state State) Equals(state2 State) bool { sbz, s2bz := state.Bytes(), state2.Bytes() return bytes.Equal(sbz, s2bz) }
go
func (state State) Equals(state2 State) bool { sbz, s2bz := state.Bytes(), state2.Bytes() return bytes.Equal(sbz, s2bz) }
[ "func", "(", "state", "State", ")", "Equals", "(", "state2", "State", ")", "bool", "{", "sbz", ",", "s2bz", ":=", "state", ".", "Bytes", "(", ")", ",", "state2", ".", "Bytes", "(", ")", "\n", "return", "bytes", ".", "Equal", "(", "sbz", ",", "s2b...
// Equals returns true if the States are identical.
[ "Equals", "returns", "true", "if", "the", "States", "are", "identical", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/state.go#L112-L115
131,462
tendermint/tendermint
state/state.go
MakeGenesisDocFromFile
func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error) { genDocJSON, err := ioutil.ReadFile(genDocFile) if err != nil { return nil, fmt.Errorf("Couldn't read GenesisDoc file: %v", err) } genDoc, err := types.GenesisDocFromJSON(genDocJSON) if err != nil { return nil, fmt.Errorf("Error reading...
go
func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error) { genDocJSON, err := ioutil.ReadFile(genDocFile) if err != nil { return nil, fmt.Errorf("Couldn't read GenesisDoc file: %v", err) } genDoc, err := types.GenesisDocFromJSON(genDocJSON) if err != nil { return nil, fmt.Errorf("Error reading...
[ "func", "MakeGenesisDocFromFile", "(", "genDocFile", "string", ")", "(", "*", "types", ".", "GenesisDoc", ",", "error", ")", "{", "genDocJSON", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "genDocFile", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// MakeGenesisDocFromFile reads and unmarshals genesis doc from the given file.
[ "MakeGenesisDocFromFile", "reads", "and", "unmarshals", "genesis", "doc", "from", "the", "given", "file", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/state.go#L200-L210
131,463
tendermint/tendermint
state/state.go
MakeGenesisState
func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { err := genDoc.ValidateAndComplete() if err != nil { return State{}, fmt.Errorf("Error in genesis file: %v", err) } var validatorSet, nextValidatorSet *types.ValidatorSet if genDoc.Validators == nil { validatorSet = types.NewValidatorSet(nil) n...
go
func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { err := genDoc.ValidateAndComplete() if err != nil { return State{}, fmt.Errorf("Error in genesis file: %v", err) } var validatorSet, nextValidatorSet *types.ValidatorSet if genDoc.Validators == nil { validatorSet = types.NewValidatorSet(nil) n...
[ "func", "MakeGenesisState", "(", "genDoc", "*", "types", ".", "GenesisDoc", ")", "(", "State", ",", "error", ")", "{", "err", ":=", "genDoc", ".", "ValidateAndComplete", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "State", "{", "}", ",", ...
// MakeGenesisState creates state from types.GenesisDoc.
[ "MakeGenesisState", "creates", "state", "from", "types", ".", "GenesisDoc", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/state.go#L213-L250
131,464
tendermint/tendermint
types/validation.go
ValidateHash
func ValidateHash(h []byte) error { if len(h) > 0 && len(h) != tmhash.Size { return fmt.Errorf("Expected size to be %d bytes, got %d bytes", tmhash.Size, len(h), ) } return nil }
go
func ValidateHash(h []byte) error { if len(h) > 0 && len(h) != tmhash.Size { return fmt.Errorf("Expected size to be %d bytes, got %d bytes", tmhash.Size, len(h), ) } return nil }
[ "func", "ValidateHash", "(", "h", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "h", ")", ">", "0", "&&", "len", "(", "h", ")", "!=", "tmhash", ".", "Size", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "tmhash", ".", "S...
// ValidateHash returns an error if the hash is not empty, but its // size != tmhash.Size.
[ "ValidateHash", "returns", "an", "error", "if", "the", "hash", "is", "not", "empty", "but", "its", "size", "!", "=", "tmhash", ".", "Size", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/validation.go#L32-L40
131,465
tendermint/tendermint
types/genesis.go
SaveAs
func (genDoc *GenesisDoc) SaveAs(file string) error { genDocBytes, err := cdc.MarshalJSONIndent(genDoc, "", " ") if err != nil { return err } return cmn.WriteFile(file, genDocBytes, 0644) }
go
func (genDoc *GenesisDoc) SaveAs(file string) error { genDocBytes, err := cdc.MarshalJSONIndent(genDoc, "", " ") if err != nil { return err } return cmn.WriteFile(file, genDocBytes, 0644) }
[ "func", "(", "genDoc", "*", "GenesisDoc", ")", "SaveAs", "(", "file", "string", ")", "error", "{", "genDocBytes", ",", "err", ":=", "cdc", ".", "MarshalJSONIndent", "(", "genDoc", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil",...
// SaveAs is a utility method for saving GenensisDoc as a JSON file.
[ "SaveAs", "is", "a", "utility", "method", "for", "saving", "GenensisDoc", "as", "a", "JSON", "file", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/genesis.go#L45-L51
131,466
tendermint/tendermint
types/genesis.go
ValidatorHash
func (genDoc *GenesisDoc) ValidatorHash() []byte { vals := make([]*Validator, len(genDoc.Validators)) for i, v := range genDoc.Validators { vals[i] = NewValidator(v.PubKey, v.Power) } vset := NewValidatorSet(vals) return vset.Hash() }
go
func (genDoc *GenesisDoc) ValidatorHash() []byte { vals := make([]*Validator, len(genDoc.Validators)) for i, v := range genDoc.Validators { vals[i] = NewValidator(v.PubKey, v.Power) } vset := NewValidatorSet(vals) return vset.Hash() }
[ "func", "(", "genDoc", "*", "GenesisDoc", ")", "ValidatorHash", "(", ")", "[", "]", "byte", "{", "vals", ":=", "make", "(", "[", "]", "*", "Validator", ",", "len", "(", "genDoc", ".", "Validators", ")", ")", "\n", "for", "i", ",", "v", ":=", "ran...
// ValidatorHash returns the hash of the validator set contained in the GenesisDoc
[ "ValidatorHash", "returns", "the", "hash", "of", "the", "validator", "set", "contained", "in", "the", "GenesisDoc" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/genesis.go#L54-L61
131,467
tendermint/tendermint
types/genesis.go
ValidateAndComplete
func (genDoc *GenesisDoc) ValidateAndComplete() error { if genDoc.ChainID == "" { return cmn.NewError("Genesis doc must include non-empty chain_id") } if len(genDoc.ChainID) > MaxChainIDLen { return cmn.NewError("chain_id in genesis doc is too long (max: %d)", MaxChainIDLen) } if genDoc.ConsensusParams == nil...
go
func (genDoc *GenesisDoc) ValidateAndComplete() error { if genDoc.ChainID == "" { return cmn.NewError("Genesis doc must include non-empty chain_id") } if len(genDoc.ChainID) > MaxChainIDLen { return cmn.NewError("chain_id in genesis doc is too long (max: %d)", MaxChainIDLen) } if genDoc.ConsensusParams == nil...
[ "func", "(", "genDoc", "*", "GenesisDoc", ")", "ValidateAndComplete", "(", ")", "error", "{", "if", "genDoc", ".", "ChainID", "==", "\"", "\"", "{", "return", "cmn", ".", "NewError", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "genDoc", ...
// ValidateAndComplete checks that all necessary fields are present // and fills in defaults for optional fields left empty
[ "ValidateAndComplete", "checks", "that", "all", "necessary", "fields", "are", "present", "and", "fills", "in", "defaults", "for", "optional", "fields", "left", "empty" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/genesis.go#L65-L98
131,468
tendermint/tendermint
types/genesis.go
GenesisDocFromFile
func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error) { jsonBlob, err := ioutil.ReadFile(genDocFile) if err != nil { return nil, cmn.ErrorWrap(err, "Couldn't read GenesisDoc file") } genDoc, err := GenesisDocFromJSON(jsonBlob) if err != nil { return nil, cmn.ErrorWrap(err, fmt.Sprintf("Error reading ...
go
func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error) { jsonBlob, err := ioutil.ReadFile(genDocFile) if err != nil { return nil, cmn.ErrorWrap(err, "Couldn't read GenesisDoc file") } genDoc, err := GenesisDocFromJSON(jsonBlob) if err != nil { return nil, cmn.ErrorWrap(err, fmt.Sprintf("Error reading ...
[ "func", "GenesisDocFromFile", "(", "genDocFile", "string", ")", "(", "*", "GenesisDoc", ",", "error", ")", "{", "jsonBlob", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "genDocFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// GenesisDocFromFile reads JSON data from a file and unmarshalls it into a GenesisDoc.
[ "GenesisDocFromFile", "reads", "JSON", "data", "from", "a", "file", "and", "unmarshalls", "it", "into", "a", "GenesisDoc", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/genesis.go#L119-L129
131,469
tendermint/tendermint
libs/common/bit_array.go
NewBitArray
func NewBitArray(bits int) *BitArray { if bits <= 0 { return nil } return &BitArray{ Bits: bits, Elems: make([]uint64, (bits+63)/64), } }
go
func NewBitArray(bits int) *BitArray { if bits <= 0 { return nil } return &BitArray{ Bits: bits, Elems: make([]uint64, (bits+63)/64), } }
[ "func", "NewBitArray", "(", "bits", "int", ")", "*", "BitArray", "{", "if", "bits", "<=", "0", "{", "return", "nil", "\n", "}", "\n", "return", "&", "BitArray", "{", "Bits", ":", "bits", ",", "Elems", ":", "make", "(", "[", "]", "uint64", ",", "(...
// NewBitArray returns a new bit array. // It returns nil if the number of bits is zero.
[ "NewBitArray", "returns", "a", "new", "bit", "array", ".", "It", "returns", "nil", "if", "the", "number", "of", "bits", "is", "zero", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L20-L28
131,470
tendermint/tendermint
libs/common/bit_array.go
GetIndex
func (bA *BitArray) GetIndex(i int) bool { if bA == nil { return false } bA.mtx.Lock() defer bA.mtx.Unlock() return bA.getIndex(i) }
go
func (bA *BitArray) GetIndex(i int) bool { if bA == nil { return false } bA.mtx.Lock() defer bA.mtx.Unlock() return bA.getIndex(i) }
[ "func", "(", "bA", "*", "BitArray", ")", "GetIndex", "(", "i", "int", ")", "bool", "{", "if", "bA", "==", "nil", "{", "return", "false", "\n", "}", "\n", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "bA", ".", "mtx", ".", "Unlock", ...
// GetIndex returns the bit at index i within the bit array. // The behavior is undefined if i >= bA.Bits
[ "GetIndex", "returns", "the", "bit", "at", "index", "i", "within", "the", "bit", "array", ".", "The", "behavior", "is", "undefined", "if", "i", ">", "=", "bA", ".", "Bits" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L40-L47
131,471
tendermint/tendermint
libs/common/bit_array.go
SetIndex
func (bA *BitArray) SetIndex(i int, v bool) bool { if bA == nil { return false } bA.mtx.Lock() defer bA.mtx.Unlock() return bA.setIndex(i, v) }
go
func (bA *BitArray) SetIndex(i int, v bool) bool { if bA == nil { return false } bA.mtx.Lock() defer bA.mtx.Unlock() return bA.setIndex(i, v) }
[ "func", "(", "bA", "*", "BitArray", ")", "SetIndex", "(", "i", "int", ",", "v", "bool", ")", "bool", "{", "if", "bA", "==", "nil", "{", "return", "false", "\n", "}", "\n", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "bA", ".", "mt...
// SetIndex sets the bit at index i within the bit array. // The behavior is undefined if i >= bA.Bits
[ "SetIndex", "sets", "the", "bit", "at", "index", "i", "within", "the", "bit", "array", ".", "The", "behavior", "is", "undefined", "if", "i", ">", "=", "bA", ".", "Bits" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L58-L65
131,472
tendermint/tendermint
libs/common/bit_array.go
Or
func (bA *BitArray) Or(o *BitArray) *BitArray { if bA == nil && o == nil { return nil } if bA == nil && o != nil { return o.Copy() } if o == nil { return bA.Copy() } bA.mtx.Lock() o.mtx.Lock() c := bA.copyBits(MaxInt(bA.Bits, o.Bits)) smaller := MinInt(len(bA.Elems), len(o.Elems)) for i := 0; i < small...
go
func (bA *BitArray) Or(o *BitArray) *BitArray { if bA == nil && o == nil { return nil } if bA == nil && o != nil { return o.Copy() } if o == nil { return bA.Copy() } bA.mtx.Lock() o.mtx.Lock() c := bA.copyBits(MaxInt(bA.Bits, o.Bits)) smaller := MinInt(len(bA.Elems), len(o.Elems)) for i := 0; i < small...
[ "func", "(", "bA", "*", "BitArray", ")", "Or", "(", "o", "*", "BitArray", ")", "*", "BitArray", "{", "if", "bA", "==", "nil", "&&", "o", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "bA", "==", "nil", "&&", "o", "!=", "nil", "{",...
// Or returns a bit array resulting from a bitwise OR of the two bit arrays. // If the two bit-arrys have different lengths, Or right-pads the smaller of the two bit-arrays with zeroes. // Thus the size of the return value is the maximum of the two provided bit arrays.
[ "Or", "returns", "a", "bit", "array", "resulting", "from", "a", "bitwise", "OR", "of", "the", "two", "bit", "arrays", ".", "If", "the", "two", "bit", "-", "arrys", "have", "different", "lengths", "Or", "right", "-", "pads", "the", "smaller", "of", "the...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L110-L130
131,473
tendermint/tendermint
libs/common/bit_array.go
And
func (bA *BitArray) And(o *BitArray) *BitArray { if bA == nil || o == nil { return nil } bA.mtx.Lock() o.mtx.Lock() defer func() { bA.mtx.Unlock() o.mtx.Unlock() }() return bA.and(o) }
go
func (bA *BitArray) And(o *BitArray) *BitArray { if bA == nil || o == nil { return nil } bA.mtx.Lock() o.mtx.Lock() defer func() { bA.mtx.Unlock() o.mtx.Unlock() }() return bA.and(o) }
[ "func", "(", "bA", "*", "BitArray", ")", "And", "(", "o", "*", "BitArray", ")", "*", "BitArray", "{", "if", "bA", "==", "nil", "||", "o", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "o", ...
// And returns a bit array resulting from a bitwise AND of the two bit arrays. // If the two bit-arrys have different lengths, this truncates the larger of the two bit-arrays from the right. // Thus the size of the return value is the minimum of the two provided bit arrays.
[ "And", "returns", "a", "bit", "array", "resulting", "from", "a", "bitwise", "AND", "of", "the", "two", "bit", "arrays", ".", "If", "the", "two", "bit", "-", "arrys", "have", "different", "lengths", "this", "truncates", "the", "larger", "of", "the", "two"...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L135-L146
131,474
tendermint/tendermint
libs/common/bit_array.go
Not
func (bA *BitArray) Not() *BitArray { if bA == nil { return nil // Degenerate } bA.mtx.Lock() defer bA.mtx.Unlock() return bA.not() }
go
func (bA *BitArray) Not() *BitArray { if bA == nil { return nil // Degenerate } bA.mtx.Lock() defer bA.mtx.Unlock() return bA.not() }
[ "func", "(", "bA", "*", "BitArray", ")", "Not", "(", ")", "*", "BitArray", "{", "if", "bA", "==", "nil", "{", "return", "nil", "// Degenerate", "\n", "}", "\n", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "bA", ".", "mtx", ".", "Unl...
// Not returns a bit array resulting from a bitwise Not of the provided bit array.
[ "Not", "returns", "a", "bit", "array", "resulting", "from", "a", "bitwise", "Not", "of", "the", "provided", "bit", "array", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L157-L164
131,475
tendermint/tendermint
libs/common/bit_array.go
IsEmpty
func (bA *BitArray) IsEmpty() bool { if bA == nil { return true // should this be opposite? } bA.mtx.Lock() defer bA.mtx.Unlock() for _, e := range bA.Elems { if e > 0 { return false } } return true }
go
func (bA *BitArray) IsEmpty() bool { if bA == nil { return true // should this be opposite? } bA.mtx.Lock() defer bA.mtx.Unlock() for _, e := range bA.Elems { if e > 0 { return false } } return true }
[ "func", "(", "bA", "*", "BitArray", ")", "IsEmpty", "(", ")", "bool", "{", "if", "bA", "==", "nil", "{", "return", "true", "// should this be opposite?", "\n", "}", "\n", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "bA", ".", "mtx", "."...
// IsEmpty returns true iff all bits in the bit array are 0
[ "IsEmpty", "returns", "true", "iff", "all", "bits", "in", "the", "bit", "array", "are", "0" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L202-L214
131,476
tendermint/tendermint
libs/common/bit_array.go
IsFull
func (bA *BitArray) IsFull() bool { if bA == nil { return true } bA.mtx.Lock() defer bA.mtx.Unlock() // Check all elements except the last for _, elem := range bA.Elems[:len(bA.Elems)-1] { if (^elem) != 0 { return false } } // Check that the last element has (lastElemBits) 1's lastElemBits := (bA.Bi...
go
func (bA *BitArray) IsFull() bool { if bA == nil { return true } bA.mtx.Lock() defer bA.mtx.Unlock() // Check all elements except the last for _, elem := range bA.Elems[:len(bA.Elems)-1] { if (^elem) != 0 { return false } } // Check that the last element has (lastElemBits) 1's lastElemBits := (bA.Bi...
[ "func", "(", "bA", "*", "BitArray", ")", "IsFull", "(", ")", "bool", "{", "if", "bA", "==", "nil", "{", "return", "true", "\n", "}", "\n", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "bA", ".", "mtx", ".", "Unlock", "(", ")", "\n\...
// IsFull returns true iff all bits in the bit array are 1.
[ "IsFull", "returns", "true", "iff", "all", "bits", "in", "the", "bit", "array", "are", "1", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L217-L235
131,477
tendermint/tendermint
libs/common/bit_array.go
PickRandom
func (bA *BitArray) PickRandom() (int, bool) { if bA == nil { return 0, false } bA.mtx.Lock() trueIndices := bA.getTrueIndices() bA.mtx.Unlock() if len(trueIndices) == 0 { // no bits set to true return 0, false } return trueIndices[RandIntn(len(trueIndices))], true }
go
func (bA *BitArray) PickRandom() (int, bool) { if bA == nil { return 0, false } bA.mtx.Lock() trueIndices := bA.getTrueIndices() bA.mtx.Unlock() if len(trueIndices) == 0 { // no bits set to true return 0, false } return trueIndices[RandIntn(len(trueIndices))], true }
[ "func", "(", "bA", "*", "BitArray", ")", "PickRandom", "(", ")", "(", "int", ",", "bool", ")", "{", "if", "bA", "==", "nil", "{", "return", "0", ",", "false", "\n", "}", "\n\n", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "trueIndices", ":="...
// PickRandom returns a random index for a set bit in the bit array. // If there is no such value, it returns 0, false. // It uses the global randomness in `random.go` to get this index.
[ "PickRandom", "returns", "a", "random", "index", "for", "a", "set", "bit", "in", "the", "bit", "array", ".", "If", "there", "is", "no", "such", "value", "it", "returns", "0", "false", ".", "It", "uses", "the", "global", "randomness", "in", "random", "....
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L240-L254
131,478
tendermint/tendermint
libs/common/bit_array.go
Bytes
func (bA *BitArray) Bytes() []byte { bA.mtx.Lock() defer bA.mtx.Unlock() numBytes := (bA.Bits + 7) / 8 bytes := make([]byte, numBytes) for i := 0; i < len(bA.Elems); i++ { elemBytes := [8]byte{} binary.LittleEndian.PutUint64(elemBytes[:], bA.Elems[i]) copy(bytes[i*8:], elemBytes[:]) } return bytes }
go
func (bA *BitArray) Bytes() []byte { bA.mtx.Lock() defer bA.mtx.Unlock() numBytes := (bA.Bits + 7) / 8 bytes := make([]byte, numBytes) for i := 0; i < len(bA.Elems); i++ { elemBytes := [8]byte{} binary.LittleEndian.PutUint64(elemBytes[:], bA.Elems[i]) copy(bytes[i*8:], elemBytes[:]) } return bytes }
[ "func", "(", "bA", "*", "BitArray", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "bA", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "numBytes", ":=", "(", "bA", ".", "Bits", "+", "7", ...
// Bytes returns the byte representation of the bits within the bitarray.
[ "Bytes", "returns", "the", "byte", "representation", "of", "the", "bits", "within", "the", "bitarray", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L334-L346
131,479
tendermint/tendermint
libs/common/bit_array.go
Update
func (bA *BitArray) Update(o *BitArray) { if bA == nil || o == nil { return } bA.mtx.Lock() o.mtx.Lock() defer func() { bA.mtx.Unlock() o.mtx.Unlock() }() copy(bA.Elems, o.Elems) }
go
func (bA *BitArray) Update(o *BitArray) { if bA == nil || o == nil { return } bA.mtx.Lock() o.mtx.Lock() defer func() { bA.mtx.Unlock() o.mtx.Unlock() }() copy(bA.Elems, o.Elems) }
[ "func", "(", "bA", "*", "BitArray", ")", "Update", "(", "o", "*", "BitArray", ")", "{", "if", "bA", "==", "nil", "||", "o", "==", "nil", "{", "return", "\n", "}", "\n", "bA", ".", "mtx", ".", "Lock", "(", ")", "\n", "o", ".", "mtx", ".", "L...
// Update sets the bA's bits to be that of the other bit array. // The copying begins from the begin of both bit arrays.
[ "Update", "sets", "the", "bA", "s", "bits", "to", "be", "that", "of", "the", "other", "bit", "array", ".", "The", "copying", "begins", "from", "the", "begin", "of", "both", "bit", "arrays", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/bit_array.go#L350-L362
131,480
tendermint/tendermint
state/txindex/indexer.go
NewBatch
func NewBatch(n int64) *Batch { return &Batch{ Ops: make([]*types.TxResult, n), } }
go
func NewBatch(n int64) *Batch { return &Batch{ Ops: make([]*types.TxResult, n), } }
[ "func", "NewBatch", "(", "n", "int64", ")", "*", "Batch", "{", "return", "&", "Batch", "{", "Ops", ":", "make", "(", "[", "]", "*", "types", ".", "TxResult", ",", "n", ")", ",", "}", "\n", "}" ]
// NewBatch creates a new Batch.
[ "NewBatch", "creates", "a", "new", "Batch", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/txindex/indexer.go#L37-L41
131,481
tendermint/tendermint
state/txindex/indexer.go
Add
func (b *Batch) Add(result *types.TxResult) error { b.Ops[result.Index] = result return nil }
go
func (b *Batch) Add(result *types.TxResult) error { b.Ops[result.Index] = result return nil }
[ "func", "(", "b", "*", "Batch", ")", "Add", "(", "result", "*", "types", ".", "TxResult", ")", "error", "{", "b", ".", "Ops", "[", "result", ".", "Index", "]", "=", "result", "\n", "return", "nil", "\n", "}" ]
// Add or update an entry for the given result.Index.
[ "Add", "or", "update", "an", "entry", "for", "the", "given", "result", ".", "Index", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/state/txindex/indexer.go#L44-L47
131,482
tendermint/tendermint
libs/db/mem_db.go
newMemDBIterator
func newMemDBIterator(db DB, keys []string, start, end []byte) *memDBIterator { return &memDBIterator{ db: db, cur: 0, keys: keys, start: start, end: end, } }
go
func newMemDBIterator(db DB, keys []string, start, end []byte) *memDBIterator { return &memDBIterator{ db: db, cur: 0, keys: keys, start: start, end: end, } }
[ "func", "newMemDBIterator", "(", "db", "DB", ",", "keys", "[", "]", "string", ",", "start", ",", "end", "[", "]", "byte", ")", "*", "memDBIterator", "{", "return", "&", "memDBIterator", "{", "db", ":", "db", ",", "cur", ":", "0", ",", "keys", ":", ...
// Keys is expected to be in reverse order for reverse iterators.
[ "Keys", "is", "expected", "to", "be", "in", "reverse", "order", "for", "reverse", "iterators", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/mem_db.go#L183-L191
131,483
tendermint/tendermint
p2p/netaddress.go
IDAddressString
func IDAddressString(id ID, protocolHostPort string) string { hostPort := removeProtocolIfDefined(protocolHostPort) return fmt.Sprintf("%s@%s", id, hostPort) }
go
func IDAddressString(id ID, protocolHostPort string) string { hostPort := removeProtocolIfDefined(protocolHostPort) return fmt.Sprintf("%s@%s", id, hostPort) }
[ "func", "IDAddressString", "(", "id", "ID", ",", "protocolHostPort", "string", ")", "string", "{", "hostPort", ":=", "removeProtocolIfDefined", "(", "protocolHostPort", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ",", "hostPort", ...
// IDAddressString returns id@hostPort. It strips the leading // protocol from protocolHostPort if it exists.
[ "IDAddressString", "returns", "id" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L37-L40
131,484
tendermint/tendermint
p2p/netaddress.go
NewNetAddressString
func NewNetAddressString(addr string) (*NetAddress, error) { spl := strings.Split(addr, "@") if len(spl) < 2 { return nil, ErrNetAddressNoID{addr} } return NewNetAddressStringWithOptionalID(addr) }
go
func NewNetAddressString(addr string) (*NetAddress, error) { spl := strings.Split(addr, "@") if len(spl) < 2 { return nil, ErrNetAddressNoID{addr} } return NewNetAddressStringWithOptionalID(addr) }
[ "func", "NewNetAddressString", "(", "addr", "string", ")", "(", "*", "NetAddress", ",", "error", ")", "{", "spl", ":=", "strings", ".", "Split", "(", "addr", ",", "\"", "\"", ")", "\n", "if", "len", "(", "spl", ")", "<", "2", "{", "return", "nil", ...
// NewNetAddressString returns a new NetAddress using the provided address in // the form of "ID@IP:Port". // Also resolves the host if host is not an IP. // Errors are of type ErrNetAddressXxx where Xxx is in (NoID, Invalid, Lookup)
[ "NewNetAddressString", "returns", "a", "new", "NetAddress", "using", "the", "provided", "address", "in", "the", "form", "of", "ID" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L69-L75
131,485
tendermint/tendermint
p2p/netaddress.go
NewNetAddressStringWithOptionalID
func NewNetAddressStringWithOptionalID(addr string) (*NetAddress, error) { addrWithoutProtocol := removeProtocolIfDefined(addr) var id ID spl := strings.Split(addrWithoutProtocol, "@") if len(spl) == 2 { idStr := spl[0] idBytes, err := hex.DecodeString(idStr) if err != nil { return nil, ErrNetAddressInval...
go
func NewNetAddressStringWithOptionalID(addr string) (*NetAddress, error) { addrWithoutProtocol := removeProtocolIfDefined(addr) var id ID spl := strings.Split(addrWithoutProtocol, "@") if len(spl) == 2 { idStr := spl[0] idBytes, err := hex.DecodeString(idStr) if err != nil { return nil, ErrNetAddressInval...
[ "func", "NewNetAddressStringWithOptionalID", "(", "addr", "string", ")", "(", "*", "NetAddress", ",", "error", ")", "{", "addrWithoutProtocol", ":=", "removeProtocolIfDefined", "(", "addr", ")", "\n\n", "var", "id", "ID", "\n", "spl", ":=", "strings", ".", "Sp...
// NewNetAddressStringWithOptionalID returns a new NetAddress using the // provided address in the form of "ID@IP:Port", where the ID is optional. // Also resolves the host if host is not an IP.
[ "NewNetAddressStringWithOptionalID", "returns", "a", "new", "NetAddress", "using", "the", "provided", "address", "in", "the", "form", "of", "ID" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L80-L127
131,486
tendermint/tendermint
p2p/netaddress.go
NewNetAddressStrings
func NewNetAddressStrings(addrs []string) ([]*NetAddress, []error) { netAddrs := make([]*NetAddress, 0) errs := make([]error, 0) for _, addr := range addrs { netAddr, err := NewNetAddressString(addr) if err != nil { errs = append(errs, err) } else { netAddrs = append(netAddrs, netAddr) } } return net...
go
func NewNetAddressStrings(addrs []string) ([]*NetAddress, []error) { netAddrs := make([]*NetAddress, 0) errs := make([]error, 0) for _, addr := range addrs { netAddr, err := NewNetAddressString(addr) if err != nil { errs = append(errs, err) } else { netAddrs = append(netAddrs, netAddr) } } return net...
[ "func", "NewNetAddressStrings", "(", "addrs", "[", "]", "string", ")", "(", "[", "]", "*", "NetAddress", ",", "[", "]", "error", ")", "{", "netAddrs", ":=", "make", "(", "[", "]", "*", "NetAddress", ",", "0", ")", "\n", "errs", ":=", "make", "(", ...
// NewNetAddressStrings returns an array of NetAddress'es build using // the provided strings.
[ "NewNetAddressStrings", "returns", "an", "array", "of", "NetAddress", "es", "build", "using", "the", "provided", "strings", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L131-L143
131,487
tendermint/tendermint
p2p/netaddress.go
NewNetAddressIPPort
func NewNetAddressIPPort(ip net.IP, port uint16) *NetAddress { return &NetAddress{ IP: ip, Port: port, } }
go
func NewNetAddressIPPort(ip net.IP, port uint16) *NetAddress { return &NetAddress{ IP: ip, Port: port, } }
[ "func", "NewNetAddressIPPort", "(", "ip", "net", ".", "IP", ",", "port", "uint16", ")", "*", "NetAddress", "{", "return", "&", "NetAddress", "{", "IP", ":", "ip", ",", "Port", ":", "port", ",", "}", "\n", "}" ]
// NewNetAddressIPPort returns a new NetAddress using the provided IP // and port number.
[ "NewNetAddressIPPort", "returns", "a", "new", "NetAddress", "using", "the", "provided", "IP", "and", "port", "number", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L147-L152
131,488
tendermint/tendermint
p2p/netaddress.go
Same
func (na *NetAddress) Same(other interface{}) bool { if o, ok := other.(*NetAddress); ok { if na.DialString() == o.DialString() { return true } if na.ID != "" && na.ID == o.ID { return true } } return false }
go
func (na *NetAddress) Same(other interface{}) bool { if o, ok := other.(*NetAddress); ok { if na.DialString() == o.DialString() { return true } if na.ID != "" && na.ID == o.ID { return true } } return false }
[ "func", "(", "na", "*", "NetAddress", ")", "Same", "(", "other", "interface", "{", "}", ")", "bool", "{", "if", "o", ",", "ok", ":=", "other", ".", "(", "*", "NetAddress", ")", ";", "ok", "{", "if", "na", ".", "DialString", "(", ")", "==", "o",...
// Same returns true is na has the same non-empty ID or DialString as other.
[ "Same", "returns", "true", "is", "na", "has", "the", "same", "non", "-", "empty", "ID", "or", "DialString", "as", "other", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L164-L174
131,489
tendermint/tendermint
p2p/netaddress.go
DialTimeout
func (na *NetAddress) DialTimeout(timeout time.Duration) (net.Conn, error) { conn, err := net.DialTimeout("tcp", na.DialString(), timeout) if err != nil { return nil, err } return conn, nil }
go
func (na *NetAddress) DialTimeout(timeout time.Duration) (net.Conn, error) { conn, err := net.DialTimeout("tcp", na.DialString(), timeout) if err != nil { return nil, err } return conn, nil }
[ "func", "(", "na", "*", "NetAddress", ")", "DialTimeout", "(", "timeout", "time", ".", "Duration", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "conn", ",", "err", ":=", "net", ".", "DialTimeout", "(", "\"", "\"", ",", "na", ".", "DialStri...
// DialTimeout calls net.DialTimeout on the address.
[ "DialTimeout", "calls", "net", ".", "DialTimeout", "on", "the", "address", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L211-L217
131,490
tendermint/tendermint
p2p/netaddress.go
Routable
func (na *NetAddress) Routable() bool { // TODO(oga) bitcoind doesn't include RFC3849 here, but should we? return na.Valid() && !(na.RFC1918() || na.RFC3927() || na.RFC4862() || na.RFC4193() || na.RFC4843() || na.Local()) }
go
func (na *NetAddress) Routable() bool { // TODO(oga) bitcoind doesn't include RFC3849 here, but should we? return na.Valid() && !(na.RFC1918() || na.RFC3927() || na.RFC4862() || na.RFC4193() || na.RFC4843() || na.Local()) }
[ "func", "(", "na", "*", "NetAddress", ")", "Routable", "(", ")", "bool", "{", "// TODO(oga) bitcoind doesn't include RFC3849 here, but should we?", "return", "na", ".", "Valid", "(", ")", "&&", "!", "(", "na", ".", "RFC1918", "(", ")", "||", "na", ".", "RFC3...
// Routable returns true if the address is routable.
[ "Routable", "returns", "true", "if", "the", "address", "is", "routable", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L220-L224
131,491
tendermint/tendermint
p2p/netaddress.go
Valid
func (na *NetAddress) Valid() bool { if string(na.ID) != "" { data, err := hex.DecodeString(string(na.ID)) if err != nil || len(data) != IDByteLength { return false } } return na.IP != nil && !(na.IP.IsUnspecified() || na.RFC3849() || na.IP.Equal(net.IPv4bcast)) }
go
func (na *NetAddress) Valid() bool { if string(na.ID) != "" { data, err := hex.DecodeString(string(na.ID)) if err != nil || len(data) != IDByteLength { return false } } return na.IP != nil && !(na.IP.IsUnspecified() || na.RFC3849() || na.IP.Equal(net.IPv4bcast)) }
[ "func", "(", "na", "*", "NetAddress", ")", "Valid", "(", ")", "bool", "{", "if", "string", "(", "na", ".", "ID", ")", "!=", "\"", "\"", "{", "data", ",", "err", ":=", "hex", ".", "DecodeString", "(", "string", "(", "na", ".", "ID", ")", ")", ...
// For IPv4 these are either a 0 or all bits set address. For IPv6 a zero // address or one that matches the RFC3849 documentation address format.
[ "For", "IPv4", "these", "are", "either", "a", "0", "or", "all", "bits", "set", "address", ".", "For", "IPv6", "a", "zero", "address", "or", "one", "that", "matches", "the", "RFC3849", "documentation", "address", "format", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L228-L237
131,492
tendermint/tendermint
p2p/netaddress.go
Local
func (na *NetAddress) Local() bool { return na.IP.IsLoopback() || zero4.Contains(na.IP) }
go
func (na *NetAddress) Local() bool { return na.IP.IsLoopback() || zero4.Contains(na.IP) }
[ "func", "(", "na", "*", "NetAddress", ")", "Local", "(", ")", "bool", "{", "return", "na", ".", "IP", ".", "IsLoopback", "(", ")", "||", "zero4", ".", "Contains", "(", "na", ".", "IP", ")", "\n", "}" ]
// Local returns true if it is a local address.
[ "Local", "returns", "true", "if", "it", "is", "a", "local", "address", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/netaddress.go#L246-L248
131,493
tendermint/tendermint
privval/signer_service_endpoint.go
SignerServiceEndpointTimeoutReadWrite
func SignerServiceEndpointTimeoutReadWrite(timeout time.Duration) SignerServiceEndpointOption { return func(ss *SignerServiceEndpoint) { ss.timeoutReadWrite = timeout } }
go
func SignerServiceEndpointTimeoutReadWrite(timeout time.Duration) SignerServiceEndpointOption { return func(ss *SignerServiceEndpoint) { ss.timeoutReadWrite = timeout } }
[ "func", "SignerServiceEndpointTimeoutReadWrite", "(", "timeout", "time", ".", "Duration", ")", "SignerServiceEndpointOption", "{", "return", "func", "(", "ss", "*", "SignerServiceEndpoint", ")", "{", "ss", ".", "timeoutReadWrite", "=", "timeout", "}", "\n", "}" ]
// SignerServiceEndpointTimeoutReadWrite sets the read and write timeout for connections // from external signing processes.
[ "SignerServiceEndpointTimeoutReadWrite", "sets", "the", "read", "and", "write", "timeout", "for", "connections", "from", "external", "signing", "processes", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/signer_service_endpoint.go#L18-L20
131,494
tendermint/tendermint
privval/signer_service_endpoint.go
NewSignerServiceEndpoint
func NewSignerServiceEndpoint( logger log.Logger, chainID string, privVal types.PrivValidator, dialer SocketDialer, ) *SignerServiceEndpoint { se := &SignerServiceEndpoint{ chainID: chainID, timeoutReadWrite: time.Second * defaultTimeoutReadWriteSeconds, connRetries: defaultMaxDialRetries, pr...
go
func NewSignerServiceEndpoint( logger log.Logger, chainID string, privVal types.PrivValidator, dialer SocketDialer, ) *SignerServiceEndpoint { se := &SignerServiceEndpoint{ chainID: chainID, timeoutReadWrite: time.Second * defaultTimeoutReadWriteSeconds, connRetries: defaultMaxDialRetries, pr...
[ "func", "NewSignerServiceEndpoint", "(", "logger", "log", ".", "Logger", ",", "chainID", "string", ",", "privVal", "types", ".", "PrivValidator", ",", "dialer", "SocketDialer", ",", ")", "*", "SignerServiceEndpoint", "{", "se", ":=", "&", "SignerServiceEndpoint", ...
// NewSignerServiceEndpoint returns a SignerServiceEndpoint that will dial using the given // dialer and respond to any signature requests over the connection // using the given privVal.
[ "NewSignerServiceEndpoint", "returns", "a", "SignerServiceEndpoint", "that", "will", "dial", "using", "the", "given", "dialer", "and", "respond", "to", "any", "signature", "requests", "over", "the", "connection", "using", "the", "given", "privVal", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/privval/signer_service_endpoint.go#L44-L60
131,495
tendermint/tendermint
consensus/types/round_state.go
String
func (rs RoundStepType) String() string { switch rs { case RoundStepNewHeight: return "RoundStepNewHeight" case RoundStepNewRound: return "RoundStepNewRound" case RoundStepPropose: return "RoundStepPropose" case RoundStepPrevote: return "RoundStepPrevote" case RoundStepPrevoteWait: return "RoundStepPrev...
go
func (rs RoundStepType) String() string { switch rs { case RoundStepNewHeight: return "RoundStepNewHeight" case RoundStepNewRound: return "RoundStepNewRound" case RoundStepPropose: return "RoundStepPropose" case RoundStepPrevote: return "RoundStepPrevote" case RoundStepPrevoteWait: return "RoundStepPrev...
[ "func", "(", "rs", "RoundStepType", ")", "String", "(", ")", "string", "{", "switch", "rs", "{", "case", "RoundStepNewHeight", ":", "return", "\"", "\"", "\n", "case", "RoundStepNewRound", ":", "return", "\"", "\"", "\n", "case", "RoundStepPropose", ":", "...
// String returns a string
[ "String", "returns", "a", "string" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/round_state.go#L39-L60
131,496
tendermint/tendermint
consensus/types/round_state.go
RoundStateSimple
func (rs *RoundState) RoundStateSimple() RoundStateSimple { votesJSON, err := rs.Votes.MarshalJSON() if err != nil { panic(err) } return RoundStateSimple{ HeightRoundStep: fmt.Sprintf("%d/%d/%d", rs.Height, rs.Round, rs.Step), StartTime: rs.StartTime, ProposalBlockHash: rs.ProposalBlock.Hash(), ...
go
func (rs *RoundState) RoundStateSimple() RoundStateSimple { votesJSON, err := rs.Votes.MarshalJSON() if err != nil { panic(err) } return RoundStateSimple{ HeightRoundStep: fmt.Sprintf("%d/%d/%d", rs.Height, rs.Round, rs.Step), StartTime: rs.StartTime, ProposalBlockHash: rs.ProposalBlock.Hash(), ...
[ "func", "(", "rs", "*", "RoundState", ")", "RoundStateSimple", "(", ")", "RoundStateSimple", "{", "votesJSON", ",", "err", ":=", "rs", ".", "Votes", ".", "MarshalJSON", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}...
// Compress the RoundState to RoundStateSimple
[ "Compress", "the", "RoundState", "to", "RoundStateSimple" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/round_state.go#L101-L114
131,497
tendermint/tendermint
consensus/types/round_state.go
NewRoundEvent
func (rs *RoundState) NewRoundEvent() types.EventDataNewRound { addr := rs.Validators.GetProposer().Address idx, _ := rs.Validators.GetByAddress(addr) return types.EventDataNewRound{ Height: rs.Height, Round: rs.Round, Step: rs.Step.String(), Proposer: types.ValidatorInfo{ Address: addr, Index: i...
go
func (rs *RoundState) NewRoundEvent() types.EventDataNewRound { addr := rs.Validators.GetProposer().Address idx, _ := rs.Validators.GetByAddress(addr) return types.EventDataNewRound{ Height: rs.Height, Round: rs.Round, Step: rs.Step.String(), Proposer: types.ValidatorInfo{ Address: addr, Index: i...
[ "func", "(", "rs", "*", "RoundState", ")", "NewRoundEvent", "(", ")", "types", ".", "EventDataNewRound", "{", "addr", ":=", "rs", ".", "Validators", ".", "GetProposer", "(", ")", ".", "Address", "\n", "idx", ",", "_", ":=", "rs", ".", "Validators", "."...
// NewRoundEvent returns the RoundState with proposer information as an event.
[ "NewRoundEvent", "returns", "the", "RoundState", "with", "proposer", "information", "as", "an", "event", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/round_state.go#L117-L130
131,498
tendermint/tendermint
consensus/types/round_state.go
CompleteProposalEvent
func (rs *RoundState) CompleteProposalEvent() types.EventDataCompleteProposal { // We must construct BlockID from ProposalBlock and ProposalBlockParts // cs.Proposal is not guaranteed to be set when this function is called blockId := types.BlockID{ Hash: rs.ProposalBlock.Hash(), PartsHeader: rs.ProposalBl...
go
func (rs *RoundState) CompleteProposalEvent() types.EventDataCompleteProposal { // We must construct BlockID from ProposalBlock and ProposalBlockParts // cs.Proposal is not guaranteed to be set when this function is called blockId := types.BlockID{ Hash: rs.ProposalBlock.Hash(), PartsHeader: rs.ProposalBl...
[ "func", "(", "rs", "*", "RoundState", ")", "CompleteProposalEvent", "(", ")", "types", ".", "EventDataCompleteProposal", "{", "// We must construct BlockID from ProposalBlock and ProposalBlockParts", "// cs.Proposal is not guaranteed to be set when this function is called", "blockId", ...
// CompleteProposalEvent returns information about a proposed block as an event.
[ "CompleteProposalEvent", "returns", "information", "about", "a", "proposed", "block", "as", "an", "event", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/round_state.go#L133-L147
131,499
tendermint/tendermint
consensus/types/round_state.go
StringIndented
func (rs *RoundState) StringIndented(indent string) string { return fmt.Sprintf(`RoundState{ %s H:%v R:%v S:%v %s StartTime: %v %s CommitTime: %v %s Validators: %v %s Proposal: %v %s ProposalBlock: %v %v %s LockedRound: %v %s LockedBlock: %v %v %s ValidRound: %v %s ValidBlock: %v %v %s...
go
func (rs *RoundState) StringIndented(indent string) string { return fmt.Sprintf(`RoundState{ %s H:%v R:%v S:%v %s StartTime: %v %s CommitTime: %v %s Validators: %v %s Proposal: %v %s ProposalBlock: %v %v %s LockedRound: %v %s LockedBlock: %v %v %s ValidRound: %v %s ValidBlock: %v %v %s...
[ "func", "(", "rs", "*", "RoundState", ")", "StringIndented", "(", "indent", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "`RoundState{\n%s H:%v R:%v S:%v\n%s StartTime: %v\n%s CommitTime: %v\n%s Validators: %v\n%s Proposal: %v\n%s Propo...
// StringIndented returns a string
[ "StringIndented", "returns", "a", "string" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/types/round_state.go#L164-L194