* remove TODO for PeerConnected and PeerDisconnected from Notifiee
This is now done via the event bus.
* remove OpenedStream and ClosedStream from Notifiee
* feat: harden encoding/decoding functions against panics
Part of https://github.com/libp2p/go-libp2p/issues/1389
These kinds of functions:
1. Handle user input.
2. Often have out-of-bounds, null pointer, etc bugs.
3. Have completely isolated logic where local panics are unlikely to
cause memory corruption elsewhere.
* test: add a panic catcher test
The mappings in go-cid were maintained by hand and are invalid.
More details in https://github.com/ipfs/go-cid/pull/137
This is switching to go-multicodec which has correct mappings
that are generated, not written by hand.
Co-authored-by: Daniel Martí <mvdan@mvdan.cc>
* add resource manager interfaces
* add scope accessors to streams and conns
* add ResourceManager accessor to the Network interface
* allow initially unattached streams.
* introduce service scopes, canonicalize ownership interface through setters
* make system scope explicit
* make memory stat an int64
* make the system scope a generic resource scope, introduce the DMZ
* fix typo
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* fix typo
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* rename DMZ to transient scope, remove OpenConnection from PeerScope
* remove ncopy param from GrowBuffer
* remove protocols from OpenStream
The stream is unnegotiated state until the actual protocol has been determined.
* document nil receiver contract, fix protocol scope protocol accessor method
* remove nil receiver contract requirement
* flesh out stat struct
* turn resource manager scope accessors into viewers
* interface refiniments
1. Introduce transactions in all scopes
2. Limit the view of stream/connection scope for users, to avoid the Done footgun
3. Move OpenStream to the resource manager
* add Buffer interface
* fix typo
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* fix typo
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* fix typo
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* rename user scopes to plain names, management scopes as such
* rename BeginTxn to BeginTransaction
* RIP Buffers
* make ErrResourceLimitExceeded a temporary error; move rcmgr errors with the other errors.
* unexport TemporaryError
* null resource manager stub
* unexport the null stubs, make entry point a variable
* don't rely on typed nils but instead use actual null object instances
So that we don't confuse the hell out of everyone!
* add Scope to the CapableConn interface
* rename ConnectionScope to ConnScope for consistency
* fix typo
* rename ConnectionManagementScope to ConnManagementScope
* add the ConnManagementScope to Upgrader.Upgrade
* fix argument name
* godocs for ResourceManager
* introduce MemoryStatus indicator in ReserveMemory
* use uint8 for MemoryStatus
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* rework reservation interface to pass priority instead of returning memory status
so that we don't have to undo reservations if there is too much pressure.
* improve comment
* fix typo
* export the NullScope
* Stream.SetProtocol can return an error
It needs to attach the protocol to the protocol scope, which may fail.
* merge the mux package into network
* pass the PeerScope to Multiplexer.NetConn
* Update network/rcmgr.go
Co-authored-by: raulk <raul@protocol.ai>
* Update network/rcmgr.go
Co-authored-by: raulk <raul@protocol.ai>
* Update network/rcmgr.go
Co-authored-by: raulk <raul@protocol.ai>
* Update network/rcmgr.go
Co-authored-by: Adin Schmahmann <adin.schmahmann@gmail.com>
* remove reference to deprecated mux.MuxedConn
* rename transaction to span
* indicate bytes in ReserveMemory
* break ResourceManager View methods into Viewer interface.
* add experimental interface warning
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
Co-authored-by: raulk <raul@protocol.ai>
Co-authored-by: Adin Schmahmann <adin.schmahmann@gmail.com>
* bump go.mod to Go 1.16 and run go fix
* run go mod tidy
* run gofmt -s
* update .github/workflows/automerge.yml
* update .github/workflows/go-test.yml
* update .github/workflows/go-check.yml
Co-authored-by: web3-bot <web3-bot@users.noreply.github.com>
There's really no reason to expire these after 10 minutes as opposed to
30. Given that our default DHT refresh interval is 10 minutes, setting
this to 30 reduces the chances that we'll "forget" peers.
Specifically, move them _here_ from the peerstore. That way
packages (like the DHT) that currently directly rely on the peerstore,
can just use go-libp2p-core.
Moved from f7f22569f7/peerstore.go (L79-L93)
With some small modifications.
* fix: make timestamps strictly increasing
On Linux, this is almost always the case. Windows, however, doesn't have
nanosecond accuracy.
We make the timestamp sequence numbers strictly increasing by returning
the last timestamp + 1 where necessary.
* apply code review
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* use a lock
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* disable Travis
* set Go version to 1.15 and run go mod tidy
* add .github/workflows/automerge.yml
* add .github/workflows/go-test.yml
* add .github/workflows/go-check.yml
* chore: tidy submodule
* chore: give vet something to vet
* test: disable timing dependent bandwidth test unless we're on linux
Co-authored-by: web3-bot <web3-bot@users.noreply.github.com>
Co-authored-by: Steven Allen <steven@stebalien.com>
* run go mod tidy
* omit receiver name if unused
* remove unused type testkey in tests
* fix duplicate import of go-multiaddr
* fix use of deprecated peer.IDB58{Encode,Decode}
* use bytes.Equal instead of bytes.Compare
* fix unnecessary assigments to blank identifier
* use time.Until instead of t.Sub(time.Now())
* fix use of deprecated go-multihash.ID
* add missing error check in envelope test
* fix error check in tests