Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sku4 committed Aug 12, 2023
0 parents commit 050bf21
Show file tree
Hide file tree
Showing 103 changed files with 16,580 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Editors + git
.idea
.git

# Dependency directories (remove the comment below to include it)
vendor/
data/
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: ci-cd

on:
push:
branches: [ master ]

jobs:
ad:
uses: sku4/ad-run/.github/workflows/ad.yml@master
secrets: inherit
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Editors
.idea

# Binaries for programs and plugins
.bin
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
db
*.out
*.db
*.lock
*.har
.env

# Dependency directories (remove the comment below to include it)
vendor/
data/

# Go workspace file
go.work

# Project
.database
26 changes: 26 additions & 0 deletions .rocks/ad-tnt-scm-3.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package = "ad-tnt"
version = "scm-3"
source = {
url = "git+ssh://git@github.com:sku4/ad-tnt.git",
}
description = {
homepage = "https://github.com/sku4/ad-tnt",
license = "Proprietary",
}
dependencies = {
"kit scm-2",
"config scm-5",
"package-reload scm-1",
"spacer scm-3",
"moonwalker scm-1",
"net-graphite",
"ctx",
"queue scm-1",
"xqueue scm-5",
-- "crud scm-1",
}
build = {
type = "builtin",
modules = {
}
}
6 changes: 6 additions & 0 deletions .rocks/config-5.1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rocks_servers = {
"http://moonlibs.github.io/rocks", -- moonlibs libs
"http://rocks.tarantool.org/", -- tarantool libs
"http://luarocks.org/repositories/rocks", -- luarocks
"https://rocks.moonscript.org",
}
91 changes: 91 additions & 0 deletions .rocks/share/tarantool/base58.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
local ffi = require 'ffi'
-- local uuid = require 'uuid'

local libpath = package.search and package.search('libbase58')
or assert(package.searchpath('libbase58', package.cpath))
local lib = ffi.load(libpath, true)
local GENBUF = 256

local genbuf = ffi.new('char[?]',GENBUF)
local sz = ffi.new('size_t [1]');

ffi.cdef[[
bool encode_base58(const char *data, size_t binsz, char *b58, size_t *b58sz);
bool decode_base58(const char *b58, size_t b58sz, void *bin, size_t *binszp);
char * strerror(int errnum);
]]

local function encode_base58( input )
local newsize = math.floor(#input*3/2)+1
-- print("newsize = ",newsize)
local out
if newsize > GENBUF then
out = ffi.new('char[?]',newsize)
sz[0] = newsize
else
out = genbuf
sz[0] = GENBUF
end
-- local sz =
-- sz[0] = ffi.sizeof(out)

if lib.encode_base58(input, #input, out, sz) then
if sz[0] > 0 then
return ffi.string(out, sz[0])
else
return ""
end
else
error("Failed to encode", 2)
end
end

local function decode_base58( input )
local newsize = math.floor(#input*4/3+1)
-- print("newsize = ",newsize)
local out
if newsize > GENBUF then
out = ffi.new('char[?]',newsize)
sz[0] = newsize
else
out = genbuf
sz[0] = GENBUF
end
if lib.decode_base58(input, #input, out, sz) then
if sz[0] > 0 then
return ffi.string(out+ffi.sizeof(out)-sz[0], sz[0])
else
return ""
end
else
error("Failed to decode: "..ffi.string(ffi.C.strerror(ffi.errno())), 2)
end
end

-- print("e = ", encode_base58("09"))
-- print("d = ", decode_base58("4ER"))
-- print("e/d = ",encode_base58(decode_base58("4ER")))

local function hex2bin(str)
return (string.gsub(str, '..', function (cc) return string.char(tonumber(cc, 16)) end))
end
local function bin2hex(str)
return (string.gsub(str, '.', function (c) return string.format('%02x', string.byte(c)) end))
end

-- local v = "nsEZ97iJrza4gy3mk9AS55"
-- -- local v = "nsss"
-- print(v)
-- print(bin2hex(decode_base58(v)))
-- print( encode_base58(decode_base58(v)) )
-- print( "min", encode_base58("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") )
-- print( "max", encode_base58("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff") )
-- print( "min", #decode_base58( encode_base58("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")) )
-- print( "max", #decode_base58( encode_base58("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff")) )
-- -- error("X")

return {
encode = encode_base58;
decode = decode_base58;
}

Loading

0 comments on commit 050bf21

Please sign in to comment.