Update go.mod module line, all require/replace directives, and every .go import path from forge.lthn.ai/core/go-blockchain to dappco.re/go/core/blockchain. Add replace directives to bridge dappco.re paths to existing forge.lthn.ai registry during migration. Update CLAUDE.md, README, and docs to reflect the new module path. Co-Authored-By: Virgil <virgil@lethean.io>
35 lines
851 B
Go
35 lines
851 B
Go
// Copyright (c) 2017-2026 Lethean (https://lt.hn)
|
|
//
|
|
// Licensed under the European Union Public Licence (EUPL) version 1.2.
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
package p2p
|
|
|
|
import "dappco.re/go/core/p2p/node/levin"
|
|
|
|
// EncodePingRequest returns an encoded empty ping request payload.
|
|
func EncodePingRequest() ([]byte, error) {
|
|
return levin.EncodeStorage(levin.Section{})
|
|
}
|
|
|
|
// DecodePingResponse parses a ping response payload.
|
|
func DecodePingResponse(data []byte) (status string, peerID uint64, err error) {
|
|
s, err := levin.DecodeStorage(data)
|
|
if err != nil {
|
|
return "", 0, err
|
|
}
|
|
if v, ok := s["status"]; ok {
|
|
blob, e := v.AsString()
|
|
if e != nil {
|
|
return "", 0, e
|
|
}
|
|
status = string(blob)
|
|
}
|
|
if v, ok := s["peer_id"]; ok {
|
|
peerID, err = v.AsUint64()
|
|
if err != nil {
|
|
return "", 0, err
|
|
}
|
|
}
|
|
return status, peerID, nil
|
|
}
|