cors

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: GPL-3.0, GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

This file is part of go-palletone.
go-palletone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-palletone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-palletone.  If not, see <http://www.gnu.org/licenses/>.

* @author PalletOne core developer Jiyou Wang <dev@pallet.one> * @date 2018

This file is part of go-palletone.
go-palletone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-palletone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-palletone.  If not, see <http://www.gnu.org/licenses/>.

* @author PalletOne core developer Jiyou Wang <dev@pallet.one> * @date 2018

This file is part of go-palletone.
go-palletone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-palletone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-palletone.  If not, see <http://www.gnu.org/licenses/>.

* @author PalletOne core developer Jiyou Wang <dev@pallet.one> * @date 2018

This file is part of go-palletone.
go-palletone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-palletone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-palletone.  If not, see <http://www.gnu.org/licenses/>.

* @author PalletOne core developer Jiyou Wang <dev@pallet.one> * @date 2018

This file is part of go-palletone.
go-palletone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-palletone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-palletone.  If not, see <http://www.gnu.org/licenses/>.

* @author PalletOne core developer Jiyou Wang <dev@pallet.one> * @date 2018

This file is part of go-palletone.
go-palletone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-palletone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-palletone.  If not, see <http://www.gnu.org/licenses/>.

* @author PalletOne core developer Jiyou Wang <dev@pallet.one> * @date 2018

Index

Constants

View Source
const (
	NetworkId          = 10
	ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
)
View Source
const (
	// Protocol messages belonging to Cors1
	StatusMsg           = 0x00
	CorsHeaderMsg       = 0x01
	CorsHeadersMsg      = 0x02
	GetCurrentHeaderMsg = 0x03
	CurrentHeaderMsg    = 0x04
	GetBlockHeadersMsg  = 0x05
	BlockHeadersMsg     = 0x06
)

cors protocol message codes

View Source
const (
	ErrMsgTooLarge = iota
	ErrDecode
	ErrInvalidMsgCode
	ErrProtocolVersionMismatch
	ErrNetworkIdMismatch
	ErrGenesisBlockMismatch
	ErrNoStatusMsg
	ErrExtraStatusMsg
	ErrSuspendedPeer
	ErrUselessPeer
	ErrRequestRejected
	ErrUnexpectedResponse
	ErrInvalidResponse
	ErrTooManyTimeouts
	ErrMissingKey
)
View Source
const (
	MaxHeaderFetch = 192 // Amount of block headers to be fetched per retrieval request

)

Variables

View Source
var (
	ClientProtocolVersions = []uint{cors}
	ServerProtocolVersions = []uint{cors}
)
View Source
var ProtocolLengths = map[uint]uint64{/* contains filtered or unexported fields */}

Functions

This section is empty.

Types

type CorsServer

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

func NewCoresServer

func NewCoresServer(ptn *ptn.PalletOne, config *ptn.Config) (*CorsServer, error)

func (*CorsServer) CorsProtocols

func (s *CorsServer) CorsProtocols() []p2p.Protocol

func (*CorsServer) Protocols

func (s *CorsServer) Protocols() []p2p.Protocol

func (*CorsServer) SendEvents

func (s *CorsServer) SendEvents(header *modules.Header)

func (*CorsServer) Start

func (s *CorsServer) Start(srvr *p2p.Server, corss *p2p.Server, syncCh chan bool)

Start starts the Cors server

func (*CorsServer) StartCorsSync

func (s *CorsServer) StartCorsSync() (string, error)

func (*CorsServer) Stop

func (s *CorsServer) Stop()

Stop stops the LES service

func (*CorsServer) SubscribeCeEvent

func (s *CorsServer) SubscribeCeEvent(ch chan<- *modules.Header) event.Subscription

type LightFetcher

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

Fetcher is responsible for accumulating block announcements from various peers and scheduling them for retrieval.

func NewLightFetcher

func NewLightFetcher(getHeaderByHash headerRetrievalFn, lightChainHeight lightChainHeightFn,
	verifyHeader headerVerifierFn, broadcastHeader headerBroadcasterFn, insertHeader headerInsertFn,
	dropPeer peerDropFn) *LightFetcher

New creates a block fetcher to retrieve blocks based on hash announcements.

func (*LightFetcher) Enqueue

func (f *LightFetcher) Enqueue(p *peer, header *modules.Header) error

Enqueue tries to fill gaps the the fetcher's future import queue.

func (*LightFetcher) Start

func (f *LightFetcher) Start()

Start boots up the announcement based synchroniser, accepting and processing hash notifications and block fetches until termination requested.

func (*LightFetcher) Stop

func (f *LightFetcher) Stop()

Stop terminates the announcement based synchroniser, canceling all pending operations.

type NodeInfo

type NodeInfo struct {
	Network uint64      `json:"network"` // Palletone network ID (1=Frontier, 2=Morden, Ropsten=3, Rinkeby=4)
	Index   uint64      `json:"number"`  // Total difficulty of the host's blockchain
	Head    common.Hash `json:"head"`    // SHA3 hash of the host's best owned block
	Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block

}

NodeInfo represents a short summary of the Palletone sub-protocol metadata known about the host peer.

type ProtocolManager

type ProtocolManager struct {
	SubProtocols []p2p.Protocol
	// contains filtered or unexported fields
}

func NewCorsProtocolManager

func NewCorsProtocolManager(lightSync bool, networkId uint64, gasToken modules.AssetId,
	dag dag.IDag, mux *event.TypeMux, genesis *modules.Unit, quitSync chan struct{}) (*ProtocolManager, error)

NewProtocolManager returns a new ethereum sub protocol manager. The Palletone sub protocol manages peers capable with the ethereum network.

func (*ProtocolManager) AddCorsPeer

func (pm *ProtocolManager) AddCorsPeer(url string) (bool, error)

func (*ProtocolManager) BlockHeadersMsg

func (pm *ProtocolManager) BlockHeadersMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) BroadcastCorsHeader

func (pm *ProtocolManager) BroadcastCorsHeader(p *peer, header *modules.Header)

func (*ProtocolManager) CorsHeaderMsg

func (pm *ProtocolManager) CorsHeaderMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) CorsHeadersMsg

func (pm *ProtocolManager) CorsHeadersMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) CurrentHeaderMsg

func (pm *ProtocolManager) CurrentHeaderMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) GetBlockHeadersMsg

func (pm *ProtocolManager) GetBlockHeadersMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) GetCurrentHeaderMsg

func (pm *ProtocolManager) GetCurrentHeaderMsg(msg p2p.Msg, p *peer) error

func (*ProtocolManager) NodeInfo

func (pm *ProtocolManager) NodeInfo(genesisHash common.Hash) *NodeInfo

NodeInfo retrieves some protocol metadata about the running host node.

func (*ProtocolManager) PullSync

func (pm *ProtocolManager) PullSync()

func (*ProtocolManager) PushSync

func (pm *ProtocolManager) PushSync()

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

func (*ProtocolManager) StartCorsSync

func (pm *ProtocolManager) StartCorsSync() (string, error)

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

Jump to

Keyboard shortcuts

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