Skip to content

protolambda/go-eth2-peerstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-eth2-peerstore

go get github.com/protolambda/go-eth2-peerstore

This extends the Libp2p peerstore, adding:

  • Address conversion utils in addrutil
  • Eth2 Status, Metadata (with seqnr handling) support, building on ZRNT types
  • Eth2 ENR support
  • Interface to access the libp2p Identify info (default libp2p does not expose it)
  • List function to get a collection of detailed info of a peer, to not have to query all separate peerstore components.
  • Everything can be persisted, with the same datastore abstraction as the native libp2p peerstore uses.
  • Peerstore tee: sync any changes made to the libp2p keystore with an external source. Logging and CSV tee types included as examples.

Getting started

import (
    "fmt"
    ds "github.com/ipfs/go-datastore"
    "github.com/ipfs/go-datastore/sync"
    "github.com/libp2p/go-libp2p-peerstore/pstoreds"
    "github.com/protolambda/go-eth2-peerstore/dstrack"
)

func main() {
    store := sync.MutexWrap(ds.NewMapDatastore())  // or your favorite persisted libp2p datastore (Leveldb, badger, etc.)
    peerstore, err := dstrack.NewExtendedPeerstore(context.Background(), store, pstoreds.DefaultOpts())
    if err != nil {
        panic(err)
    }
    data, err := peerstore.GetAllData("peerid.....")
    if err != nil {
        panic(err)
    }
    fmt.Println(data)
}

License

MIT. See LICENSE file.

About

Eth2 peerstore for Go libp2p

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages