-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate network parts from mesh protocol parts
Separate the networking logic from the mesh protocol logic by splitting the old TankaClient into two parts. MeshConn handles connections to both tatanka nodes and peers. Mesh handles the client mesh protocol. Mesh has its own database. That is where things like order info and bonds will be stored.
- Loading branch information
Showing
13 changed files
with
1,353 additions
and
962 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// This code is available on the terms of the project LICENSE.md file, | ||
// also available online at https://blueoakcouncil.org/license/1.0.0. | ||
|
||
package lexi | ||
|
||
import ( | ||
"encoding" | ||
"encoding/json" | ||
) | ||
|
||
// lexiJSON is just a wrapper for something that is JSON-encodable. | ||
type lexiJSON struct { | ||
thing any | ||
} | ||
|
||
type BinaryMarshal interface { | ||
encoding.BinaryMarshaler | ||
encoding.BinaryUnmarshaler | ||
} | ||
|
||
// JSON can be used to encode JSON-encodable things. | ||
func JSON(thing any) BinaryMarshal { | ||
return &lexiJSON{thing} | ||
} | ||
|
||
// UnJSON can be used in index entry generator functions for some syntactic | ||
// sugar. | ||
func UnJSON(thing any) interface{} { | ||
if lj, is := thing.(*lexiJSON); is { | ||
return lj.thing | ||
} | ||
return struct{}{} | ||
} | ||
|
||
func (p *lexiJSON) MarshalBinary() ([]byte, error) { | ||
return json.Marshal(p.thing) | ||
} | ||
|
||
func (p *lexiJSON) UnmarshalBinary(b []byte) error { | ||
return json.Unmarshal(b, p.thing) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.