go fmt
This commit is contained in:
parent
8e044be7c2
commit
ac25502308
@ -30,7 +30,7 @@ type BlockSync struct {
|
|||||||
// FIXME: We should have a reduced interface here, initialized
|
// FIXME: We should have a reduced interface here, initialized
|
||||||
// just with our protocol ID, we shouldn't be able to open *any*
|
// just with our protocol ID, we shouldn't be able to open *any*
|
||||||
// connection.
|
// connection.
|
||||||
host host.Host
|
host host.Host
|
||||||
|
|
||||||
peerTracker *bsPeerTracker
|
peerTracker *bsPeerTracker
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ func (client *BlockSync) processResponse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check `TipSet`s are connected (valid chain).
|
// Check `TipSet`s are connected (valid chain).
|
||||||
for i := 0; i < len(validRes.tipsets) - 1; i++ {
|
for i := 0; i < len(validRes.tipsets)-1; i++ {
|
||||||
if validRes.tipsets[i].IsChildOf(validRes.tipsets[i+1]) == false {
|
if validRes.tipsets[i].IsChildOf(validRes.tipsets[i+1]) == false {
|
||||||
return nil, fmt.Errorf("tipsets are not connected at height (head - %d)/(head - %d)",
|
return nil, fmt.Errorf("tipsets are not connected at height (head - %d)/(head - %d)",
|
||||||
i, i+1)
|
i, i+1)
|
||||||
@ -305,7 +305,7 @@ func (client *BlockSync) GetChainMessages(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
head *types.TipSet,
|
head *types.TipSet,
|
||||||
length uint64,
|
length uint64,
|
||||||
) ([]*CompactedMessages, error) {
|
) ([]*CompactedMessages, error) {
|
||||||
ctx, span := trace.StartSpan(ctx, "GetChainMessages")
|
ctx, span := trace.StartSpan(ctx, "GetChainMessages")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package blocksync
|
package blocksync
|
||||||
|
|
||||||
// FIXME: This needs to be reviewed.
|
// FIXME: This needs to be reviewed.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -29,7 +29,7 @@ var MaxRequestLength = uint64(build.ForkLengthThreshold)
|
|||||||
const SUCCESS_PEER_TAG_VALUE = 25
|
const SUCCESS_PEER_TAG_VALUE = 25
|
||||||
const WRITE_REQ_DEADLINE = 5 * time.Second
|
const WRITE_REQ_DEADLINE = 5 * time.Second
|
||||||
const READ_RES_DEADLINE = WRITE_REQ_DEADLINE
|
const READ_RES_DEADLINE = WRITE_REQ_DEADLINE
|
||||||
const READ_RES_MIN_SPEED = 50<<10
|
const READ_RES_MIN_SPEED = 50 << 10
|
||||||
const SHUFFLE_PEERS_PREFIX = 5
|
const SHUFFLE_PEERS_PREFIX = 5
|
||||||
const WRITE_RES_DEADLINE = 60 * time.Second
|
const WRITE_RES_DEADLINE = 60 * time.Second
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ func parseOptions(optfield uint64) *parsedOptions {
|
|||||||
|
|
||||||
// FIXME: Rename. Make private.
|
// FIXME: Rename. Make private.
|
||||||
type Response struct {
|
type Response struct {
|
||||||
Status status
|
Status status
|
||||||
// String that complements the error status when converting to an
|
// String that complements the error status when converting to an
|
||||||
// internal error (see `statusToError()`).
|
// internal error (see `statusToError()`).
|
||||||
ErrorMessage string
|
ErrorMessage string
|
||||||
@ -92,6 +92,7 @@ type Response struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type status uint64
|
type status uint64
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Ok status = 0
|
Ok status = 0
|
||||||
// We could not fetch all blocks requested (but at least we returned
|
// We could not fetch all blocks requested (but at least we returned
|
||||||
@ -127,8 +128,8 @@ func (res *Response) statusToError() error {
|
|||||||
|
|
||||||
// FIXME: Rename.
|
// FIXME: Rename.
|
||||||
type BSTipSet struct {
|
type BSTipSet struct {
|
||||||
Blocks []*types.BlockHeader
|
Blocks []*types.BlockHeader
|
||||||
Messages *CompactedMessages
|
Messages *CompactedMessages
|
||||||
}
|
}
|
||||||
|
|
||||||
// All messages of a single tipset compacted together instead
|
// All messages of a single tipset compacted together instead
|
||||||
@ -144,17 +145,17 @@ type BSTipSet struct {
|
|||||||
// FIXME: The logic to decompress this structure should belong
|
// FIXME: The logic to decompress this structure should belong
|
||||||
// to itself, not to the consumer.
|
// to itself, not to the consumer.
|
||||||
type CompactedMessages struct {
|
type CompactedMessages struct {
|
||||||
Bls []*types.Message
|
Bls []*types.Message
|
||||||
BlsIncludes [][]uint64
|
BlsIncludes [][]uint64
|
||||||
|
|
||||||
Secpk []*types.SignedMessage
|
Secpk []*types.SignedMessage
|
||||||
SecpkIncludes [][]uint64
|
SecpkIncludes [][]uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Response that has been validated according to the protocol
|
// Response that has been validated according to the protocol
|
||||||
// and can be safely accessed.
|
// and can be safely accessed.
|
||||||
type validatedResponse struct {
|
type validatedResponse struct {
|
||||||
tipsets []*types.TipSet
|
tipsets []*types.TipSet
|
||||||
// List of all messages per tipset (grouped by tipset,
|
// List of all messages per tipset (grouped by tipset,
|
||||||
// not by block, hence a single index like `tipsets`).
|
// not by block, hence a single index like `tipsets`).
|
||||||
messages []*CompactedMessages
|
messages []*CompactedMessages
|
||||||
@ -162,7 +163,7 @@ type validatedResponse struct {
|
|||||||
|
|
||||||
// Decompress messages and form full tipsets with them. The headers
|
// Decompress messages and form full tipsets with them. The headers
|
||||||
// need to have been requested as well.
|
// need to have been requested as well.
|
||||||
func (res *validatedResponse) toFullTipSets() ([]*store.FullTipSet) {
|
func (res *validatedResponse) toFullTipSets() []*store.FullTipSet {
|
||||||
if len(res.tipsets) == 0 || len(res.tipsets) != len(res.messages) {
|
if len(res.tipsets) == 0 || len(res.tipsets) != len(res.messages) {
|
||||||
// This decompression can only be done if both headers and
|
// This decompression can only be done if both headers and
|
||||||
// messages are returned in the response. (The second check
|
// messages are returned in the response. (The second check
|
||||||
|
@ -18,7 +18,6 @@ import (
|
|||||||
inet "github.com/libp2p/go-libp2p-core/network"
|
inet "github.com/libp2p/go-libp2p-core/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// BlockSyncService is the component that services BlockSync requests from
|
// BlockSyncService is the component that services BlockSync requests from
|
||||||
// peers.
|
// peers.
|
||||||
//
|
//
|
||||||
@ -101,7 +100,7 @@ func (server *BlockSyncService) processRequest(
|
|||||||
func validateRequest(
|
func validateRequest(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *Request,
|
req *Request,
|
||||||
) ( *validatedRequest, *Response) {
|
) (*validatedRequest, *Response) {
|
||||||
_, span := trace.StartSpan(ctx, "blocksync.ValidateRequest")
|
_, span := trace.StartSpan(ctx, "blocksync.ValidateRequest")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -118,7 +117,7 @@ func validateRequest(
|
|||||||
validReq.length = req.Length
|
validReq.length = req.Length
|
||||||
if validReq.length > MaxRequestLength {
|
if validReq.length > MaxRequestLength {
|
||||||
return nil, &Response{
|
return nil, &Response{
|
||||||
Status: BadRequest,
|
Status: BadRequest,
|
||||||
ErrorMessage: fmt.Sprintf("request length over maximum allowed (%d)",
|
ErrorMessage: fmt.Sprintf("request length over maximum allowed (%d)",
|
||||||
MaxRequestLength),
|
MaxRequestLength),
|
||||||
}
|
}
|
||||||
@ -151,7 +150,7 @@ func validateRequest(
|
|||||||
func (server *BlockSyncService) serviceRequest(
|
func (server *BlockSyncService) serviceRequest(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *validatedRequest,
|
req *validatedRequest,
|
||||||
) (*Response, error) {
|
) (*Response, error) {
|
||||||
_, span := trace.StartSpan(ctx, "blocksync.ServiceRequest")
|
_, span := trace.StartSpan(ctx, "blocksync.ServiceRequest")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -178,7 +177,7 @@ func (server *BlockSyncService) serviceRequest(
|
|||||||
func collectChainSegment(
|
func collectChainSegment(
|
||||||
cs *store.ChainStore,
|
cs *store.ChainStore,
|
||||||
req *validatedRequest,
|
req *validatedRequest,
|
||||||
) ([]*BSTipSet, error) {
|
) ([]*BSTipSet, error) {
|
||||||
var bstips []*BSTipSet
|
var bstips []*BSTipSet
|
||||||
|
|
||||||
cur := req.head
|
cur := req.head
|
||||||
|
Loading…
Reference in New Issue
Block a user