store

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BanInboundPeer

func BanInboundPeer(db *leveldb.DB, ip string, duration time.Duration) error

func BanInboundPeerTx

func BanInboundPeerTx(tx *leveldb.Transaction, ip string, duration time.Duration) error

func BanName

func BanName(tx *leveldb.Transaction, name string) error

func BanOutboundPeer

func BanOutboundPeer(db *leveldb.DB, ip string, duration time.Duration) error

func BanOutboundPeerTx

func BanOutboundPeerTx(tx *leveldb.Transaction, ip string, duration time.Duration) error

func GetHeaderCount

func GetHeaderCount(db *leveldb.DB) (int, error)

func GetInitialImportComplete

func GetInitialImportComplete(db *leveldb.DB) (bool, error)

func GetLastBanListImportAt

func GetLastBanListImportAt(db *leveldb.DB) (time.Time, error)

func GetLastNameImportHeight

func GetLastNameImportHeight(db *leveldb.DB) (int, error)

func GetMerkleBase

func GetMerkleBase(db *leveldb.DB, name string) (blob.MerkleBase, error)

func IncrementHeaderCount

func IncrementHeaderCount(tx *leveldb.Transaction) error

func IsBanned

func IsBanned(db *leveldb.DB, ip string) (bool, bool, error)

func NameIsBanned

func NameIsBanned(db *leveldb.DB, name string) (bool, error)

func Open

func Open(path string) (*leveldb.DB, error)

func Prefixer

func Prefixer(prefix string) func(k ...string) []byte

func SetHeaderTx

func SetHeaderTx(tx *leveldb.Transaction, header *Header, merkleBase blob.MerkleBase) error

func SetInitialImportCompleteTx

func SetInitialImportCompleteTx(tx *leveldb.Transaction) error

func SetLastBanListImportAt

func SetLastBanListImportAt(tx *leveldb.Transaction, t time.Time) error

func SetLastNameImportHeightTx

func SetLastNameImportHeightTx(tx *leveldb.Transaction, height int) error

func SetNameInfoTx

func SetNameInfoTx(tx *leveldb.Transaction, name string, key *btcec.PublicKey, height int) error

func SetPeer

func SetPeer(db *leveldb.DB, id crypto.Hash, ip string, verify bool) error

func SetPeerTx

func SetPeerTx(batch *leveldb.Transaction, id crypto.Hash, ip string, verify bool) error

func TruncateBannedNames

func TruncateBannedNames(tx *leveldb.Transaction) error

func TruncateHeaderStore

func TruncateHeaderStore(db *leveldb.DB) error

func TruncateNameStore

func TruncateNameStore(db *leveldb.DB) error

func TruncatePeerStore

func TruncatePeerStore(db *leveldb.DB) error

func UnbanInboundPeerTx

func UnbanInboundPeerTx(tx *leveldb.Transaction, ip string) error

func UnbanOutboundPeerTx

func UnbanOutboundPeerTx(tx *leveldb.Transaction, ip string) error

func UnwhitelistPeerTx added in v0.2.1

func UnwhitelistPeerTx(tx *leveldb.Transaction, ip string) error

func WhitelistPeerTx added in v0.2.1

func WhitelistPeerTx(tx *leveldb.Transaction, ip string) error

func WithTx

func WithTx(db *leveldb.DB, cb TxCb) error

Types

type BlobInfo

type BlobInfo struct {
	Name         string           `json:"name"`
	PublicKey    *btcec.PublicKey `json:"public_key"`
	ImportHeight int              `json:"import_height"`
	Timestamp    time.Time        `json:"timestamp"`
	MerkleRoot   crypto.Hash      `json:"merkle_root"`
	Signature    crypto.Signature `json:"signature"`
	ReservedRoot crypto.Hash      `json:"reserved_root"`
	ReceivedAt   time.Time        `json:"received_at"`
	Timebank     int              `json:"timebank"`
}

func (*BlobInfo) MarshalJSON

func (b *BlobInfo) MarshalJSON() ([]byte, error)

type BlobInfoStream

type BlobInfoStream struct {
	// contains filtered or unexported fields
}

func StreamBlobInfo

func StreamBlobInfo(db *leveldb.DB, start string) (*BlobInfoStream, error)

func (*BlobInfoStream) Close

func (bis *BlobInfoStream) Close() error

func (*BlobInfoStream) Next

func (bis *BlobInfoStream) Next() (*BlobInfo, error)
type Header struct {
	Name         string
	Timestamp    time.Time
	MerkleRoot   crypto.Hash
	Signature    crypto.Signature
	ReservedRoot crypto.Hash
	ReceivedAt   time.Time
	Timebank     int
}

func GetHeader

func GetHeader(db *leveldb.DB, name string) (*Header, error)

func (*Header) MarshalJSON

func (h *Header) MarshalJSON() ([]byte, error)

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(b []byte) error

type NameInfo

type NameInfo struct {
	Name         string
	PublicKey    *btcec.PublicKey
	ImportHeight int
}

func GetNameInfo

func GetNameInfo(db *leveldb.DB, name string) (*NameInfo, error)

func (*NameInfo) MarshalJSON

func (n *NameInfo) MarshalJSON() ([]byte, error)

func (*NameInfo) UnmarshalJSON

func (n *NameInfo) UnmarshalJSON(data []byte) error

type NameInfoStream

type NameInfoStream struct {
	// contains filtered or unexported fields
}

func StreamNameInfo

func StreamNameInfo(db *leveldb.DB, start string) (*NameInfoStream, error)

func (*NameInfoStream) Close

func (nis *NameInfoStream) Close() error

func (*NameInfoStream) Next

func (nis *NameInfoStream) Next() (*NameInfo, error)

type Peer

type Peer struct {
	ID                  crypto.Hash
	IP                  string
	LastSeen            time.Time
	Verify              bool
	InboundBannedUntil  time.Time
	OutboundBannedUntil time.Time
	Whitelisted         bool
}

func (*Peer) IsBanned

func (p *Peer) IsBanned() bool

func (*Peer) MarshalJSON

func (p *Peer) MarshalJSON() ([]byte, error)

func (*Peer) UnmarshalJSON

func (p *Peer) UnmarshalJSON(b []byte) error

type PeerStream

type PeerStream struct {
	// contains filtered or unexported fields
}

func StreamPeers

func StreamPeers(db *leveldb.DB, includeBanned bool) (*PeerStream, error)

func (*PeerStream) Close

func (ps *PeerStream) Close() error

func (*PeerStream) Next

func (ps *PeerStream) Next() (*Peer, error)

type TxCb

type TxCb func(tx *leveldb.Transaction) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL