Skip to content
39 changes: 39 additions & 0 deletions common/messaging/messaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

accountspb "github.com/JupiterMetaLabs/JMDN-FastSync/common/proto/accounts"
datasyncpb "github.com/JupiterMetaLabs/JMDN-FastSync/common/proto/datasync"
headersyncpb "github.com/JupiterMetaLabs/JMDN-FastSync/common/proto/headersync"
potspb "github.com/JupiterMetaLabs/JMDN-FastSync/common/proto/pots"
priorsyncpb "github.com/JupiterMetaLabs/JMDN-FastSync/common/proto/priorsync"
"github.com/JupiterMetaLabs/JMDN-FastSync/common/types/constants"
Expand Down Expand Up @@ -461,6 +462,44 @@ func SendDataSyncProtoDelimitedWithHeartbeat(
)
}

// SendHeaderSyncProtoDelimitedWithHeartbeat is a heartbeat-aware variant of SendProtoDelimited,
// designed for the HeaderSync protocol. Fetching large header batches from the server's DB
// can exceed the 15s stream deadline; heartbeat frames reset the read deadline on each tick.
func SendHeaderSyncProtoDelimitedWithHeartbeat(
ctx context.Context,
version uint16,
host host.Host,
peerInfo peer.AddrInfo,
protocolID protocol.ID,
request proto.Message,
response *headersyncpb.HeaderSyncResponse,
) error {
if response == nil {
return errors.New("response message is nil")
}
return sendProtoDelimitedWithHeartbeatGeneric(ctx, version, host, peerInfo, protocolID, request,
streamConfig[*headersyncpb.HeaderSyncStreamMessage]{
newEnvelope: func() *headersyncpb.HeaderSyncStreamMessage {
return &headersyncpb.HeaderSyncStreamMessage{}
},
isHeartbeat: func(e *headersyncpb.HeaderSyncStreamMessage) bool {
_, ok := e.Payload.(*headersyncpb.HeaderSyncStreamMessage_Heartbeat)
return ok
},
mergeResponse: func(e *headersyncpb.HeaderSyncStreamMessage) error {
p, ok := e.Payload.(*headersyncpb.HeaderSyncStreamMessage_Response)
if !ok {
return fmt.Errorf("unexpected HeaderSyncStreamMessage payload type: %T", e.Payload)
}
if p.Response != nil {
proto.Merge(response, p.Response)
}
return nil
},
},
)
}

// SendPoTSProtoDelimitedWithHeartbeat is a heartbeat-aware variant of SendProtoDelimited,
// designed for the PoTS (Proof of Time Sync) protocol.
func SendPoTSProtoDelimitedWithHeartbeat(
Expand Down
17 changes: 13 additions & 4 deletions common/proto/availability/availability.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/proto/availability/availability.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ message AvailabilityResponse {
uint32 block_merge = 3;
auth.Auth auth = 4;
phase.Phase phase = 5;
uint64 block_height = 6;
}
184 changes: 162 additions & 22 deletions common/proto/headersync/headersync.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions common/proto/headersync/headersync.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,15 @@ message HeaderSyncResponse {
uint32 version = 2;
ack.Ack ack = 3;
phase.Phase phase = 4;
}

message HeaderSyncHeartbeat {
int64 timestamp = 1;
}

message HeaderSyncStreamMessage {
oneof payload {
HeaderSyncHeartbeat heartbeat = 1;
HeaderSyncResponse response = 2;
}
}
4 changes: 2 additions & 2 deletions common/types/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const (
)

const (
AUTH_TTL = 2 * time.Minute
AUTH_TTL = 48 * time.Hour
)

const (
Expand All @@ -67,7 +67,7 @@ const (
MAX_DATA_PER_REQUEST = 30
MIN_BLOCKS = 500 // if number of blocks in the client is less than 500 then do the full sync.
MAX_PARALLEL_REQUESTS = 10
ATMOST_ACCOUNT_ROUTINES = 15
ATMOST_ACCOUNT_ROUTINES = 3
LRU_CACHE_CAPACITY = 200
)

Expand Down
Loading
Loading