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:
parent
ee5d8acb05
commit
60dc4e764c
|
@ -12,3 +12,4 @@ vendor/*
|
||||||
NimBinaries
|
NimBinaries
|
||||||
.update.timestamp
|
.update.timestamp
|
||||||
*.dSYM
|
*.dSYM
|
||||||
|
*.vscode/*
|
||||||
|
|
|
@ -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?
|
||||||
|
|
|
@ -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) =
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue