Fix changes from stint (#81)

* some formatting tweaks to make errors easier to grok

* stint removed overloads for regular ints - use stew versions instead

* various name style fixes

* ignore vscode stuff

* revert style changes

* revert unneeded var rename changes

---------

Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
This commit is contained in:
Jaremy Creechley 2023-11-17 12:08:45 -07:00 committed by GitHub
parent ee5d8acb05
commit 60dc4e764c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 5 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ vendor/*
NimBinaries NimBinaries
.update.timestamp .update.timestamp
*.dSYM *.dSYM
*.vscode/*

View File

@ -15,6 +15,7 @@
import import
std/[hashes, net, options, sugar, tables], std/[hashes, net, options, sugar, tables],
stew/endians2,
bearssl/rand, bearssl/rand,
chronicles, chronicles,
stew/[results, byteutils], stew/[results, byteutils],
@ -200,7 +201,7 @@ proc hasHandshake*(c: Codec, key: HandshakeKey): bool =
proc encodeStaticHeader*(flag: Flag, nonce: AESGCMNonce, authSize: int): proc encodeStaticHeader*(flag: Flag, nonce: AESGCMNonce, authSize: int):
seq[byte] = seq[byte] =
result.add(protocolId) result.add(protocolId)
result.add(version.toBytesBE()) result.add(endians2.toBytesBE(version))
result.add(byte(flag)) result.add(byte(flag))
result.add(nonce) result.add(nonce)
# TODO: assert on authSize of > 2^16? # TODO: assert on authSize of > 2^16?

View File

@ -11,6 +11,7 @@
import import
std/net, std/net,
chronicles, chronicles,
stew/endians2,
libp2p/routing_record, libp2p/routing_record,
libp2p/signed_envelope, libp2p/signed_envelope,
"."/[messages, spr, node], "."/[messages, spr, node],
@ -98,7 +99,7 @@ proc getField*(pb: ProtoBuffer, field: int,
if not(res): if not(res):
ok(false) ok(false)
else: else:
family = uint8.fromBytesBE(buffer).IpAddressFamily family = endians2.fromBytesBE(uint8, buffer).IpAddressFamily
ok(true) ok(true)
proc write*(pb: var ProtoBuffer, field: int, family: IpAddressFamily) = proc write*(pb: var ProtoBuffer, field: int, family: IpAddressFamily) =

View File

@ -369,7 +369,7 @@ proc handleTalkReq(d: Protocol, fromId: NodeId, fromAddr: Address,
proc addProviderLocal(p: Protocol, cId: NodeId, prov: SignedPeerRecord) {.async.} = proc addProviderLocal(p: Protocol, cId: NodeId, prov: SignedPeerRecord) {.async.} =
trace "adding provider to local db", n = p.localNode, cId, prov trace "adding provider to local db", n = p.localNode, cId, prov
if (let res = (await p.providers.add(cid, prov)); res.isErr): if (let res = (await p.providers.add(cId, prov)); res.isErr):
trace "Unable to add provider", cid, peerId = prov.data.peerId trace "Unable to add provider", cid, peerId = prov.data.peerId
proc handleAddProvider( proc handleAddProvider(

View File

@ -10,6 +10,7 @@
import std/options import std/options
import std/sequtils import std/sequtils
import pkg/stew/endians2
import pkg/chronos import pkg/chronos
import pkg/libp2p import pkg/libp2p
import pkg/datastore import pkg/datastore

View File

@ -8,6 +8,7 @@
import std/sequtils import std/sequtils
import std/strutils import std/strutils
import pkg/stew/endians2
import pkg/datastore import pkg/datastore
import pkg/chronos import pkg/chronos
import pkg/libp2p import pkg/libp2p
@ -79,7 +80,7 @@ proc add*(
else: else:
Moment.fromNow(self.ttl) - ZeroMoment Moment.fromNow(self.ttl) - ZeroMoment
ttl = expires.microseconds.uint64.toBytesBE ttl = endians2.toBytesBE(expires.microseconds.uint64)
bytes: seq[byte] = bytes: seq[byte] =
if existing =? (await self.getProvByKey(provKey)) and if existing =? (await self.getProvByKey(provKey)) and

View File

@ -59,7 +59,7 @@ proc bootstrapNetwork(
#waitFor bootNode.bootstrap() # immediate, since no bootnodes are defined above #waitFor bootNode.bootstrap() # immediate, since no bootnodes are defined above
var res = await bootstrapNodes(nodecount - 1, var res = await bootstrapNodes(nodecount - 1,
@[bootnode.localNode.record], @[bootNode.localNode.record],
rng, rng,
delay) delay)
res.insert((bootNode, bootNodeKey), 0) res.insert((bootNode, bootNodeKey), 0)